crypt32: Add basic tests for CryptGetDefaultOIDFunctionAddress.

This commit is contained in:
Juan Lang 2007-10-17 09:31:18 -07:00 committed by Alexandre Julliard
parent 6b390b4009
commit ad514dbc20
1 changed files with 42 additions and 0 deletions

View File

@ -414,6 +414,47 @@ static void test_registerDefaultOIDFunction(void)
"Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
}
static void test_getDefaultOIDFunctionAddress(void)
{
BOOL ret;
HCRYPTOIDFUNCSET set;
void *funcAddr;
HCRYPTOIDFUNCADDR hFuncAddr;
/* Crash
ret = CryptGetDefaultOIDFunctionAddress(0, 0, NULL, 0, NULL, NULL);
ret = CryptGetDefaultOIDFunctionAddress(0, 0, NULL, 0, &funcAddr, NULL);
ret = CryptGetDefaultOIDFunctionAddress(0, 0, NULL, 0, NULL, &hFuncAddr);
ret = CryptGetDefaultOIDFunctionAddress(0, 0, NULL, 0, &funcAddr,
&hFuncAddr);
*/
set = CryptInitOIDFunctionSet("CertDllOpenStoreProv", 0);
ok(set != 0, "CryptInitOIDFunctionSet failed: %d\n", GetLastError());
/* This crashes if hFuncAddr is not 0 to begin with */
hFuncAddr = 0;
ret = CryptGetDefaultOIDFunctionAddress(set, 0, NULL, 0, &funcAddr,
&hFuncAddr);
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
/* This fails with the normal encoding too, so built-in functions aren't
* returned.
*/
ret = CryptGetDefaultOIDFunctionAddress(set, X509_ASN_ENCODING, NULL, 0,
&funcAddr, &hFuncAddr);
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
/* Even with a registered dll, this fails (since the dll doesn't exist) */
ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 0,
bogusDll);
ok(ret, "CryptRegisterDefaultOIDFunction failed: %08x\n", GetLastError());
ret = CryptGetDefaultOIDFunctionAddress(set, 0, NULL, 0, &funcAddr,
&hFuncAddr);
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
CryptUnregisterDefaultOIDFunction(0, "CertDllOpenStoreProv", bogusDll);
}
static BOOL WINAPI countOidInfo(PCCRYPT_OID_INFO pInfo, void *pvArg)
{
(*(DWORD *)pvArg)++;
@ -499,4 +540,5 @@ START_TEST(oid)
test_installOIDFunctionAddress();
test_registerOIDFunction();
test_registerDefaultOIDFunction();
test_getDefaultOIDFunctionAddress();
}