[SECUR32_WINETEST] Sync with Wine Staging 1.9.11. CORE-11368

svn path=/trunk/; revision=71784
This commit is contained in:
Amine Khaldi 2016-07-03 11:50:18 +00:00
parent 6e323c1869
commit 78cd78815a
3 changed files with 147 additions and 55 deletions

View file

@ -162,30 +162,35 @@ static void testEnumerateSecurityPackages(void)
for(i = 0; i < num_packages; ++i){
trace("%d: Package \"%s\"\n", i, pkg_info[i].Name);
trace("Supported flags:\n");
if(pkg_info[i].fCapabilities & SECPKG_FLAG_INTEGRITY)
trace("\tSECPKG_FLAG_INTEGRITY\n");
if(pkg_info[i].fCapabilities & SECPKG_FLAG_PRIVACY)
trace("\tSECPKG_FLAG_PRIVACY\n");
if(pkg_info[i].fCapabilities & SECPKG_FLAG_TOKEN_ONLY)
trace("\tSECPKG_FLAG_TOKEN_ONLY\n");
if(pkg_info[i].fCapabilities & SECPKG_FLAG_DATAGRAM)
trace("\tSECPKG_FLAG_DATAGRAM\n");
if(pkg_info[i].fCapabilities & SECPKG_FLAG_CONNECTION)
trace("\tSECPKG_FLAG_CONNECTION\n");
if(pkg_info[i].fCapabilities & SECPKG_FLAG_MULTI_REQUIRED)
trace("\tSECPKG_FLAG_MULTI_REQUIRED\n");
if(pkg_info[i].fCapabilities & SECPKG_FLAG_CLIENT_ONLY)
trace("\tSECPKG_FLAG_CLIENT_ONLY\n");
if(pkg_info[i].fCapabilities & SECPKG_FLAG_EXTENDED_ERROR)
trace("\tSECPKG_FLAG_EXTENDED_ERROR\n");
if(pkg_info[i].fCapabilities & SECPKG_FLAG_IMPERSONATION)
trace("\tSECPKG_FLAG_IMPERSONATION\n");
if(pkg_info[i].fCapabilities & SECPKG_FLAG_ACCEPT_WIN32_NAME)
trace("\tSECPKG_FLAG_ACCEPT_WIN32_NAME\n");
if(pkg_info[i].fCapabilities & SECPKG_FLAG_STREAM)
trace("\tSECPKG_FLAG_STREAM\n");
if(pkg_info[i].fCapabilities & SECPKG_FLAG_READONLY_WITH_CHECKSUM)
trace("\tSECPKG_FLAG_READONLY_WITH_CHECKSUM\n");
#define X(flag) \
if(pkg_info[i].fCapabilities & flag) \
trace("\t" #flag "\n")
X(SECPKG_FLAG_INTEGRITY);
X(SECPKG_FLAG_PRIVACY);
X(SECPKG_FLAG_TOKEN_ONLY);
X(SECPKG_FLAG_DATAGRAM);
X(SECPKG_FLAG_CONNECTION);
X(SECPKG_FLAG_MULTI_REQUIRED);
X(SECPKG_FLAG_CLIENT_ONLY);
X(SECPKG_FLAG_EXTENDED_ERROR);
X(SECPKG_FLAG_IMPERSONATION);
X(SECPKG_FLAG_ACCEPT_WIN32_NAME);
X(SECPKG_FLAG_STREAM);
X(SECPKG_FLAG_NEGOTIABLE);
X(SECPKG_FLAG_GSS_COMPATIBLE);
X(SECPKG_FLAG_LOGON);
X(SECPKG_FLAG_ASCII_BUFFERS);
X(SECPKG_FLAG_FRAGMENT);
X(SECPKG_FLAG_MUTUAL_AUTH);
X(SECPKG_FLAG_DELEGATION);
X(SECPKG_FLAG_READONLY_WITH_CHECKSUM);
X(SECPKG_FLAG_RESTRICTED_TOKENS);
X(SECPKG_FLAG_NEGO_EXTENDER);
X(SECPKG_FLAG_NEGOTIABLE2);
X(SECPKG_FLAG_APPCONTAINER_PASSTHROUGH);
X(SECPKG_FLAG_APPCONTAINER_CHECKS);
#undef X
trace("Comment: %s\n", pkg_info[i].Comment);
trace("\n");
}

View file

@ -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 * pAcquireCredentialsHandleA)(SEC_CHAR*, SEC_CHAR*,
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,
SEC_CHAR*, ULONG, ULONG, ULONG, PSecBufferDesc, ULONG,
PCtxtHandle, PSecBufferDesc, PULONG, PTimeStamp);
@ -149,6 +151,11 @@ static BYTE crypt_message_server2[] =
{0xc8, 0xf2, 0x39, 0x7f, 0x0c, 0xaf, 0xf5, 0x5d, 0xef, 0x0c,
0x8b, 0x5f, 0x82};
static char test_user[] = "testuser",
workgroup[] = "WORKGROUP",
test_pass[] = "testpass",
sec_pkg_name[] = "NTLM";
static void InitFunctionPtrs(void)
{
secdll = LoadLibraryA("secur32.dll");
@ -160,6 +167,7 @@ static void InitFunctionPtrs(void)
pFreeContextBuffer = (PVOID)GetProcAddress(secdll, "FreeContextBuffer");
pQuerySecurityPackageInfoA = (PVOID)GetProcAddress(secdll, "QuerySecurityPackageInfoA");
pAcquireCredentialsHandleA = (PVOID)GetProcAddress(secdll, "AcquireCredentialsHandleA");
pAcquireCredentialsHandleW = (void*)GetProcAddress(secdll, "AcquireCredentialsHandleW");
pInitializeSecurityContextA = (PVOID)GetProcAddress(secdll, "InitializeSecurityContextA");
pCompleteAuthToken = (PVOID)GetProcAddress(secdll, "CompleteAuthToken");
pAcceptSecurityContext = (PVOID)GetProcAddress(secdll, "AcceptSecurityContext");
@ -327,7 +335,7 @@ static SECURITY_STATUS setupClient(SspiData *sspi_data, SEC_CHAR *provider)
trace("AcquireCredentialsHandle() returned %s\n", getSecError(ret));
}
ok(ret == SEC_E_OK, "AcquireCredentialsHande() returned %s\n",
ok(ret == SEC_E_OK, "AcquireCredentialsHandle() returned %s\n",
getSecError(ret));
return ret;
@ -355,7 +363,7 @@ static SECURITY_STATUS setupServer(SspiData *sspi_data, SEC_CHAR *provider)
trace("AcquireCredentialsHandle() returned %s\n", getSecError(ret));
}
ok(ret == SEC_E_OK, "AcquireCredentialsHande() returned %s\n",
ok(ret == SEC_E_OK, "AcquireCredentialsHandle() returned %s\n",
getSecError(ret));
return ret;
@ -568,10 +576,6 @@ static void testInitializeSecurityContextFlags(void)
PSecPkgInfoA pkg_info = NULL;
SspiData client;
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;
TimeStamp ttl;
PBYTE packet;
@ -793,10 +797,6 @@ static void testAuth(ULONG data_rep, BOOL fake)
SspiData client, server;
SEC_WINNT_AUTH_IDENTITY_A id;
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)
{
@ -930,9 +930,6 @@ static void testSignSeal(void)
SecBuffer data[2], fake_data[2], complex_data[4];
ULONG qop = 0xdeadbeef;
SecPkgContext_Sizes ctxt_sizes;
static char test_user[] = "testuser",
workgroup[] = "WORKGROUP",
test_pass[] = "testpass";
complex_data[1].pvBuffer = complex_data[3].pvBuffer = NULL;
@ -1186,10 +1183,6 @@ static BOOL testAcquireCredentialsHandle(void)
{
CredHandle cred;
TimeStamp ttl;
static char test_user[] = "testuser",
workgroup[] = "WORKGROUP",
test_pass[] = "testpass",
sec_pkg_name[] = "NTLM";
SECURITY_STATUS ret;
SEC_WINNT_AUTH_IDENTITY_A id;
PSecPkgInfoA pkg_info = NULL;
@ -1211,21 +1204,21 @@ static BOOL testAcquireCredentialsHandle(void)
ret = pAcquireCredentialsHandleA(NULL, sec_pkg_name, SECPKG_CRED_OUTBOUND,
NULL, &id, NULL, NULL, &cred, &ttl);
ok(ret == SEC_E_OK, "AcquireCredentialsHande() returned %s\n",
ok(ret == SEC_E_OK, "AcquireCredentialsHandle() returned %s\n",
getSecError(ret));
pFreeCredentialsHandle(&cred);
id.DomainLength = 0;
ret = pAcquireCredentialsHandleA(NULL, sec_pkg_name, SECPKG_CRED_OUTBOUND,
NULL, &id, NULL, NULL, &cred, &ttl);
ok(ret == SEC_E_OK, "AcquireCredentialsHande() returned %s\n",
ok(ret == SEC_E_OK, "AcquireCredentialsHandle() returned %s\n",
getSecError(ret));
pFreeCredentialsHandle(&cred);
id.Domain = NULL;
ret = pAcquireCredentialsHandleA(NULL, sec_pkg_name, SECPKG_CRED_OUTBOUND,
NULL, &id, NULL, NULL, &cred, &ttl);
ok(ret == SEC_E_OK, "AcquireCredentialsHande() returned %s\n",
ok(ret == SEC_E_OK, "AcquireCredentialsHandle() returned %s\n",
getSecError(ret));
pFreeCredentialsHandle(&cred);
@ -1235,7 +1228,7 @@ static BOOL testAcquireCredentialsHandle(void)
id.User = NULL;
ret = pAcquireCredentialsHandleA(NULL, sec_pkg_name, SECPKG_CRED_OUTBOUND,
NULL, &id, NULL, NULL, &cred, &ttl);
ok(ret == SEC_E_OK, "AcquireCredentialsHande() returned %s\n",
ok(ret == SEC_E_OK, "AcquireCredentialsHandle() returned %s\n",
getSecError(ret));
pFreeCredentialsHandle(&cred);
@ -1245,18 +1238,104 @@ static BOOL testAcquireCredentialsHandle(void)
id.PasswordLength = 0;
ret = pAcquireCredentialsHandleA(NULL, sec_pkg_name, SECPKG_CRED_OUTBOUND,
NULL, &id, NULL, NULL, &cred, &ttl);
ok(ret == SEC_E_OK, "AcquireCredentialsHande() returned %s\n",
ok(ret == SEC_E_OK, "AcquireCredentialsHandle() returned %s\n",
getSecError(ret));
pFreeCredentialsHandle(&cred);
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 char test_user[] = "testuser",
workgroup[] = "WORKGROUP",
test_pass[] = "testpass",
sec_pkg_name[] = "NTLM";
SECURITY_STATUS ret;
SEC_WINNT_AUTH_IDENTITY_A id;
PSecPkgInfoA pkg_info = NULL;
@ -1289,7 +1368,7 @@ static void test_cred_multiple_use(void)
ret = pAcquireCredentialsHandleA(NULL, sec_pkg_name, SECPKG_CRED_OUTBOUND,
NULL, &id, NULL, NULL, &cred, &ttl);
ok(ret == SEC_E_OK, "AcquireCredentialsHande() returned %s\n",
ok(ret == SEC_E_OK, "AcquireCredentialsHandle() returned %s\n",
getSecError(ret));
buffer_desc.ulVersion = SECBUFFER_VERSION;
@ -1337,7 +1416,7 @@ static void test_null_auth_data(void)
status = pAcquireCredentialsHandleA(NULL, (SEC_CHAR *)"NTLM", SECPKG_CRED_OUTBOUND,
NULL, NULL, NULL, NULL, &cred, &ttl);
ok(status == SEC_E_OK, "AcquireCredentialsHande() failed %s\n", getSecError(status));
ok(status == SEC_E_OK, "AcquireCredentialsHandle() failed %s\n", getSecError(status));
buffers[0].cbBuffer = info->cbMaxToken;
buffers[0].BufferType = SECBUFFER_TOKEN;
@ -1373,6 +1452,8 @@ START_TEST(ntlm)
pAcquireCredentialsHandleA && pInitializeSecurityContextA &&
pCompleteAuthToken && pQuerySecurityPackageInfoA)
{
testAcquireCredentialsHandleW();
if(!testAcquireCredentialsHandle())
goto cleanup;
testInitializeSecurityContextFlags();

View file

@ -640,7 +640,7 @@ static void test_remote_cert(PCCERT_CONTEXT remote_cert)
cert_cnt++;
}
ok(cert_cnt == 3, "cert_cnt = %u\n", cert_cnt);
ok(cert_cnt == 2 || cert_cnt == 3, "cert_cnt = %u\n", cert_cnt);
ok(incl_remote, "context does not contain cert itself\n");
}
@ -822,7 +822,6 @@ todo_wine
ISC_REQ_CONFIDENTIALITY|ISC_REQ_STREAM,
0, 0, &buffers[1], 0, NULL, &buffers[0], &attrs, NULL);
ok(status == SEC_E_INVALID_TOKEN, "Expected SEC_E_INVALID_TOKEN, got %08x\n", status);
todo_wine
ok(buffers[0].pBuffers[0].cbBuffer == 0, "Output buffer size was not set to 0.\n");
buffers[0].pBuffers[0].cbBuffer = 0;
@ -832,9 +831,15 @@ todo_wine
todo_wine
ok(status == SEC_E_INSUFFICIENT_MEMORY || status == SEC_E_INVALID_TOKEN,
"Expected SEC_E_INSUFFICIENT_MEMORY or SEC_E_INVALID_TOKEN, got %08x\n", status);
ok(buffers[0].pBuffers[0].cbBuffer == 0, "Output buffer size was not set to 0.\n");
status = pInitializeSecurityContextA(&cred_handle, NULL, (SEC_CHAR *)"localhost",
ISC_REQ_CONFIDENTIALITY|ISC_REQ_STREAM,
0, 0, NULL, 0, &context, NULL, &attrs, NULL);
todo_wine
ok(status == SEC_E_INVALID_TOKEN, "Expected SEC_E_INVALID_TOKEN, got %08x\n", status);
buffers[0].pBuffers[0].cbBuffer = buf_size;
status = pInitializeSecurityContextA(&cred_handle, NULL, (SEC_CHAR *)"localhost",
ISC_REQ_CONFIDENTIALITY|ISC_REQ_STREAM,
0, 0, NULL, 0, &context, &buffers[0], &attrs, NULL);
@ -907,6 +912,7 @@ todo_wine
buffers[1].pBuffers[0].cbBuffer = buf_size;
}
ok(buffers[0].pBuffers[0].cbBuffer == 0, "Output buffer size was not set to 0.\n");
ok(status == SEC_E_OK || broken(status == SEC_E_INVALID_TOKEN) /* WinNT */,
"InitializeSecurityContext failed: %08x\n", status);
if(status != SEC_E_OK) {