cryptnet: Add tests for CryptGetObjectUrl.

oldstable
Juan Lang 2007-10-18 10:28:32 -07:00 committed by Alexandre Julliard
parent 016a26ddae
commit 322bcddfa8
10 changed files with 273 additions and 0 deletions

5
.gitignore vendored
View File

@ -72,6 +72,10 @@ dlls/crypt32/tests/*.ok
dlls/crypt32/tests/crypt32_crosstest.exe
dlls/crypt32/tests/testlist.c
dlls/cryptdll/libcryptdll.def
dlls/cryptnet/libcryptnet.def
dlls/cryptnet/tests/*.ok
dlls/cryptnet/tests/cryptnet_crosstest.exe
dlls/cryptnet/tests/testlist.c
dlls/ctl3d.dll16
dlls/ctl3d32/libctl3d32.def
dlls/ctl3dv2.dll16
@ -688,6 +692,7 @@ programs/winetest/comcat_test.exe
programs/winetest/comctl32_test.exe
programs/winetest/comdlg32_test.exe
programs/winetest/crypt32_test.exe
programs/winetest/cryptnet_test.exe
programs/winetest/d3d8_test.exe
programs/winetest/d3d9_test.exe
programs/winetest/d3drm_test.exe

View File

@ -188,6 +188,7 @@ ALL_MAKEFILES = \
dlls/crypt32/tests/Makefile \
dlls/cryptdll/Makefile \
dlls/cryptnet/Makefile \
dlls/cryptnet/tests/Makefile \
dlls/ctl3d32/Makefile \
dlls/d3d10/Makefile \
dlls/d3d8/Makefile \
@ -561,6 +562,7 @@ dlls/crypt32/Makefile: dlls/crypt32/Makefile.in dlls/Makedll.rules
dlls/crypt32/tests/Makefile: dlls/crypt32/tests/Makefile.in dlls/Maketest.rules
dlls/cryptdll/Makefile: dlls/cryptdll/Makefile.in dlls/Makedll.rules
dlls/cryptnet/Makefile: dlls/cryptnet/Makefile.in dlls/Makedll.rules
dlls/cryptnet/tests/Makefile: dlls/cryptnet/tests/Makefile.in dlls/Maketest.rules
dlls/ctl3d32/Makefile: dlls/ctl3d32/Makefile.in dlls/Makedll.rules
dlls/d3d10/Makefile: dlls/d3d10/Makefile.in dlls/Makedll.rules
dlls/d3d8/Makefile: dlls/d3d8/Makefile.in dlls/Makedll.rules

3
configure vendored
View File

@ -20571,6 +20571,8 @@ ac_config_files="$ac_config_files dlls/cryptdll/Makefile"
ac_config_files="$ac_config_files dlls/cryptnet/Makefile"
ac_config_files="$ac_config_files dlls/cryptnet/tests/Makefile"
ac_config_files="$ac_config_files dlls/ctl3d32/Makefile"
ac_config_files="$ac_config_files dlls/d3d10/Makefile"
@ -21823,6 +21825,7 @@ do
"dlls/crypt32/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/crypt32/tests/Makefile" ;;
"dlls/cryptdll/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/cryptdll/Makefile" ;;
"dlls/cryptnet/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/cryptnet/Makefile" ;;
"dlls/cryptnet/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/cryptnet/tests/Makefile" ;;
"dlls/ctl3d32/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/ctl3d32/Makefile" ;;
"dlls/d3d10/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/d3d10/Makefile" ;;
"dlls/d3d8/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/d3d8/Makefile" ;;

View File

@ -1601,6 +1601,7 @@ AC_CONFIG_FILES([dlls/crypt32/Makefile])
AC_CONFIG_FILES([dlls/crypt32/tests/Makefile])
AC_CONFIG_FILES([dlls/cryptdll/Makefile])
AC_CONFIG_FILES([dlls/cryptnet/Makefile])
AC_CONFIG_FILES([dlls/cryptnet/tests/Makefile])
AC_CONFIG_FILES([dlls/ctl3d32/Makefile])
AC_CONFIG_FILES([dlls/d3d10/Makefile])
AC_CONFIG_FILES([dlls/d3d8/Makefile])

View File

@ -252,6 +252,7 @@ TESTSUBDIRS = \
comctl32/tests \
comdlg32/tests \
crypt32/tests \
cryptnet/tests \
d3d8/tests \
d3d9/tests \
d3drm/tests \
@ -501,6 +502,7 @@ IMPORT_LIBS = \
crtdll/libcrtdll.$(IMPLIBEXT) \
crypt32/libcrypt32.$(IMPLIBEXT) \
cryptdll/libcryptdll.$(IMPLIBEXT) \
cryptnet/libcryptnet.$(IMPLIBEXT) \
ctl3d32/libctl3d32.$(IMPLIBEXT) \
d3d8/libd3d8.$(IMPLIBEXT) \
d3d9/libd3d9.$(IMPLIBEXT) \
@ -666,6 +668,9 @@ crypt32/libcrypt32.$(IMPLIBEXT): crypt32/crypt32.spec $(WINEBUILD)
cryptdll/libcryptdll.$(IMPLIBEXT): cryptdll/cryptdll.spec $(WINEBUILD)
@cd cryptdll && $(MAKE) libcryptdll.$(IMPLIBEXT)
cryptnet/libcryptnet.$(IMPLIBEXT): cryptnet/cryptnet.spec $(WINEBUILD)
@cd cryptnet && $(MAKE) libcryptnet.$(IMPLIBEXT)
ctl3d32/libctl3d32.$(IMPLIBEXT): ctl3d32/ctl3d32.spec $(WINEBUILD)
@cd ctl3d32 && $(MAKE) libctl3d32.$(IMPLIBEXT)

View File

@ -3,6 +3,7 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = cryptnet.dll
IMPORTLIB = libcryptnet.$(IMPLIBEXT)
IMPORTS = crypt32 kernel32
C_SRCS = \

View File

@ -0,0 +1,13 @@
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../../..
SRCDIR = @srcdir@
VPATH = @srcdir@
TESTDLL = cryptnet.dll
IMPORTS = cryptnet crypt32 kernel32
CTESTS = \
cryptnet.c
@MAKE_TEST_RULES@
@DEPENDENCIES@ # everything below this line is overwritten by make depend

View File

@ -0,0 +1,239 @@
/*
* Unit test suite for cryptnet.dll
*
* Copyright 2007 Juan Lang
*
* 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 <stdarg.h>
#define NONAMELESSUNION
#include <windef.h>
#include <winbase.h>
#include <winerror.h>
#include <wincrypt.h>
#include "wine/test.h"
static const BYTE bigCert[] = {
0x30,0x78,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,0x14,0x31,0x12,0x30,0x10,
0x06,0x03,0x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,
0x67,0x30,0x22,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,
0x30,0x30,0x30,0x30,0x5a,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,
0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x14,0x31,0x12,0x30,0x10,0x06,0x03,
0x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x30,
0x07,0x30,0x02,0x06,0x00,0x03,0x01,0x00,0xa3,0x16,0x30,0x14,0x30,0x12,0x06,
0x03,0x55,0x1d,0x13,0x01,0x01,0xff,0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,
0x01,0x01};
static const BYTE certWithIssuingDistPoint[] = {
0x30,0x81,0x99,0xa0,0x03,0x02,0x01,0x02,0x02,0x01,0x01,0x30,0x0d,0x06,0x09,
0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x30,0x14,0x31,0x12,
0x30,0x10,0x06,0x03,0x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e,0x20,0x4c,
0x61,0x6e,0x67,0x30,0x22,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,
0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,
0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x14,0x31,0x12,0x30,0x10,
0x06,0x03,0x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,
0x67,0x30,0x07,0x30,0x02,0x06,0x00,0x03,0x01,0x00,0xa3,0x27,0x30,0x25,0x30,
0x23,0x06,0x03,0x55,0x1d,0x1c,0x01,0x01,0xff,0x04,0x19,0x30,0x17,0xa0,0x15,
0xa0,0x13,0x86,0x11,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x69,0x6e,0x65,
0x68,0x71,0x2e,0x6f,0x72,0x67, };
static const BYTE certWithCRLDistPoint[] = {
0x30,0x81,0x9b,0xa0,0x03,0x02,0x01,0x02,0x02,0x01,0x01,0x30,0x0d,0x06,0x09,
0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x30,0x14,0x31,0x12,
0x30,0x10,0x06,0x03,0x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e,0x20,0x4c,
0x61,0x6e,0x67,0x30,0x22,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,
0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,
0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x14,0x31,0x12,0x30,0x10,
0x06,0x03,0x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,
0x67,0x30,0x07,0x30,0x02,0x06,0x00,0x03,0x01,0x00,0xa3,0x29,0x30,0x27,0x30,
0x25,0x06,0x03,0x55,0x1d,0x1f,0x01,0x01,0xff,0x04,0x1b,0x30,0x19,0x30,0x17,
0xa0,0x15,0xa0,0x13,0x86,0x11,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x69,
0x6e,0x65,0x68,0x71,0x2e,0x6f,0x72,0x67, };
static void compareUrlArray(const CRYPT_URL_ARRAY *expected,
const CRYPT_URL_ARRAY *got)
{
ok(expected->cUrl == got->cUrl, "Expected %d URLs, got %d\n",
expected->cUrl, got->cUrl);
if (expected->cUrl == got->cUrl)
{
DWORD i;
for (i = 0; i < got->cUrl; i++)
ok(!lstrcmpiW(expected->rgwszUrl[i], got->rgwszUrl[i]),
"%d: unexpected URL\n", i);
}
}
static WCHAR url[] =
{ 'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g',0 };
static void test_getObjectUrl(void)
{
BOOL ret;
DWORD urlArraySize = 0, infoSize = 0;
PCCERT_CONTEXT cert;
SetLastError(0xdeadbeef);
ret = CryptGetObjectUrl(NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL);
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
/* Crash
ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_ISSUER, NULL, 0, NULL, NULL,
NULL, NULL, NULL);
ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_ISSUER, NULL, 0, NULL, NULL,
NULL, &infoSize, NULL);
ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_ISSUER, NULL, 0, NULL,
&urlArraySize, NULL, &infoSize, NULL);
*/
/* A cert with no CRL dist point extension fails.. */
cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
sizeof(bigCert));
SetLastError(0xdeadbeef);
ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_ISSUER, (void *)cert, 0, NULL,
NULL, NULL, NULL, NULL);
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
CertFreeCertificateContext(cert);
cert = CertCreateCertificateContext(X509_ASN_ENCODING,
certWithIssuingDistPoint, sizeof(certWithIssuingDistPoint));
if (cert)
{
/* This cert has no AIA extension, so expect this to fail */
SetLastError(0xdeadbeef);
ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_ISSUER, (void *)cert, 0,
NULL, NULL, NULL, NULL, NULL);
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
SetLastError(0xdeadbeef);
ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_ISSUER, (void *)cert,
CRYPT_GET_URL_FROM_PROPERTY, NULL, NULL, NULL, NULL, NULL);
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
SetLastError(0xdeadbeef);
ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_ISSUER, (void *)cert,
CRYPT_GET_URL_FROM_EXTENSION, NULL, NULL, NULL, NULL, NULL);
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
/* It does have an issuing dist point extension, but that's not what
* this is looking for (it wants a CRL dist points extension)
*/
SetLastError(0xdeadbeef);
ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_CRL_DIST_POINT,
(void *)cert, 0, NULL, NULL, NULL, NULL, NULL);
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
SetLastError(0xdeadbeef);
ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_CRL_DIST_POINT,
(void *)cert, CRYPT_GET_URL_FROM_PROPERTY, NULL, NULL, NULL, NULL,
NULL);
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
SetLastError(0xdeadbeef);
ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_CRL_DIST_POINT,
(void *)cert, CRYPT_GET_URL_FROM_EXTENSION, NULL, NULL, NULL, NULL,
NULL);
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
}
cert = CertCreateCertificateContext(X509_ASN_ENCODING,
certWithCRLDistPoint, sizeof(certWithCRLDistPoint));
if (cert)
{
PCRYPT_URL_ARRAY urlArray;
/* This cert has no AIA extension, so expect this to fail */
SetLastError(0xdeadbeef);
ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_ISSUER, (void *)cert, 0,
NULL, NULL, NULL, NULL, NULL);
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
SetLastError(0xdeadbeef);
ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_ISSUER, (void *)cert,
CRYPT_GET_URL_FROM_PROPERTY, NULL, NULL, NULL, NULL, NULL);
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
SetLastError(0xdeadbeef);
ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_ISSUER, (void *)cert,
CRYPT_GET_URL_FROM_EXTENSION, NULL, NULL, NULL, NULL, NULL);
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
/* It does have a CRL dist points extension */
SetLastError(0xdeadbeef);
ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_CRL_DIST_POINT,
(void *)cert, 0, NULL, NULL, NULL, NULL, NULL);
todo_wine
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
SetLastError(0xdeadbeef);
ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_CRL_DIST_POINT,
(void *)cert, 0, NULL, NULL, NULL, &infoSize, NULL);
todo_wine
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
/* Can get it without specifying the location: */
ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_CRL_DIST_POINT,
(void *)cert, 0, NULL, &urlArraySize, NULL, NULL, NULL);
ok(ret, "CryptGetObjectUrl failed: %08x\n", GetLastError());
urlArray = HeapAlloc(GetProcessHeap(), 0, urlArraySize);
if (urlArray)
{
ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_CRL_DIST_POINT,
(void *)cert, 0, urlArray, &urlArraySize, NULL, NULL, NULL);
ok(ret, "CryptGetObjectUrl failed: %08x\n", GetLastError());
if (ret)
{
LPWSTR pUrl = url;
CRYPT_URL_ARRAY expectedUrl = { 1, &pUrl };
compareUrlArray(&expectedUrl, urlArray);
}
HeapFree(GetProcessHeap(), 0, urlArray);
}
/* or by specifying it's an extension: */
ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_CRL_DIST_POINT,
(void *)cert, CRYPT_GET_URL_FROM_EXTENSION, NULL, &urlArraySize, NULL,
NULL, NULL);
ok(ret, "CryptGetObjectUrl failed: %08x\n", GetLastError());
urlArray = HeapAlloc(GetProcessHeap(), 0, urlArraySize);
if (urlArray)
{
ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_CRL_DIST_POINT,
(void *)cert, CRYPT_GET_URL_FROM_EXTENSION, urlArray,
&urlArraySize, NULL, NULL, NULL);
ok(ret, "CryptGetObjectUrl failed: %08x\n", GetLastError());
if (ret)
{
LPWSTR pUrl = url;
CRYPT_URL_ARRAY expectedUrl = { 1, &pUrl };
compareUrlArray(&expectedUrl, urlArray);
}
HeapFree(GetProcessHeap(), 0, urlArray);
}
/* but it isn't contained in a property: */
SetLastError(0xdeadbeef);
ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_CRL_DIST_POINT,
(void *)cert, CRYPT_GET_URL_FROM_PROPERTY, NULL, &urlArraySize, NULL,
NULL, NULL);
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
CertFreeCertificateContext(cert);
}
}
START_TEST(cryptnet)
{
test_getObjectUrl();
}

View File

@ -28,6 +28,7 @@ TESTBINS = \
comctl32_test.exe \
comdlg32_test.exe \
crypt32_test.exe \
cryptnet_test.exe \
d3d8_test.exe \
d3d9_test.exe \
d3drm_test.exe \
@ -106,6 +107,8 @@ comdlg32_test.exe: $(DLLDIR)/comdlg32/tests/comdlg32_test.exe$(DLLEXT)
cp $(DLLDIR)/comdlg32/tests/comdlg32_test.exe$(DLLEXT) $@ && $(STRIP) $@
crypt32_test.exe: $(DLLDIR)/crypt32/tests/crypt32_test.exe$(DLLEXT)
cp $(DLLDIR)/crypt32/tests/crypt32_test.exe$(DLLEXT) $@ && $(STRIP) $@
cryptnet_test.exe: $(DLLDIR)/cryptnet/tests/cryptnet_test.exe$(DLLEXT)
cp $(DLLDIR)/cryptnet/tests/cryptnet_test.exe$(DLLEXT) $@ && $(STRIP) $@
d3d8_test.exe: $(DLLDIR)/d3d8/tests/d3d8_test.exe$(DLLEXT)
cp $(DLLDIR)/d3d8/tests/d3d8_test.exe$(DLLEXT) $@ && $(STRIP) $@
d3d9_test.exe: $(DLLDIR)/d3d9/tests/d3d9_test.exe$(DLLEXT)

View File

@ -86,6 +86,7 @@ comcat_test.exe TESTRES "comcat_test.exe"
comctl32_test.exe TESTRES "comctl32_test.exe"
comdlg32_test.exe TESTRES "comdlg32_test.exe"
crypt32_test.exe TESTRES "crypt32_test.exe"
cryptnet_test.exe TESTRES "cryptnet_test.exe"
d3d8_test.exe TESTRES "d3d8_test.exe"
d3d9_test.exe TESTRES "d3d9_test.exe"
d3drm_test.exe TESTRES "d3drm_test.exe"