secur32/tests: Add a test for NTLM behaviour with SECPKG_ATTR_NEGOTIATION_INFO query.

To show that QueryContextAttributes(SECPKG_ATTR_NEGOTIATION_INFO)
allocates flat memory block for the PackageInfo structure.

Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Dmitry Timoshkov 2017-12-14 17:18:04 +08:00 committed by Alexandre Julliard
parent 8d4d7c7251
commit 09f6e200d9
1 changed files with 60 additions and 0 deletions

View File

@ -36,6 +36,29 @@
#include "wine/test.h" #include "wine/test.h"
#define NEGOTIATE_BASE_CAPS ( \
SECPKG_FLAG_INTEGRITY | \
SECPKG_FLAG_PRIVACY | \
SECPKG_FLAG_CONNECTION | \
SECPKG_FLAG_MULTI_REQUIRED | \
SECPKG_FLAG_EXTENDED_ERROR | \
SECPKG_FLAG_IMPERSONATION | \
SECPKG_FLAG_ACCEPT_WIN32_NAME | \
SECPKG_FLAG_NEGOTIABLE | \
SECPKG_FLAG_GSS_COMPATIBLE | \
SECPKG_FLAG_LOGON )
#define NTLM_BASE_CAPS ( \
SECPKG_FLAG_INTEGRITY | \
SECPKG_FLAG_PRIVACY | \
SECPKG_FLAG_TOKEN_ONLY | \
SECPKG_FLAG_CONNECTION | \
SECPKG_FLAG_MULTI_REQUIRED | \
SECPKG_FLAG_IMPERSONATION | \
SECPKG_FLAG_ACCEPT_WIN32_NAME | \
SECPKG_FLAG_NEGOTIABLE | \
SECPKG_FLAG_LOGON )
static HMODULE secdll; static HMODULE secdll;
static PSecurityFunctionTableA (SEC_ENTRY * pInitSecurityInterfaceA)(void); static PSecurityFunctionTableA (SEC_ENTRY * pInitSecurityInterfaceA)(void);
static SECURITY_STATUS (SEC_ENTRY * pFreeContextBuffer)(PVOID pv); static SECURITY_STATUS (SEC_ENTRY * pFreeContextBuffer)(PVOID pv);
@ -797,6 +820,8 @@ static void testAuth(ULONG data_rep, BOOL fake)
SspiData client = {{0}}, server = {{0}}; SspiData client = {{0}}, server = {{0}};
SEC_WINNT_AUTH_IDENTITY_A id; SEC_WINNT_AUTH_IDENTITY_A id;
SecPkgContext_Sizes ctxt_sizes; SecPkgContext_Sizes ctxt_sizes;
SecPkgContext_NegotiationInfoA info;
SecPkgInfoA *pi;
if(pQuerySecurityPackageInfoA( sec_pkg_name, &pkg_info)!= SEC_E_OK) if(pQuerySecurityPackageInfoA( sec_pkg_name, &pkg_info)!= SEC_E_OK)
{ {
@ -889,6 +914,41 @@ static void testAuth(ULONG data_rep, BOOL fake)
"cbBlockSize should be 0 but is %u\n", "cbBlockSize should be 0 but is %u\n",
ctxt_sizes.cbBlockSize); ctxt_sizes.cbBlockSize);
memset(&info, 0, sizeof(info));
sec_status = QueryContextAttributesA(&client.ctxt, SECPKG_ATTR_NEGOTIATION_INFO, &info);
todo_wine
ok(sec_status == SEC_E_OK, "QueryContextAttributesA returned %08x\n", sec_status);
pi = info.PackageInfo;
ok(info.NegotiationState == SECPKG_NEGOTIATION_COMPLETE, "got %u\n", info.NegotiationState);
todo_wine
ok(pi != NULL, "expected non-NULL PackageInfo\n");
if (pi)
{
UINT expected, got;
char *eob;
ok(pi->fCapabilities == NTLM_BASE_CAPS ||
pi->fCapabilities == (NTLM_BASE_CAPS|SECPKG_FLAG_READONLY_WITH_CHECKSUM) ||
pi->fCapabilities == (NTLM_BASE_CAPS|SECPKG_FLAG_RESTRICTED_TOKENS) ||
pi->fCapabilities == (NTLM_BASE_CAPS|SECPKG_FLAG_RESTRICTED_TOKENS|
SECPKG_FLAG_APPCONTAINER_CHECKS),
"got %08x\n", pi->fCapabilities);
ok(pi->wVersion == 1, "got %u\n", pi->wVersion);
ok(pi->wRPCID == RPC_C_AUTHN_WINNT, "got %u\n", pi->wRPCID);
ok(!lstrcmpA( pi->Name, "NTLM" ), "got %s\n", pi->Name);
expected = sizeof(*pi) + lstrlenA(pi->Name) + 1 + lstrlenA(pi->Comment) + 1;
got = HeapSize(GetProcessHeap(), 0, pi);
ok(got == expected, "got %u, expected %u\n", got, expected);
eob = (char *)pi + expected;
ok(pi->Name + lstrlenA(pi->Name) < eob, "Name doesn't fit into allocated block\n");
ok(pi->Comment + lstrlenA(pi->Comment) < eob, "Comment doesn't fit into allocated block\n");
sec_status = FreeContextBuffer(pi);
ok(sec_status == SEC_E_OK, "FreeContextBuffer error %#x\n", sec_status);
}
tAuthend: tAuthend:
cleanupBuffers(&client); cleanupBuffers(&client);
cleanupBuffers(&server); cleanupBuffers(&server);