Commit 0b994d0a authored by Paul Vriens's avatar Paul Vriens Committed by Alexandre Julliard

advapi32/tests: Restore default cryptographic provider after the tests.

parent e6d540d5
......@@ -856,6 +856,8 @@ static void test_set_provider_ex(void)
{
DWORD result;
DWORD notNull = 5;
LPSTR curProvName = NULL;
DWORD curlen;
/* results */
LPSTR pszProvName = NULL;
......@@ -867,6 +869,13 @@ static void test_set_provider_ex(void)
return;
}
/* store the current one */
pCryptGetDefaultProviderA(PROV_RSA_FULL, NULL, CRYPT_MACHINE_DEFAULT, NULL, &curlen);
if (!(curProvName = LocalAlloc(LMEM_ZEROINIT, curlen)))
return;
result = pCryptGetDefaultProviderA(PROV_RSA_FULL, NULL, CRYPT_MACHINE_DEFAULT, curProvName, &curlen);
ok(result, "%d\n", GetLastError());
/* check pdwReserved for NULL */
result = pCryptSetProviderExA(MS_DEF_PROV, PROV_RSA_FULL, &notNull, CRYPT_MACHINE_DEFAULT);
ok(!result && GetLastError()==ERROR_INVALID_PARAMETER, "expected %i, got %d\n",
......@@ -880,6 +889,7 @@ static void test_set_provider_ex(void)
ok( GetLastError() == ERROR_ACCESS_DENIED || broken(GetLastError() == ERROR_INVALID_PARAMETER),
"wrong error %u\n", GetLastError() );
skip("Not enough rights to remove the default provider\n");
LocalFree(curProvName);
return;
}
......@@ -889,13 +899,19 @@ static void test_set_provider_ex(void)
/* call CryptGetDefaultProvider to see if they match */
result = pCryptGetDefaultProviderA(PROV_RSA_FULL, NULL, CRYPT_MACHINE_DEFAULT, NULL, &cbProvName);
if (!(pszProvName = LocalAlloc(LMEM_ZEROINIT, cbProvName)))
return;
goto reset;
result = pCryptGetDefaultProviderA(PROV_RSA_FULL, NULL, CRYPT_MACHINE_DEFAULT, pszProvName, &cbProvName);
ok(result && !strcmp(MS_DEF_PROV, pszProvName), "expected %s, got %s\n", MS_DEF_PROV, pszProvName);
ok(result && cbProvName==(strlen(MS_DEF_PROV) + 1), "expected %i, got %d\n", (lstrlenA(MS_DEF_PROV) + 1), cbProvName);
LocalFree(pszProvName);
reset:
/* Set the provider back to it's original */
result = pCryptSetProviderExA(curProvName, PROV_RSA_FULL, NULL, CRYPT_MACHINE_DEFAULT);
ok(result, "%d\n", GetLastError());
LocalFree(curProvName);
}
static void test_machine_guid(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment