schannel: Tests for SpLsaModeInitialize, SpUserModeInitialize and GetInfo.
This commit is contained in:
parent
cdb91ab7ee
commit
735df24617
|
@ -455,6 +455,9 @@ dlls/rsaenh/tests/rsaenh_crosstest.exe
|
|||
dlls/rsaenh/tests/testlist.c
|
||||
dlls/rsaenh/version.res
|
||||
dlls/sane.ds/rsrc.res
|
||||
dlls/schannel/tests/*.ok
|
||||
dlls/schannel/tests/schannel_crosstest.exe
|
||||
dlls/schannel/tests/testlist.c
|
||||
dlls/secur32/libsecur32.def
|
||||
dlls/secur32/tests/*.ok
|
||||
dlls/secur32/tests/secur32_crosstest.exe
|
||||
|
@ -860,6 +863,7 @@ programs/winetest/riched20_test.exe
|
|||
programs/winetest/rpcrt4_test.exe
|
||||
programs/winetest/rsabase_test.exe
|
||||
programs/winetest/rsaenh_test.exe
|
||||
programs/winetest/schannel_test.exe
|
||||
programs/winetest/secur32_test.exe
|
||||
programs/winetest/serialui_test.exe
|
||||
programs/winetest/setupapi_test.exe
|
||||
|
|
|
@ -344,6 +344,7 @@ ALL_MAKEFILES = \
|
|||
dlls/rsaenh/tests/Makefile \
|
||||
dlls/sane.ds/Makefile \
|
||||
dlls/schannel/Makefile \
|
||||
dlls/schannel/tests/Makefile \
|
||||
dlls/secur32/Makefile \
|
||||
dlls/secur32/tests/Makefile \
|
||||
dlls/security/Makefile \
|
||||
|
@ -688,6 +689,7 @@ dlls/rsaenh/Makefile: dlls/rsaenh/Makefile.in dlls/Makedll.rules
|
|||
dlls/rsaenh/tests/Makefile: dlls/rsaenh/tests/Makefile.in dlls/Maketest.rules
|
||||
dlls/sane.ds/Makefile: dlls/sane.ds/Makefile.in dlls/Makedll.rules
|
||||
dlls/schannel/Makefile: dlls/schannel/Makefile.in dlls/Makedll.rules
|
||||
dlls/schannel/tests/Makefile: dlls/schannel/tests/Makefile.in dlls/Maketest.rules
|
||||
dlls/secur32/Makefile: dlls/secur32/Makefile.in dlls/Makedll.rules
|
||||
dlls/secur32/tests/Makefile: dlls/secur32/tests/Makefile.in dlls/Maketest.rules
|
||||
dlls/security/Makefile: dlls/security/Makefile.in dlls/Makedll.rules
|
||||
|
|
|
@ -20693,6 +20693,8 @@ ac_config_files="$ac_config_files dlls/sane.ds/Makefile"
|
|||
|
||||
ac_config_files="$ac_config_files dlls/schannel/Makefile"
|
||||
|
||||
ac_config_files="$ac_config_files dlls/schannel/tests/Makefile"
|
||||
|
||||
ac_config_files="$ac_config_files dlls/secur32/Makefile"
|
||||
|
||||
ac_config_files="$ac_config_files dlls/secur32/tests/Makefile"
|
||||
|
@ -21731,6 +21733,7 @@ do
|
|||
"dlls/rsaenh/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/rsaenh/tests/Makefile" ;;
|
||||
"dlls/sane.ds/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/sane.ds/Makefile" ;;
|
||||
"dlls/schannel/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/schannel/Makefile" ;;
|
||||
"dlls/schannel/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/schannel/tests/Makefile" ;;
|
||||
"dlls/secur32/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/secur32/Makefile" ;;
|
||||
"dlls/secur32/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/secur32/tests/Makefile" ;;
|
||||
"dlls/security/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/security/Makefile" ;;
|
||||
|
|
|
@ -1671,6 +1671,7 @@ AC_CONFIG_FILES([dlls/rsaenh/Makefile])
|
|||
AC_CONFIG_FILES([dlls/rsaenh/tests/Makefile])
|
||||
AC_CONFIG_FILES([dlls/sane.ds/Makefile])
|
||||
AC_CONFIG_FILES([dlls/schannel/Makefile])
|
||||
AC_CONFIG_FILES([dlls/schannel/tests/Makefile])
|
||||
AC_CONFIG_FILES([dlls/secur32/Makefile])
|
||||
AC_CONFIG_FILES([dlls/secur32/tests/Makefile])
|
||||
AC_CONFIG_FILES([dlls/security/Makefile])
|
||||
|
|
|
@ -269,6 +269,7 @@ TESTSUBDIRS = \
|
|||
rpcrt4/tests \
|
||||
rsabase/tests \
|
||||
rsaenh/tests \
|
||||
schannel/tests \
|
||||
secur32/tests \
|
||||
serialui/tests \
|
||||
setupapi/tests \
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
TOPSRCDIR = @top_srcdir@
|
||||
TOPOBJDIR = ../../..
|
||||
SRCDIR = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
TESTDLL = schannel.dll
|
||||
IMPORTS = crypt32 advapi32 kernel32
|
||||
|
||||
CTESTS = \
|
||||
main.c
|
||||
|
||||
@MAKE_TEST_RULES@
|
||||
|
||||
@DEPENDENCIES@ # everything below this line is overwritten by make depend
|
|
@ -0,0 +1,180 @@
|
|||
/*
|
||||
* Schannel tests
|
||||
*
|
||||
* Copyright 2006 Yuval Fledel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "ntstatus.h"
|
||||
#define WIN32_NO_STATUS
|
||||
#include <windef.h>
|
||||
#include <winbase.h>
|
||||
#define SECURITY_WIN32
|
||||
#include <security.h>
|
||||
#include <schannel.h>
|
||||
#include <ntsecapi.h>
|
||||
#include <ntsecpkg.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
static NTSTATUS (NTAPI *pSpLsaModeInitialize)(ULONG, PULONG,
|
||||
PSECPKG_FUNCTION_TABLE*, PULONG);
|
||||
static NTSTATUS (NTAPI *pSpUserModeInitialize)(ULONG, PULONG,
|
||||
PSECPKG_USER_FUNCTION_TABLE*, PULONG);
|
||||
|
||||
static void testInitialize(void)
|
||||
{
|
||||
PSECPKG_USER_FUNCTION_TABLE pUserTables, pUserTables2;
|
||||
PSECPKG_FUNCTION_TABLE pTables, pTables2;
|
||||
ULONG cTables = 0, cUserTables = 0, Version = 0;
|
||||
NTSTATUS status;
|
||||
|
||||
/* Passing NULL into one of the parameters of SpLsaModeInitialize or
|
||||
SpUserModeInitialize causes a crash. */
|
||||
|
||||
/* SpLsaModeInitialize does not care about the LSA version. */
|
||||
status = pSpLsaModeInitialize(0, &Version, &pTables2, &cTables);
|
||||
ok(status == STATUS_SUCCESS, "status: 0x%x\n", status);
|
||||
ok(cTables == 2, "cTables: %d\n", cTables);
|
||||
ok(pTables2 != NULL,"pTables: %p\n", pTables2);
|
||||
|
||||
/* We can call it as many times we want. */
|
||||
status = pSpLsaModeInitialize(0x10000, &Version, &pTables, &cTables);
|
||||
ok(status == STATUS_SUCCESS, "status: 0x%x\n", status);
|
||||
ok(cTables == 2, "cTables: %d\n", cTables);
|
||||
ok(pTables != NULL, "pTables: %p\n", pTables);
|
||||
/* It will always return the same pointer. */
|
||||
ok(pTables == pTables2, "pTables: %p, pTables2: %p\n", pTables, pTables2);
|
||||
|
||||
status = pSpLsaModeInitialize(0x23456, &Version, &pTables, &cTables);
|
||||
ok(status == STATUS_SUCCESS, "status: 0x%x\n", status);
|
||||
ok(cTables == 2, "cTables: %d\n", cTables);
|
||||
ok(pTables != NULL, "pTables: %p\n", pTables);
|
||||
ok(pTables == pTables2, "pTables: %p, pTables2: %p\n", pTables, pTables2);
|
||||
|
||||
/* Bad versions to SpUserModeInitialize. Parameters unchanged */
|
||||
Version = 0xdead;
|
||||
cUserTables = 0xdead;
|
||||
pUserTables = NULL;
|
||||
status = pSpUserModeInitialize(0, &Version, &pUserTables, &cUserTables);
|
||||
ok(status == STATUS_INVALID_PARAMETER, "status: 0x%x\n", status);
|
||||
ok(Version == 0xdead, "Version: 0x%x\n", Version);
|
||||
ok(cUserTables == 0xdead, "cTables: %d\n", cUserTables);
|
||||
ok(pUserTables == NULL, "pUserTables: %p\n", pUserTables);
|
||||
|
||||
status = pSpUserModeInitialize(0x20000, &Version, &pUserTables,
|
||||
&cUserTables);
|
||||
ok(status == STATUS_INVALID_PARAMETER, "status: 0x%x\n", status);
|
||||
ok(Version == 0xdead, "Version: 0x%x\n", Version);
|
||||
ok(cUserTables == 0xdead, "cTables: %d\n", cUserTables);
|
||||
ok(pUserTables == NULL, "pUserTables: %p\n", pUserTables);
|
||||
|
||||
/* Good version to SpUserModeInitialize */
|
||||
status = pSpUserModeInitialize(SECPKG_INTERFACE_VERSION, &Version,
|
||||
&pUserTables, &cUserTables);
|
||||
ok(status == STATUS_SUCCESS, "status: 0x%x\n", status);
|
||||
ok(Version == SECPKG_INTERFACE_VERSION, "Version: 0x%x\n", Version);
|
||||
ok(cUserTables == 2, "cUserTables: %d\n", cUserTables);
|
||||
ok(pUserTables != NULL, "pUserTables: %p\n", pUserTables);
|
||||
|
||||
/* Initializing user again */
|
||||
status = pSpUserModeInitialize(SECPKG_INTERFACE_VERSION, &Version,
|
||||
&pUserTables2, &cTables);
|
||||
ok(status == STATUS_SUCCESS, "status: 0x%x\n", status);
|
||||
ok(pUserTables == pUserTables2, "pUserTables: %p, pUserTables2: %p\n",
|
||||
pUserTables, pUserTables2);
|
||||
}
|
||||
|
||||
/* A helper function to find the dispatch table of the next package.
|
||||
Needed because SECPKG_FUNCTION_TABLE's size depend on the version */
|
||||
static PSECPKG_FUNCTION_TABLE getNextSecPkgTable(PSECPKG_FUNCTION_TABLE pTable,
|
||||
ULONG Version)
|
||||
{
|
||||
size_t size;
|
||||
|
||||
if (Version == SECPKG_INTERFACE_VERSION)
|
||||
size = SECPKG_FUNCTION_TABLE_SIZE_1;
|
||||
else if (Version == SECPKG_INTERFACE_VERSION_2)
|
||||
size = SECPKG_FUNCTION_TABLE_SIZE_2;
|
||||
else if (Version == SECPKG_INTERFACE_VERSION_3)
|
||||
size = SECPKG_FUNCTION_TABLE_SIZE_3;
|
||||
else {
|
||||
ok(FALSE, "Unknown package version 0x%x\n", Version);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (PSECPKG_FUNCTION_TABLE)((PBYTE)pTable + size);
|
||||
}
|
||||
|
||||
static void testGetInfo(void)
|
||||
{
|
||||
PSECPKG_FUNCTION_TABLE pTables;
|
||||
SecPkgInfoW PackageInfo;
|
||||
ULONG cTables, Version;
|
||||
NTSTATUS status;
|
||||
|
||||
/* Get the dispatch table */
|
||||
status = pSpLsaModeInitialize(0, &Version, &pTables, &cTables);
|
||||
ok(status == STATUS_SUCCESS, "status: 0x%x\n", status);
|
||||
|
||||
/* Passing NULL into ->GetInfo causes a crash. */
|
||||
|
||||
/* First package: Unified */
|
||||
status = pTables->GetInfo(&PackageInfo);
|
||||
ok(status == STATUS_SUCCESS, "status: 0x%x\n", status);
|
||||
ok(PackageInfo.fCapabilities == 0x107b3, "fCapabilities: 0x%lx\n",
|
||||
PackageInfo.fCapabilities);
|
||||
ok(PackageInfo.wVersion == 1, "wVersion: %d\n", PackageInfo.wVersion);
|
||||
ok(PackageInfo.wRPCID == 14, "wRPCID: %d\n", PackageInfo.wRPCID);
|
||||
ok(PackageInfo.cbMaxToken == 0x4000, "cbMaxToken: 0x%lx\n",
|
||||
PackageInfo.cbMaxToken);
|
||||
|
||||
/* Second package: SChannel */
|
||||
pTables = getNextSecPkgTable(pTables, Version);
|
||||
if (!pTables)
|
||||
return;
|
||||
status = pTables->GetInfo(&PackageInfo);
|
||||
ok(status == STATUS_SUCCESS, "status: 0x%x\n", status);
|
||||
ok(PackageInfo.fCapabilities == 0x107b3, "fCapabilities: 0x%lx\n",
|
||||
PackageInfo.fCapabilities);
|
||||
ok(PackageInfo.wVersion == 1, "wVersion: %d\n", PackageInfo.wVersion);
|
||||
ok(PackageInfo.wRPCID == 14, "wRPCID: %d\n", PackageInfo.wRPCID);
|
||||
ok(PackageInfo.cbMaxToken == 0x4000, "cbMaxToken: 0x%lx\n",
|
||||
PackageInfo.cbMaxToken);
|
||||
}
|
||||
|
||||
START_TEST(main)
|
||||
{
|
||||
HMODULE hMod = LoadLibraryA("schannel.dll");
|
||||
if (!hMod) {
|
||||
skip("schannel.dll not found.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
pSpLsaModeInitialize = GetProcAddress(hMod, "SpLsaModeInitialize");
|
||||
pSpUserModeInitialize = GetProcAddress(hMod, "SpUserModeInitialize");
|
||||
|
||||
if (pSpLsaModeInitialize && pSpUserModeInitialize)
|
||||
{
|
||||
testInitialize();
|
||||
testGetInfo();
|
||||
}
|
||||
else skip( "schannel functions not found\n" );
|
||||
|
||||
FreeLibrary(hMod);
|
||||
}
|
|
@ -68,6 +68,7 @@ TESTBINS = \
|
|||
rpcrt4_test.exe \
|
||||
rsabase_test.exe \
|
||||
rsaenh_test.exe \
|
||||
schannel_test.exe \
|
||||
secur32_test.exe \
|
||||
serialui_test.exe \
|
||||
setupapi_test.exe \
|
||||
|
@ -176,6 +177,8 @@ rsabase_test.exe: $(DLLDIR)/rsabase/tests/rsabase_test.exe$(DLLEXT)
|
|||
cp $(DLLDIR)/rsabase/tests/rsabase_test.exe$(DLLEXT) $@ && $(STRIP) $@
|
||||
rsaenh_test.exe: $(DLLDIR)/rsaenh/tests/rsaenh_test.exe$(DLLEXT)
|
||||
cp $(DLLDIR)/rsaenh/tests/rsaenh_test.exe$(DLLEXT) $@ && $(STRIP) $@
|
||||
schannel_test.exe: $(DLLDIR)/schannel/tests/schannel_test.exe$(DLLEXT)
|
||||
cp $(DLLDIR)/schannel/tests/schannel_test.exe$(DLLEXT) $@ && $(STRIP) $@
|
||||
secur32_test.exe: $(DLLDIR)/secur32/tests/secur32_test.exe$(DLLEXT)
|
||||
cp $(DLLDIR)/secur32/tests/secur32_test.exe$(DLLEXT) $@ && $(STRIP) $@
|
||||
serialui_test.exe: $(DLLDIR)/serialui/tests/serialui_test.exe$(DLLEXT)
|
||||
|
|
|
@ -191,6 +191,7 @@ riched20_test.exe TESTRES "riched20_test.exe"
|
|||
rpcrt4_test.exe TESTRES "rpcrt4_test.exe"
|
||||
rsabase_test.exe TESTRES "rsabase_test.exe"
|
||||
rsaenh_test.exe TESTRES "rsaenh_test.exe"
|
||||
schannel_test.exe TESTRES "schannel_test.exe"
|
||||
secur32_test.exe TESTRES "secur32_test.exe"
|
||||
serialui_test.exe TESTRES "serialui_test.exe"
|
||||
setupapi_test.exe TESTRES "setupapi_test.exe"
|
||||
|
|
Loading…
Reference in New Issue