secur32/tests: Add AcquireCredentialsHandleW tests.
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com> Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
5cc400ed60
commit
ee7bc087fd
|
@ -42,6 +42,8 @@ static SECURITY_STATUS (SEC_ENTRY * pFreeContextBuffer)(PVOID pv);
|
||||||
static SECURITY_STATUS (SEC_ENTRY * pQuerySecurityPackageInfoA)(SEC_CHAR*, PSecPkgInfoA*);
|
static SECURITY_STATUS (SEC_ENTRY * pQuerySecurityPackageInfoA)(SEC_CHAR*, PSecPkgInfoA*);
|
||||||
static SECURITY_STATUS (SEC_ENTRY * pAcquireCredentialsHandleA)(SEC_CHAR*, SEC_CHAR*,
|
static SECURITY_STATUS (SEC_ENTRY * pAcquireCredentialsHandleA)(SEC_CHAR*, SEC_CHAR*,
|
||||||
ULONG, PLUID, PVOID, SEC_GET_KEY_FN, PVOID, PCredHandle, PTimeStamp);
|
ULONG, PLUID, PVOID, SEC_GET_KEY_FN, PVOID, PCredHandle, PTimeStamp);
|
||||||
|
static SECURITY_STATUS (SEC_ENTRY * pAcquireCredentialsHandleW)(SEC_CHAR*, SEC_WCHAR*,
|
||||||
|
ULONG, PLUID, void*, SEC_GET_KEY_FN, void*, CredHandle*, TimeStamp*);
|
||||||
static SECURITY_STATUS (SEC_ENTRY * pInitializeSecurityContextA)(PCredHandle, PCtxtHandle,
|
static SECURITY_STATUS (SEC_ENTRY * pInitializeSecurityContextA)(PCredHandle, PCtxtHandle,
|
||||||
SEC_CHAR*, ULONG, ULONG, ULONG, PSecBufferDesc, ULONG,
|
SEC_CHAR*, ULONG, ULONG, ULONG, PSecBufferDesc, ULONG,
|
||||||
PCtxtHandle, PSecBufferDesc, PULONG, PTimeStamp);
|
PCtxtHandle, PSecBufferDesc, PULONG, PTimeStamp);
|
||||||
|
@ -149,6 +151,11 @@ static BYTE crypt_message_server2[] =
|
||||||
{0xc8, 0xf2, 0x39, 0x7f, 0x0c, 0xaf, 0xf5, 0x5d, 0xef, 0x0c,
|
{0xc8, 0xf2, 0x39, 0x7f, 0x0c, 0xaf, 0xf5, 0x5d, 0xef, 0x0c,
|
||||||
0x8b, 0x5f, 0x82};
|
0x8b, 0x5f, 0x82};
|
||||||
|
|
||||||
|
static char test_user[] = "testuser",
|
||||||
|
workgroup[] = "WORKGROUP",
|
||||||
|
test_pass[] = "testpass",
|
||||||
|
sec_pkg_name[] = "NTLM";
|
||||||
|
|
||||||
static void InitFunctionPtrs(void)
|
static void InitFunctionPtrs(void)
|
||||||
{
|
{
|
||||||
secdll = LoadLibraryA("secur32.dll");
|
secdll = LoadLibraryA("secur32.dll");
|
||||||
|
@ -160,6 +167,7 @@ static void InitFunctionPtrs(void)
|
||||||
pFreeContextBuffer = (PVOID)GetProcAddress(secdll, "FreeContextBuffer");
|
pFreeContextBuffer = (PVOID)GetProcAddress(secdll, "FreeContextBuffer");
|
||||||
pQuerySecurityPackageInfoA = (PVOID)GetProcAddress(secdll, "QuerySecurityPackageInfoA");
|
pQuerySecurityPackageInfoA = (PVOID)GetProcAddress(secdll, "QuerySecurityPackageInfoA");
|
||||||
pAcquireCredentialsHandleA = (PVOID)GetProcAddress(secdll, "AcquireCredentialsHandleA");
|
pAcquireCredentialsHandleA = (PVOID)GetProcAddress(secdll, "AcquireCredentialsHandleA");
|
||||||
|
pAcquireCredentialsHandleW = (void*)GetProcAddress(secdll, "AcquireCredentialsHandleW");
|
||||||
pInitializeSecurityContextA = (PVOID)GetProcAddress(secdll, "InitializeSecurityContextA");
|
pInitializeSecurityContextA = (PVOID)GetProcAddress(secdll, "InitializeSecurityContextA");
|
||||||
pCompleteAuthToken = (PVOID)GetProcAddress(secdll, "CompleteAuthToken");
|
pCompleteAuthToken = (PVOID)GetProcAddress(secdll, "CompleteAuthToken");
|
||||||
pAcceptSecurityContext = (PVOID)GetProcAddress(secdll, "AcceptSecurityContext");
|
pAcceptSecurityContext = (PVOID)GetProcAddress(secdll, "AcceptSecurityContext");
|
||||||
|
@ -568,10 +576,6 @@ static void testInitializeSecurityContextFlags(void)
|
||||||
PSecPkgInfoA pkg_info = NULL;
|
PSecPkgInfoA pkg_info = NULL;
|
||||||
SspiData client;
|
SspiData client;
|
||||||
SEC_WINNT_AUTH_IDENTITY_A id;
|
SEC_WINNT_AUTH_IDENTITY_A id;
|
||||||
static char sec_pkg_name[] = "NTLM",
|
|
||||||
test_user[] = "testuser",
|
|
||||||
workgroup[] = "WORKGROUP",
|
|
||||||
test_pass[] = "testpass";
|
|
||||||
ULONG req_attr, ctxt_attr;
|
ULONG req_attr, ctxt_attr;
|
||||||
TimeStamp ttl;
|
TimeStamp ttl;
|
||||||
PBYTE packet;
|
PBYTE packet;
|
||||||
|
@ -793,10 +797,6 @@ static void testAuth(ULONG data_rep, BOOL fake)
|
||||||
SspiData client, server;
|
SspiData client, server;
|
||||||
SEC_WINNT_AUTH_IDENTITY_A id;
|
SEC_WINNT_AUTH_IDENTITY_A id;
|
||||||
SecPkgContext_Sizes ctxt_sizes;
|
SecPkgContext_Sizes ctxt_sizes;
|
||||||
static char sec_pkg_name[] = "NTLM",
|
|
||||||
test_user[] = "testuser",
|
|
||||||
workgroup[] = "WORKGROUP",
|
|
||||||
test_pass[] = "testpass";
|
|
||||||
|
|
||||||
if(pQuerySecurityPackageInfoA( sec_pkg_name, &pkg_info)!= SEC_E_OK)
|
if(pQuerySecurityPackageInfoA( sec_pkg_name, &pkg_info)!= SEC_E_OK)
|
||||||
{
|
{
|
||||||
|
@ -930,9 +930,6 @@ static void testSignSeal(void)
|
||||||
SecBuffer data[2], fake_data[2], complex_data[4];
|
SecBuffer data[2], fake_data[2], complex_data[4];
|
||||||
ULONG qop = 0xdeadbeef;
|
ULONG qop = 0xdeadbeef;
|
||||||
SecPkgContext_Sizes ctxt_sizes;
|
SecPkgContext_Sizes ctxt_sizes;
|
||||||
static char test_user[] = "testuser",
|
|
||||||
workgroup[] = "WORKGROUP",
|
|
||||||
test_pass[] = "testpass";
|
|
||||||
|
|
||||||
complex_data[1].pvBuffer = complex_data[3].pvBuffer = NULL;
|
complex_data[1].pvBuffer = complex_data[3].pvBuffer = NULL;
|
||||||
|
|
||||||
|
@ -1186,10 +1183,6 @@ static BOOL testAcquireCredentialsHandle(void)
|
||||||
{
|
{
|
||||||
CredHandle cred;
|
CredHandle cred;
|
||||||
TimeStamp ttl;
|
TimeStamp ttl;
|
||||||
static char test_user[] = "testuser",
|
|
||||||
workgroup[] = "WORKGROUP",
|
|
||||||
test_pass[] = "testpass",
|
|
||||||
sec_pkg_name[] = "NTLM";
|
|
||||||
SECURITY_STATUS ret;
|
SECURITY_STATUS ret;
|
||||||
SEC_WINNT_AUTH_IDENTITY_A id;
|
SEC_WINNT_AUTH_IDENTITY_A id;
|
||||||
PSecPkgInfoA pkg_info = NULL;
|
PSecPkgInfoA pkg_info = NULL;
|
||||||
|
@ -1251,12 +1244,98 @@ static BOOL testAcquireCredentialsHandle(void)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void testAcquireCredentialsHandleW(void)
|
||||||
|
{
|
||||||
|
CredHandle cred;
|
||||||
|
TimeStamp ttl;
|
||||||
|
static WCHAR sec_pkg_nameW[] = {'N','T','L','M',0 };
|
||||||
|
static WCHAR test_userW[] = {'t','e','s','t','u','s','e','r',0 };
|
||||||
|
static WCHAR workgroupW[] = {'W','O','R','K','G','R','O','U','P',0};
|
||||||
|
static WCHAR test_passW[] = {'t','e','s','t','p','a','s','s',0};
|
||||||
|
SECURITY_STATUS ret;
|
||||||
|
SEC_WINNT_AUTH_IDENTITY_A idA;
|
||||||
|
SEC_WINNT_AUTH_IDENTITY_W id;
|
||||||
|
PSecPkgInfoA pkg_info = NULL;
|
||||||
|
|
||||||
|
if(!pAcquireCredentialsHandleW)
|
||||||
|
{
|
||||||
|
win_skip("AcquireCredentialsHandleW not available\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pQuerySecurityPackageInfoA(sec_pkg_name, &pkg_info) != SEC_E_OK)
|
||||||
|
{
|
||||||
|
ok(0, "NTLM package not installed, skipping test\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pFreeContextBuffer(pkg_info);
|
||||||
|
|
||||||
|
id.User = test_userW;
|
||||||
|
id.UserLength = lstrlenW(test_userW);
|
||||||
|
id.Domain = workgroupW;
|
||||||
|
id.DomainLength = lstrlenW(workgroupW);
|
||||||
|
id.Password = test_passW;
|
||||||
|
id.PasswordLength = lstrlenW(test_passW);
|
||||||
|
id.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
|
||||||
|
|
||||||
|
ret = pAcquireCredentialsHandleW(NULL, sec_pkg_nameW, SECPKG_CRED_OUTBOUND,
|
||||||
|
NULL, &id, NULL, NULL, &cred, &ttl);
|
||||||
|
ok(ret == SEC_E_OK, "AcquireCredentialsHandeW() returned %s\n",
|
||||||
|
getSecError(ret));
|
||||||
|
pFreeCredentialsHandle(&cred);
|
||||||
|
|
||||||
|
id.DomainLength = 0;
|
||||||
|
ret = pAcquireCredentialsHandleW(NULL, sec_pkg_nameW, SECPKG_CRED_OUTBOUND,
|
||||||
|
NULL, &id, NULL, NULL, &cred, &ttl);
|
||||||
|
ok(ret == SEC_E_OK, "AcquireCredentialsHandeW() returned %s\n",
|
||||||
|
getSecError(ret));
|
||||||
|
pFreeCredentialsHandle(&cred);
|
||||||
|
|
||||||
|
id.Domain = NULL;
|
||||||
|
ret = pAcquireCredentialsHandleW(NULL, sec_pkg_nameW, SECPKG_CRED_OUTBOUND,
|
||||||
|
NULL, &id, NULL, NULL, &cred, &ttl);
|
||||||
|
ok(ret == SEC_E_OK, "AcquireCredentialsHandeW() returned %s\n",
|
||||||
|
getSecError(ret));
|
||||||
|
pFreeCredentialsHandle(&cred);
|
||||||
|
|
||||||
|
id.Domain = workgroupW;
|
||||||
|
id.DomainLength = lstrlenW(workgroupW);
|
||||||
|
id.UserLength = 0;
|
||||||
|
id.User = NULL;
|
||||||
|
ret = pAcquireCredentialsHandleW(NULL, sec_pkg_nameW, SECPKG_CRED_OUTBOUND,
|
||||||
|
NULL, &id, NULL, NULL, &cred, &ttl);
|
||||||
|
ok(ret == SEC_E_OK, "AcquireCredentialsHandeW() returned %s\n",
|
||||||
|
getSecError(ret));
|
||||||
|
pFreeCredentialsHandle(&cred);
|
||||||
|
|
||||||
|
id.User = test_userW;
|
||||||
|
id.UserLength = lstrlenW(test_userW);
|
||||||
|
id.Password = test_passW; /* NULL string causes a crash. */
|
||||||
|
id.PasswordLength = 0;
|
||||||
|
ret = pAcquireCredentialsHandleW(NULL, sec_pkg_nameW, SECPKG_CRED_OUTBOUND,
|
||||||
|
NULL, &id, NULL, NULL, &cred, &ttl);
|
||||||
|
ok(ret == SEC_E_OK, "AcquireCredentialsHandeW() returned %s\n",
|
||||||
|
getSecError(ret));
|
||||||
|
pFreeCredentialsHandle(&cred);
|
||||||
|
|
||||||
|
/* Test using the ASCII structure. */
|
||||||
|
idA.User = (unsigned char*) test_user;
|
||||||
|
idA.UserLength = strlen(test_user);
|
||||||
|
idA.Domain = (unsigned char *) workgroup;
|
||||||
|
idA.DomainLength = strlen(workgroup);
|
||||||
|
idA.Password = (unsigned char*) test_pass;
|
||||||
|
idA.PasswordLength = strlen(test_pass);
|
||||||
|
idA.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
|
||||||
|
|
||||||
|
ret = pAcquireCredentialsHandleW(NULL, sec_pkg_nameW, SECPKG_CRED_OUTBOUND,
|
||||||
|
NULL, &idA, NULL, NULL, &cred, &ttl);
|
||||||
|
ok(ret == SEC_E_OK, "AcquireCredentialsHandeW() returned %s\n",
|
||||||
|
getSecError(ret));
|
||||||
|
pFreeCredentialsHandle(&cred);
|
||||||
|
}
|
||||||
|
|
||||||
static void test_cred_multiple_use(void)
|
static void test_cred_multiple_use(void)
|
||||||
{
|
{
|
||||||
static char test_user[] = "testuser",
|
|
||||||
workgroup[] = "WORKGROUP",
|
|
||||||
test_pass[] = "testpass",
|
|
||||||
sec_pkg_name[] = "NTLM";
|
|
||||||
SECURITY_STATUS ret;
|
SECURITY_STATUS ret;
|
||||||
SEC_WINNT_AUTH_IDENTITY_A id;
|
SEC_WINNT_AUTH_IDENTITY_A id;
|
||||||
PSecPkgInfoA pkg_info = NULL;
|
PSecPkgInfoA pkg_info = NULL;
|
||||||
|
@ -1373,6 +1452,8 @@ START_TEST(ntlm)
|
||||||
pAcquireCredentialsHandleA && pInitializeSecurityContextA &&
|
pAcquireCredentialsHandleA && pInitializeSecurityContextA &&
|
||||||
pCompleteAuthToken && pQuerySecurityPackageInfoA)
|
pCompleteAuthToken && pQuerySecurityPackageInfoA)
|
||||||
{
|
{
|
||||||
|
testAcquireCredentialsHandleW();
|
||||||
|
|
||||||
if(!testAcquireCredentialsHandle())
|
if(!testAcquireCredentialsHandle())
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
testInitializeSecurityContextFlags();
|
testInitializeSecurityContextFlags();
|
||||||
|
|
Loading…
Reference in New Issue