On Mon, 14 Dec 2020, Dmitry Timoshkov wrote:
Francois Gouget <fgouget(a)codeweavers.com> wrote:
@@ -314,7 +330,7 @@ static void test_registerOIDFunction(void) SetLastError(0xdeadbeef); ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "CryptDllEncodeObject", "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL); - if (!ret && GetLastError() == ERROR_ACCESS_DENIED) + if (!ret && GetLastError() == ERROR_ACCESS_DENIED && !is_process_elevated()) { skip("Need admin rights\n"); return; @@ -393,7 +409,7 @@ static void test_registerDefaultOIDFunction(void) SetLastError(0xdeadbeef); ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 0, bogusDll); - if (!ret && GetLastError() == ERROR_ACCESS_DENIED) + if (!ret && GetLastError() == ERROR_ACCESS_DENIED && !is_process_elevated()) { skip("Need admin rights\n"); return; @@ -499,7 +515,7 @@ static void test_getDefaultOIDFunctionAddress(void) SetLastError(0xdeadbeef); ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 0, bogusDll); - if (!ret && GetLastError() == ERROR_ACCESS_DENIED) + if (!ret && GetLastError() == ERROR_ACCESS_DENIED && !is_process_elevated()) skip("Need admin rights\n"); else ok(ret, "CryptRegisterDefaultOIDFunction failed: %08x\n", GetLastError());
In which cases the changes above are needed? It seems that this only complicates things without a reason and could potentially slow down the tests execution.
These are not strictly needed. Rather the goal is to verify that we only get ERROR_ACCESS_DENIED when missing elevated privileges rather than blindly assuming the access denied error is justified.
@@ -645,7 +661,11 @@ static void test_registerOIDInfo(void) info1.pszOID = test_oid; SetLastError(0xdeadbeef); ret = CryptUnregisterOIDInfo(&info1); - ok(!ret, "should fail\n"); + if (!ret && GetLastError() == ERROR_ACCESS_DENIED && !is_process_elevated()) + { + skip("Need admin rights FIXME\n"); + return; + } ok(!ret, "should fail\n");
This change doesn't look right. Most likely it's not needed here.
It is needed: https://test.winehq.org/data/3acb0b3326c4120ea0c4c6076bd03c9cfe82c744/win10_... -- Francois Gouget <fgouget(a)codeweavers.com>