ReactOS 0.4.15-dev-7924-g5949c20
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 201 of file credui.c.

202{
203 HMODULE hcredui = GetModuleHandleA( "credui.dll" ), hsecur32 = LoadLibraryA( "secur32.dll" );
204
205 if (hcredui)
206 pSspiPromptForCredentialsW = (void *)GetProcAddress( hcredui, "SspiPromptForCredentialsW" );
207 if (hsecur32)
208 {
209 pSspiEncodeAuthIdentityAsStrings = (void *)GetProcAddress( hsecur32, "SspiEncodeAuthIdentityAsStrings" );
210 pSspiFreeAuthIdentity = (void *)GetProcAddress( hsecur32, "SspiFreeAuthIdentity" );
211 }
212
215
216 FreeLibrary( hsecur32 );
217}
static void test_SspiPromptForCredentials(void)
Definition: credui.c:150
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[] = {'W','i','n','e','T','e','s','t',0};
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 %d\n", ret);
54
55 ret = CredUIConfirmCredentialsW(wszServerName, TRUE);
56 ok(ret == ERROR_NOT_FOUND, "CredUIConfirmCredentials should have returned ERROR_NOT_FOUND instead of %d\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 %d\n", ret);
65
70 ok(ret == ERROR_INVALID_PARAMETER, "CredUIPromptForCredentials should have returned ERROR_INVALID_PARAMETER instead of %d\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 %d\n", ret);
77
79 {
80 static const WCHAR wszCaption1[] = {'C','R','E','D','U','I','_','F','L','A','G','S','_','E','X','P','E','C','T','_','C','O','N','F','I','R','M','A','T','I','O','N',0};
81 static const WCHAR wszCaption2[] = {'C','R','E','D','U','I','_','F','L','A','G','S','_','I','N','C','O','R','R','E','C','T','_','P','A','S','S','W','O','R','D','|',
82 'C','R','E','D','U','I','_','F','L','A','G','S','_','E','X','P','E','C','T','_','C','O','N','F','I','R','M','A','T','I','O','N',0};
83 static const WCHAR wszCaption3[] = {'C','R','E','D','U','I','_','F','L','A','G','S','_','D','O','_','N','O','T','_','P','E','R','S','I','S','T','|',
84 'C','R','E','D','U','I','_','F','L','A','G','S','_','E','X','P','E','C','T','_','C','O','N','F','I','R','M','A','T','I','O','N',0};
85 static const WCHAR wszCaption4[] = {'C','R','E','D','U','I','_','F','L','A','G','S','_','P','E','R','S','I','S','T','|',
86 'C','R','E','D','U','I','_','F','L','A','G','S','_','E','X','P','E','C','T','_','C','O','N','F','I','R','M','A','T','I','O','N',0};
87
88 ret = CredUIPromptForCredentialsW(NULL, wszServerName, NULL, 0, username,
92 ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret);
93 if (ret == ERROR_SUCCESS)
94 {
95 ret = CredUIConfirmCredentialsW(wszServerName, FALSE);
96 ok(ret == ERROR_SUCCESS, "CredUIConfirmCredentials failed with error %d\n", ret);
97 }
98
99 credui_info.pszCaptionText = wszCaption1;
100 ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL, ERROR_ACCESS_DENIED,
104 ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret);
105 if (ret == ERROR_SUCCESS)
106 {
107 ret = CredUIConfirmCredentialsW(wszServerName, FALSE);
108 ok(ret == ERROR_SUCCESS, "CredUIConfirmCredentials failed with error %d\n", ret);
109 }
110
111 credui_info.pszCaptionText = wszCaption2;
112 ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL, 0,
116 ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret);
117 if (ret == ERROR_SUCCESS)
118 {
119 ret = CredUIConfirmCredentialsW(wszServerName, FALSE);
120 ok(ret == ERROR_SUCCESS, "CredUIConfirmCredentials failed with error %d\n", ret);
121 }
122
123
124 save = TRUE;
125 credui_info.pszCaptionText = wszCaption3;
126 ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL, 0,
130 ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret);
131 ok(save, "save flag should have been untouched\n");
132
133 save = FALSE;
134 credui_info.pszCaptionText = wszCaption4;
135 ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL, 0,
139 ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret);
140 ok(!save, "save flag should have been untouched\n");
141 if (ret == ERROR_SUCCESS)
142 {
143 ret = CredUIConfirmCredentialsW(wszServerName, FALSE);
144 ok(ret == ERROR_SUCCESS, "CredUIConfirmCredentials failed with error %d\n", ret);
145 }
146
147 }
148}
#define ok(value,...)
Definition: atltest.h:57
#define ARRAY_SIZE(A)
Definition: main.h:33
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:599
DWORD WINAPI CredUIConfirmCredentialsW(PCWSTR pszTargetName, BOOL bConfirm)
Definition: credui_main.c:719
#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
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
static WCHAR password[]
Definition: url.c:33
static WCHAR username[]
Definition: url.c:32
int winetest_interactive
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
int ret
#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:726
#define ERROR_INVALID_FLAGS
Definition: winerror.h:583
#define ERROR_NOT_FOUND
Definition: winerror.h:690
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_SspiPromptForCredentials()

static void test_SspiPromptForCredentials ( void  )
static

Definition at line 150 of file credui.c.

151{
152 static const WCHAR targetW[] = {'S','s','p','i','T','e','s','t',0};
153 static const WCHAR basicW[] = {'b','a','s','i','c',0};
154 ULONG ret;
158 const WCHAR *username, *domain, *creds;
159 int save;
160
161 if (!pSspiPromptForCredentialsW || !pSspiFreeAuthIdentity)
162 {
163 win_skip( "SspiPromptForCredentialsW is missing\n" );
164 return;
165 }
166
167 info.cbSize = sizeof(info);
168 info.hwndParent = NULL;
169 info.pszMessageText = targetW;
170 info.pszCaptionText = basicW;
171 info.hbmBanner = NULL;
172 ret = pSspiPromptForCredentialsW( NULL, &info, 0, basicW, NULL, &id, &save, 0 );
173 ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret );
174
175 ret = pSspiPromptForCredentialsW( targetW, &info, 0, NULL, NULL, &id, &save, 0 );
176 ok( ret == ERROR_NO_SUCH_PACKAGE, "got %u\n", ret );
177
179 {
180 id = NULL;
181 save = -1;
182 ret = pSspiPromptForCredentialsW( targetW, &info, 0, basicW, NULL, &id, &save, 0 );
183 ok( ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "got %u\n", ret );
184 if (ret == ERROR_SUCCESS)
185 {
186 ok( id != NULL, "id not set\n" );
187 ok( save == TRUE || save == FALSE, "got %d\n", save );
188
189 username = creds = NULL;
190 domain = (const WCHAR *)0xdeadbeef;
191 status = pSspiEncodeAuthIdentityAsStrings( id, &username, &domain, &creds );
192 ok( status == SEC_E_OK, "got %u\n", status );
193 ok( username != NULL, "username not set\n" );
194 ok( domain == NULL, "domain not set\n" );
195 ok( creds != NULL, "creds not set\n" );
196 pSspiFreeAuthIdentity( id );
197 }
198 }
199}
GLuint id
Definition: glext.h:5910
LONG SECURITY_STATUS
Definition: sspi.h:34
static const WCHAR basicW[]
#define win_skip
Definition: test.h:160
Definition: cookie.c:42
Definition: ps.c:97
uint32_t ULONG
Definition: typedefs.h:59
#define SEC_E_OK
Definition: winerror.h:2356
#define ERROR_NO_SUCH_PACKAGE
Definition: winerror.h:845

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