ReactOS 0.4.17-dev-806-gffa4164
credui.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wincred.h"
#include "sspi.h"
#include "wine/test.h"
Include dependency graph for credui.c:

Go to the source code of this file.

Functions

static SECURITY_STATUS (SEC_ENTRY *pSspiEncodeAuthIdentityAsStrings)(PSEC_WINNT_AUTH_IDENTITY_OPAQUE
 
static PCWSTR PCWSTR PCWSTR *static void (SEC_ENTRY *pSspiFreeAuthIdentity)(PSEC_WINNT_AUTH_IDENTITY_OPAQUE)
 
static ULONG (SEC_ENTRY *pSspiPromptForCredentialsW)(PCWSTR
 
static void test_CredUIPromptForCredentials (void)
 
static void test_SspiPromptForCredentials (void)
 
 START_TEST (credui)
 

Variables

static void ULONG
 
static void PCWSTR
 
static void PSEC_WINNT_AUTH_IDENTITY_OPAQUE
 

Function Documentation

◆ SECURITY_STATUS()

static SECURITY_STATUS ( SEC_ENTRY pSspiEncodeAuthIdentityAsStrings)
static

◆ START_TEST()

START_TEST ( credui  )

Definition at line 191 of file credui.c.

192{
193 HMODULE hcredui = GetModuleHandleA( "credui.dll" ), hsecur32 = LoadLibraryA( "secur32.dll" );
194
195 if (hcredui)
196 pSspiPromptForCredentialsW = (void *)GetProcAddress( hcredui, "SspiPromptForCredentialsW" );
197 if (hsecur32)
198 {
199 pSspiEncodeAuthIdentityAsStrings = (void *)GetProcAddress( hsecur32, "SspiEncodeAuthIdentityAsStrings" );
200 pSspiFreeAuthIdentity = (void *)GetProcAddress( hsecur32, "SspiFreeAuthIdentity" );
201 }
202
205
206 FreeLibrary( hsecur32 );
207}
static void test_SspiPromptForCredentials(void)
Definition: credui.c:142
static void test_CredUIPromptForCredentials(void)
Definition: credui.c:37
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111

◆ test_CredUIPromptForCredentials()

static void test_CredUIPromptForCredentials ( void  )
static

Definition at line 37 of file credui.c.

38{
39 static const WCHAR wszServerName[] = L"WineTest";
40 DWORD ret;
41 WCHAR username[256];
42 WCHAR password[256];
43 CREDUI_INFOW credui_info;
44 BOOL save = FALSE;
45
46 credui_info.cbSize = sizeof(credui_info);
47 credui_info.hwndParent = NULL;
48 credui_info.pszMessageText = NULL;
49 credui_info.hbmBanner = NULL;
50
52 ok(ret == ERROR_INVALID_PARAMETER /* 2003 + */ || ret == ERROR_NOT_FOUND /* XP */,
53 "CredUIConfirmCredentials should have returned ERROR_INVALID_PARAMETER or ERROR_NOT_FOUND instead of %ld\n", ret);
54
55 ret = CredUIConfirmCredentialsW(wszServerName, TRUE);
56 ok(ret == ERROR_NOT_FOUND, "CredUIConfirmCredentials should have returned ERROR_NOT_FOUND instead of %ld\n", ret);
57
58 username[0] = '\0';
59 password[0] = '\0';
64 ok(ret == ERROR_INVALID_FLAGS, "CredUIPromptForCredentials should have returned ERROR_INVALID_FLAGS instead of %ld\n", ret);
65
70 ok(ret == ERROR_INVALID_PARAMETER, "CredUIPromptForCredentials should have returned ERROR_INVALID_PARAMETER instead of %ld\n", ret);
71
72 ret = CredUIPromptForCredentialsW(NULL, wszServerName, NULL, 0, username,
76 ok(ret == ERROR_INVALID_PARAMETER, "CredUIPromptForCredentials should have returned ERROR_INVALID_PARAMETER instead of %ld\n", ret);
77
79 {
80 ret = CredUIPromptForCredentialsW(NULL, wszServerName, NULL, 0, username,
84 ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %ld\n", ret);
85 if (ret == ERROR_SUCCESS)
86 {
87 ret = CredUIConfirmCredentialsW(wszServerName, FALSE);
88 ok(ret == ERROR_SUCCESS, "CredUIConfirmCredentials failed with error %ld\n", ret);
89 }
90
91 credui_info.pszCaptionText = L"CREDUI_FLAGS_EXPECT_CONFIRMATION";
92 ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL, ERROR_ACCESS_DENIED,
96 ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %ld\n", ret);
97 if (ret == ERROR_SUCCESS)
98 {
99 ret = CredUIConfirmCredentialsW(wszServerName, FALSE);
100 ok(ret == ERROR_SUCCESS, "CredUIConfirmCredentials failed with error %ld\n", ret);
101 }
102
103 credui_info.pszCaptionText = L"CREDUI_FLAGS_INCORRECT_PASSWORD|CREDUI_FLAGS_EXPECT_CONFIRMATION";
104 ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL, 0,
108 ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %ld\n", ret);
109 if (ret == ERROR_SUCCESS)
110 {
111 ret = CredUIConfirmCredentialsW(wszServerName, FALSE);
112 ok(ret == ERROR_SUCCESS, "CredUIConfirmCredentials failed with error %ld\n", ret);
113 }
114
115
116 save = TRUE;
117 credui_info.pszCaptionText = L"CREDUI_FLAGS_DO_NOT_PERSIST|CREDUI_FLAGS_EXPECT_CONFIRMATION";
118 ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL, 0,
122 ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %ld\n", ret);
123 ok(save, "save flag should have been untouched\n");
124
125 save = FALSE;
126 credui_info.pszCaptionText = L"CREDUI_FLAGS_PERSIST|CREDUI_FLAGS_EXPECT_CONFIRMATION";
127 ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL, 0,
131 ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %ld\n", ret);
132 ok(!save, "save flag should have been untouched\n");
133 if (ret == ERROR_SUCCESS)
134 {
135 ret = CredUIConfirmCredentialsW(wszServerName, FALSE);
136 ok(ret == ERROR_SUCCESS, "CredUIConfirmCredentials failed with error %ld\n", ret);
137 }
138
139 }
140}
#define ok(value,...)
Definition: atltest.h:57
#define ARRAY_SIZE(A)
Definition: main.h:20
static UCHAR password[]
Definition: bcrypt.c:520
DWORD WINAPI CredUIPromptForCredentialsW(PCREDUI_INFOW pUIInfo, PCWSTR pszTargetName, PCtxtHandle Reserved, DWORD dwAuthError, PWSTR pszUsername, ULONG ulUsernameMaxChars, PWSTR pszPassword, ULONG ulPasswordMaxChars, PBOOL pfSave, DWORD dwFlags)
Definition: credui_main.c:593
DWORD WINAPI CredUIConfirmCredentialsW(PCWSTR pszTargetName, BOOL bConfirm)
Definition: credui_main.c:713
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
return ret
Definition: mutex.c:147
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
int winetest_interactive
static WCHAR username[]
Definition: url.c:32
short WCHAR
Definition: pedump.c:58
HWND hwndParent
Definition: wincred.h:144
PCWSTR pszMessageText
Definition: wincred.h:145
DWORD cbSize
Definition: wincred.h:143
PCWSTR pszCaptionText
Definition: wincred.h:146
HBITMAP hbmBanner
Definition: wincred.h:147
#define CREDUI_FLAGS_EXPECT_CONFIRMATION
Definition: wincred.h:236
#define CREDUI_FLAGS_ALWAYS_SHOW_UI
Definition: wincred.h:229
#define CREDUI_FLAGS_GENERIC_CREDENTIALS
Definition: wincred.h:237
#define CREDUI_FLAGS_INCORRECT_PASSWORD
Definition: wincred.h:223
#define CREDUI_FLAGS_PERSIST
Definition: wincred.h:234
#define CREDUI_FLAGS_DO_NOT_PERSIST
Definition: wincred.h:224
#define CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX
Definition: wincred.h:228
#define ERROR_CANCELLED
Definition: winerror.h:1055
#define ERROR_INVALID_FLAGS
Definition: winerror.h:907
#define ERROR_NOT_FOUND
Definition: winerror.h:1014

Referenced by START_TEST().

◆ test_SspiPromptForCredentials()

static void test_SspiPromptForCredentials ( void  )
static

Definition at line 142 of file credui.c.

143{
144 ULONG ret;
148 const WCHAR *username, *domain, *creds;
149 int save;
150
151 if (!pSspiPromptForCredentialsW || !pSspiFreeAuthIdentity)
152 {
153 win_skip( "SspiPromptForCredentialsW is missing\n" );
154 return;
155 }
156
157 info.cbSize = sizeof(info);
158 info.hwndParent = NULL;
159 info.pszMessageText = L"SspiTest";
160 info.pszCaptionText = L"basic";
161 info.hbmBanner = NULL;
162 ret = pSspiPromptForCredentialsW( NULL, &info, 0, L"basic", NULL, &id, &save, 0 );
163 ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret );
164
165 ret = pSspiPromptForCredentialsW( L"SspiTest", &info, 0, NULL, NULL, &id, &save, 0 );
166 ok( ret == ERROR_NO_SUCH_PACKAGE, "got %lu\n", ret );
167
169 {
170 id = NULL;
171 save = -1;
172 ret = pSspiPromptForCredentialsW( L"SspiTest", &info, 0, L"basic", NULL, &id, &save, 0 );
173 ok( ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "got %lu\n", ret );
174 if (ret == ERROR_SUCCESS)
175 {
176 ok( id != NULL, "id not set\n" );
177 ok( save == TRUE || save == FALSE, "got %d\n", save );
178
179 username = creds = NULL;
180 domain = (const WCHAR *)0xdeadbeef;
181 status = pSspiEncodeAuthIdentityAsStrings( id, &username, &domain, &creds );
182 ok( status == SEC_E_OK, "got %lu\n", status );
183 ok( username != NULL, "username not set\n" );
184 ok( domain == NULL, "domain not set\n" );
185 ok( creds != NULL, "creds not set\n" );
186 pSspiFreeAuthIdentity( id );
187 }
188 }
189}
GLuint id
Definition: glext.h:5910
#define win_skip
Definition: minitest.h:67
LONG SECURITY_STATUS
Definition: sspi.h:34
Definition: cookie.c:42
Definition: ps.c:97
uint32_t ULONG
Definition: typedefs.h:59
#define SEC_E_OK
Definition: winerror.h:3450
#define ERROR_NO_SUCH_PACKAGE
Definition: winerror.h:1190

Referenced by START_TEST().

◆ ULONG()

static ULONG ( SEC_ENTRY pSspiPromptForCredentialsW)
static

◆ void()

static PCWSTR PCWSTR PCWSTR *static void ( SEC_ENTRY pSspiFreeAuthIdentity)
static

Variable Documentation

◆ PCWSTR

Definition at line 35 of file credui.c.

◆ PSEC_WINNT_AUTH_IDENTITY_OPAQUE

Definition at line 35 of file credui.c.

◆ ULONG