static void test_SspiPromptForCredentials(void) { static const WCHAR targetW[] = {'S','s','p','i','T','e','s','t',0}; static const WCHAR basicW[] = {'b','a','s','i','c',0}; ULONG ret; SECURITY_STATUS status; CREDUI_INFOW info; PSEC_WINNT_AUTH_IDENTITY_OPAQUE id; const WCHAR *username, *domain, *creds; int save; if (!pSspiPromptForCredentialsW || !pSspiFreeAuthIdentity) { win_skip( "SspiPromptForCredentialsW is missing\n" ); return; } info.cbSize = sizeof(info); info.hwndParent = NULL; info.pszMessageText = targetW; info.pszCaptionText = basicW; info.hbmBanner = NULL; ret = pSspiPromptForCredentialsW( NULL, &info, 0, basicW, NULL, &id, &save, 0 ); ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); ret = pSspiPromptForCredentialsW( targetW, &info, 0, NULL, NULL, &id, &save, 0 ); ok( ret == ERROR_NO_SUCH_PACKAGE, "got %u\n", ret ); if (winetest_interactive) { id = NULL; save = -1; ret = pSspiPromptForCredentialsW( targetW, &info, 0, basicW, NULL, &id, &save, 0 ); ok( ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "got %u\n", ret ); if (ret == ERROR_SUCCESS) { ok( id != NULL, "id not set\n" ); ok( save == TRUE || save == FALSE, "got %d\n", save ); username = creds = NULL; domain = (const WCHAR *)0xdeadbeef; status = pSspiEncodeAuthIdentityAsStrings( id, &username, &domain, &creds ); ok( status == SEC_E_OK, "got %u\n", status ); ok( username != NULL, "username not set\n" ); ok( domain == NULL, "domain not set\n" ); ok( creds != NULL, "creds not set\n" ); pSspiFreeAuthIdentity( id ); } } }
static void test_SspiEncodeStringsAsAuthIdentity(void) { static const WCHAR username[] = {'u','s','e','r','n','a','m','e',0}; static const WCHAR domainname[] = {'d','o','m','a','i','n','n','a','m','e',0}; static const WCHAR password[] = {'p','a','s','s','w','o','r','d',0}; const WCHAR *username_ptr, *domainname_ptr, *password_ptr; PSEC_WINNT_AUTH_IDENTITY_OPAQUE id; SECURITY_STATUS status; if (!pSspiEncodeStringsAsAuthIdentity) { win_skip( "SspiEncodeAuthIdentityAsStrings not exported by secur32.dll\n" ); return; } status = pSspiEncodeStringsAsAuthIdentity( NULL, NULL, NULL, NULL ); ok( status == SEC_E_INVALID_TOKEN, "got %08x\n", status ); id = (PSEC_WINNT_AUTH_IDENTITY_OPAQUE)0xdeadbeef; status = pSspiEncodeStringsAsAuthIdentity( NULL, NULL, NULL, &id ); ok( status == SEC_E_INVALID_TOKEN, "got %08x\n", status ); ok( id == (PSEC_WINNT_AUTH_IDENTITY_OPAQUE)0xdeadbeef, "id set\n" ); id = NULL; status = pSspiEncodeStringsAsAuthIdentity( NULL, NULL, password, &id ); ok( status == SEC_E_OK, "got %08x\n", status ); ok( id != NULL, "id not set\n" ); pSspiFreeAuthIdentity( id ); id = NULL; status = pSspiEncodeStringsAsAuthIdentity( NULL, domainname, password, &id ); ok( status == SEC_E_OK, "got %08x\n", status ); ok( id != NULL, "id not set\n" ); pSspiFreeAuthIdentity( id ); id = NULL; status = pSspiEncodeStringsAsAuthIdentity( username, NULL, password, &id ); ok( status == SEC_E_OK, "got %08x\n", status ); ok( id != NULL, "id not set\n" ); pSspiFreeAuthIdentity( id ); id = NULL; status = pSspiEncodeStringsAsAuthIdentity( username, NULL, NULL, &id ); ok( status == SEC_E_OK, "got %08x\n", status ); ok( id != NULL, "id not set\n" ); pSspiFreeAuthIdentity( id ); id = NULL; status = pSspiEncodeStringsAsAuthIdentity( username, domainname, password, &id ); ok( status == SEC_E_OK, "got %08x\n", status ); ok( id != NULL, "id not set\n" ); username_ptr = domainname_ptr = password_ptr = NULL; status = pSspiEncodeAuthIdentityAsStrings( id, &username_ptr, &domainname_ptr, &password_ptr ); ok( status == SEC_E_OK, "got %08x\n", status ); ok( !lstrcmpW( username, username_ptr ), "wrong username\n" ); ok( !lstrcmpW( domainname, domainname_ptr ), "wrong domainname\n" ); ok( !lstrcmpW( password, password_ptr ), "wrong password\n" ); pSspiZeroAuthIdentity( id ); pSspiLocalFree( (void *)username_ptr ); pSspiLocalFree( (void *)domainname_ptr ); pSspiLocalFree( (void *)password_ptr ); pSspiFreeAuthIdentity( id ); id = NULL; status = pSspiEncodeStringsAsAuthIdentity( username, NULL, password, &id ); ok( status == SEC_E_OK, "got %08x\n", status ); ok( id != NULL, "id not set\n" ); username_ptr = password_ptr = NULL; domainname_ptr = (const WCHAR *)0xdeadbeef; status = pSspiEncodeAuthIdentityAsStrings( id, &username_ptr, &domainname_ptr, &password_ptr ); ok( status == SEC_E_OK, "got %08x\n", status ); ok( !lstrcmpW( username, username_ptr ), "wrong username\n" ); ok( domainname_ptr == NULL, "domainname_ptr not cleared\n" ); ok( !lstrcmpW( password, password_ptr ), "wrong password\n" ); pSspiLocalFree( (void *)username_ptr ); pSspiLocalFree( (void *)password_ptr ); pSspiFreeAuthIdentity( id ); }