Commit 10a32a0b authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

msi/tests: Skip tests when the current user has insufficient rights.

parent dad50e3a
......@@ -733,6 +733,12 @@ static void test_dispatch(void)
V_VT(&vararg[0]) = VT_BSTR;
V_BSTR(&vararg[0]) = SysAllocString(path);
hr = IDispatch_Invoke(pInstaller, dispid, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
if (hr == DISP_E_EXCEPTION)
{
skip("OpenPackage failed, insufficient rights?\n");
DeleteFileW(path);
return;
}
ok(hr == S_OK, "IDispatch::Invoke returned 0x%08x\n", hr);
VariantClear(&vararg[0]);
VariantClear(&varresult);
......@@ -2405,7 +2411,7 @@ static void test_Installer_InstallProduct(void)
hr = Installer_InstallProduct(szMsifile, NULL);
if (hr == DISP_E_EXCEPTION)
{
skip("Installer object not supported.\n");
skip("InstallProduct failed, insufficient rights?\n");
delete_test_files();
return;
}
......@@ -2610,6 +2616,12 @@ static void test_Installer(void)
/* Installer::OpenPackage */
hr = Installer_OpenPackage(szPath, 0, &pSession);
if (hr == DISP_E_EXCEPTION)
{
skip("OpenPackage failed, insufficient rights?\n");
DeleteFileW(szPath);
return;
}
ok(hr == S_OK, "Installer_OpenPackage failed, hresult 0x%08x\n", hr);
if (hr == S_OK)
{
......
......@@ -3122,6 +3122,11 @@ static void test_try_transform(void)
/* check that the property was added */
r = package_from_db(hdb, &hpkg);
if (r == ERROR_INSTALL_PACKAGE_REJECTED)
{
skip("Not enough rights to perform tests\n");
goto error;
}
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
sz = MAX_PATH;
......@@ -3130,8 +3135,9 @@ static void test_try_transform(void)
ok(!lstrcmp(buffer, "val"), "Expected val, got %s\n", buffer);
MsiCloseHandle(hpkg);
MsiCloseHandle(hdb);
error:
MsiCloseHandle(hdb);
DeleteFile(msifile);
DeleteFile(mstfile);
}
......@@ -7176,8 +7182,7 @@ static void test_storages_table(void)
static void test_dbtopackage(void)
{
MSIHANDLE hdb, hpkg;
CHAR package[10];
CHAR buf[MAX_PATH];
CHAR package[12], buf[MAX_PATH];
DWORD size;
UINT r;
......@@ -7196,8 +7201,13 @@ static void test_dbtopackage(void)
r = add_custom_action_entry(hdb, "'SetProp', 51, 'MYPROP', 'grape'");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
sprintf(package, "#%i", hdb);
sprintf(package, "#%u", hdb);
r = MsiOpenPackage(package, &hpkg);
if (r == ERROR_INSTALL_PACKAGE_REJECTED)
{
skip("Not enough rights to perform tests\n");
goto error;
}
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
/* property is not set yet */
......@@ -7255,7 +7265,7 @@ static void test_dbtopackage(void)
r = add_custom_action_entry(hdb, "'SetProp', 51, 'MYPROP', 'grape'");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
sprintf(package, "#%i", hdb);
sprintf(package, "#%u", hdb);
r = MsiOpenPackage(package, &hpkg);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
......@@ -7296,8 +7306,10 @@ static void test_dbtopackage(void)
ok(size == 0, "Expected 0, got %d\n", size);
}
MsiCloseHandle(hdb);
MsiCloseHandle(hpkg);
error:
MsiCloseHandle(hdb);
DeleteFileA(msifile);
}
......
......@@ -201,15 +201,20 @@ static MSIHANDLE create_package_db(void)
DeleteFile(msifile);
/* create an empty database */
res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb );
ok( res == ERROR_SUCCESS , "Failed to create database\n" );
res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATEDIRECT, &hdb );
ok( res == ERROR_SUCCESS , "Failed to create database %u\n", res );
if( res != ERROR_SUCCESS )
return hdb;
return 0;
res = MsiDatabaseCommit( hdb );
ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
if( res != ERROR_SUCCESS )
return 0;
res = set_summary_info(hdb);
ok( res == ERROR_SUCCESS , "Failed to set summary info %u\n", res );
if( res != ERROR_SUCCESS )
return 0;
res = run_query( hdb,
"CREATE TABLE `Directory` ( "
......@@ -217,7 +222,7 @@ static MSIHANDLE create_package_db(void)
"`Directory_Parent` CHAR(255), "
"`DefaultDir` CHAR(255) NOT NULL "
"PRIMARY KEY `Directory`)" );
ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
ok( res == ERROR_SUCCESS , "Failed to create directory table %u\n", res );
return hdb;
}
......@@ -264,11 +269,13 @@ static UINT helper_createpackage( const char *szName, MSIHANDLE *handle )
DeleteFile(szName);
/* create an empty database */
res = MsiOpenDatabase(szName, MSIDBOPEN_CREATE, &hdb );
ok( res == ERROR_SUCCESS , "Failed to create database\n" );
res = MsiOpenDatabase(szName, MSIDBOPEN_CREATEDIRECT, &hdb );
ok( res == ERROR_SUCCESS , "Failed to create database %u\n", res );
if (res != ERROR_SUCCESS)
return res;
res = MsiDatabaseCommit( hdb );
ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
ok( res == ERROR_SUCCESS , "Failed to commit database %u\n", res );
/* build summary info */
res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
......@@ -307,9 +314,13 @@ static UINT helper_createpackage( const char *szName, MSIHANDLE *handle )
ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
res = package_from_db( hdb, &hPackage );
ok( res == ERROR_SUCCESS, "failed to create package %u\n", res );
MsiCloseHandle(hdb);
if (res != ERROR_SUCCESS)
DeleteFileA( szName );
else
*handle = hPackage;
*handle = hPackage;
return res;
}
......@@ -319,6 +330,11 @@ static void test_createpackage(void)
UINT res;
res = helper_createpackage( msifile, &hPackage );
if (res == ERROR_INSTALL_PACKAGE_REJECTED)
{
skip("Not enough rights to perform tests\n");
return;
}
ok( res == ERROR_SUCCESS, "Failed to create package %u\n", res );
res = MsiCloseHandle( hPackage );
......@@ -1626,6 +1642,11 @@ static void test_formatrecord_package(void)
DWORD sz=100;
r = helper_createpackage( msifile, &package );
if (r == ERROR_INSTALL_PACKAGE_REJECTED)
{
skip("Not enough rights to perform tests\n");
return;
}
ok( r == ERROR_SUCCESS, "Unable to create package %u\n", r );
hrec = MsiCreateRecord(12);
......@@ -2198,6 +2219,13 @@ static void test_formatrecord_tables(void)
ok( r == ERROR_SUCCESS, "cannt add custom action: %d\n", r);
r = package_from_db( hdb, &hpkg );
if (r == ERROR_INSTALL_PACKAGE_REJECTED)
{
skip("Not enough rights to perform tests\n");
MsiCloseHandle( hdb );
DeleteFile( msifile );
return;
}
ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
MsiCloseHandle( hdb );
......@@ -2385,6 +2413,11 @@ static void test_processmessage(void)
UINT r;
r = helper_createpackage( msifile, &package );
if (r == ERROR_INSTALL_PACKAGE_REJECTED)
{
skip("Not enough rights to perform tests\n");
return;
}
ok( r == ERROR_SUCCESS, "Unable to create package %u\n", r );
hrec = MsiCreateRecord(3);
......
......@@ -275,6 +275,11 @@ static void test_null(void)
/* empty product string */
r = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", 0, access, &hkey);
if (r == ERROR_ACCESS_DENIED)
{
skip("Not enough rights to perform tests\n");
return;
}
ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
r = RegQueryValueExA(hkey, NULL, 0, &dwType, lpData, &cbData);
......@@ -614,6 +619,13 @@ static void test_MsiQueryProductState(void)
lstrcatA(keypath, prodcode);
res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
if (res == ERROR_ACCESS_DENIED)
{
skip("Not enough rights to perform tests\n");
RegDeleteKeyA(userkey, "");
LocalFree(usersid);
return;
}
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* local uninstall key exists */
......@@ -914,6 +926,14 @@ static void test_MsiQueryFeatureState(void)
lstrcatA(keypath, "\\Features");
res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
if (res == ERROR_ACCESS_DENIED)
{
skip("Not enough rights to perform tests\n");
RegDeleteKeyA(userkey, "");
RegCloseKey(userkey);
LocalFree(usersid);
return;
}
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* userdata features key exists */
......@@ -1309,6 +1329,12 @@ static void test_MsiQueryComponentState(void)
lstrcatA(keypath, prod_squashed);
res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
if (res == ERROR_ACCESS_DENIED)
{
skip("Not enough rights to perform tests\n");
LocalFree(usersid);
return;
}
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
state = MAGIC_ERROR;
......@@ -1637,6 +1663,12 @@ static void test_MsiGetComponentPath(void)
lstrcatA(keypath, comp_squashed);
res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
if (res == ERROR_ACCESS_DENIED)
{
skip("Not enough rights to perform tests\n");
LocalFree(usersid);
return;
}
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* local system component key exists */
......@@ -2155,6 +2187,12 @@ static void test_MsiGetProductCode(void)
lstrcatA(keypath, comp_squashed);
res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
if (res == ERROR_ACCESS_DENIED)
{
skip("Not enough rights to perform tests\n");
LocalFree(usersid);
return;
}
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* user unmanaged component key exists */
......@@ -2397,6 +2435,12 @@ static void test_MsiEnumClients(void)
lstrcatA(keypath, comp_squashed);
res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
if (res == ERROR_ACCESS_DENIED)
{
skip("Not enough rights to perform tests\n");
LocalFree(usersid);
return;
}
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* user unmanaged component key exists */
......@@ -2911,6 +2955,12 @@ static void test_MsiGetProductInfo(void)
lstrcatA(keypath, prod_squashed);
res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
if (res == ERROR_ACCESS_DENIED)
{
skip("Not enough rights to perform tests\n");
LocalFree(usersid);
return;
}
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* managed product code exists */
......@@ -4222,6 +4272,12 @@ static void test_MsiGetProductInfoEx(void)
lstrcatA(keypath, prod_squashed);
res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
if (res == ERROR_ACCESS_DENIED)
{
skip("Not enough rights to perform tests\n");
LocalFree(usersid);
return;
}
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* local user product key exists */
......@@ -7007,6 +7063,12 @@ static void test_MsiGetUserInfo(void)
lstrcatA(keypath, prod_squashed);
res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
if (res == ERROR_ACCESS_DENIED)
{
skip("Not enough rights to perform tests\n");
LocalFree(usersid);
return;
}
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* managed product key exists */
......@@ -7483,6 +7545,12 @@ static void test_MsiOpenProduct(void)
lstrcatA(keypath, prod_squashed);
res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
if (res == ERROR_ACCESS_DENIED)
{
skip("Not enough rights to perform tests\n");
LocalFree(usersid);
return;
}
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* managed product key exists */
......@@ -7745,6 +7813,11 @@ static void test_MsiEnumPatchesEx_usermanaged(LPCSTR usersid, LPCSTR expectedsid
r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
&context, targetsid, &size);
if (r == ERROR_ACCESS_DENIED)
{
skip("Not enough rights to perform tests\n");
return;
}
ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
ok(!lstrcmpA(patchcode, "apple"),
"Expected patchcode to be unchanged, got %s\n", patchcode);
......@@ -7762,6 +7835,11 @@ static void test_MsiEnumPatchesEx_usermanaged(LPCSTR usersid, LPCSTR expectedsid
lstrcatA(keypath, prod_squashed);
res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
if (res == ERROR_ACCESS_DENIED)
{
skip("Not enough rights to perform tests\n");
return;
}
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* managed product key exists */
......@@ -8510,6 +8588,11 @@ static void test_MsiEnumPatchesEx_userunmanaged(LPCSTR usersid, LPCSTR expecteds
lstrcatA(keypath, patch_squashed);
res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
if (res == ERROR_ACCESS_DENIED)
{
skip("Not enough rights to perform tests\n");
goto error;
}
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* userdata patch key exists */
......@@ -8759,6 +8842,8 @@ static void test_MsiEnumPatchesEx_userunmanaged(LPCSTR usersid, LPCSTR expecteds
RegCloseKey(userkey);
RegDeleteValueA(patches, patch_squashed);
RegDeleteValueA(patches, "Patches");
error:
RegDeleteKeyA(patches, "");
RegCloseKey(patches);
RegDeleteKeyA(prodkey, "");
......@@ -8811,6 +8896,11 @@ static void test_MsiEnumPatchesEx_machine(void)
lstrcatA(keypath, prod_squashed);
res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
if (res == ERROR_ACCESS_DENIED)
{
skip("Not enough rights to perform tests\n");
return;
}
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* local product key exists */
......@@ -9588,6 +9678,12 @@ static void test_MsiEnumPatches(void)
lstrcatA(keypath, prod_squashed);
res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
if (res == ERROR_ACCESS_DENIED)
{
skip("Not enough rights to perform tests\n");
LocalFree(usersid);
return;
}
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* managed product key exists */
......@@ -10430,6 +10526,12 @@ static void test_MsiGetPatchInfoEx(void)
lstrcatA(keypath, prod_squashed);
res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &udprod, NULL);
if (res == ERROR_ACCESS_DENIED)
{
skip("Not enough rights to perform tests\n");
LocalFree(usersid);
return;
}
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* local UserData product key exists */
......@@ -11219,6 +11321,11 @@ static void test_MsiGetPatchInfo(void)
lstrcatA(keypath, prod_squashed);
res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &hkey_product, NULL);
if (res == ERROR_ACCESS_DENIED)
{
skip("Not enough rights to perform tests\n");
return;
}
ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res);
/* product key exists */
......@@ -11386,6 +11493,12 @@ static void test_MsiEnumProducts(void)
strcat(keypath1, product_squashed1);
r = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath1, 0, NULL, 0, access, NULL, &key1, NULL);
if (r == ERROR_ACCESS_DENIED)
{
skip("Not enough rights to perform tests\n");
LocalFree(usersid);
return;
}
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
strcpy(keypath2, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
......
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