Test code - Bug 1342742 - check that the app update patch dir, install dir, and working dir paths are valid. r=mhowell

This commit is contained in:
Robert Strong 2017-04-28 16:36:57 -07:00
Родитель 0de416e483
Коммит 815f458666
25 изменённых файлов: 690 добавлений и 93 удалений

Просмотреть файл

@ -337,6 +337,26 @@ int NS_main(int argc, NS_tchar **argv)
#endif
}
if (!NS_tstrcmp(argv[1], NS_T("launch-service"))) {
#ifdef XP_WIN
DWORD ret = LaunchServiceSoftwareUpdateCommand(argc - 2, (LPCWSTR *)argv + 2);
if (ret != ERROR_SUCCESS) {
// 192 is used to avoid reusing a possible return value from the call to
// WaitForServiceStop
return 0x000000C0;
}
// Wait a maximum of 120 seconds.
DWORD lastState = WaitForServiceStop(SVC_NAME, 120);
if (SERVICE_STOPPED == lastState) {
return 0;
}
return lastState;
#else
// Not implemented on non-Windows platforms
return 1;
#endif
}
if (NS_tchdir(argv[1]) != 0) {
return 1;
}

Просмотреть файл

@ -37,14 +37,21 @@ const STATE_SUCCEEDED = "succeeded";
const STATE_DOWNLOAD_FAILED = "download-failed";
const STATE_FAILED = "failed";
const LOADSOURCE_ERROR_WRONG_SIZE = 2;
const CRC_ERROR = 4;
const READ_ERROR = 6;
const WRITE_ERROR = 7;
const MAR_CHANNEL_MISMATCH_ERROR = 22;
const VERSION_DOWNGRADE_ERROR = 23;
const INVALID_APPLYTO_DIR_STAGED_ERROR = 72;
const INVALID_APPLYTO_DIR_ERROR = 74;
const LOADSOURCE_ERROR_WRONG_SIZE = 2;
const CRC_ERROR = 4;
const READ_ERROR = 6;
const WRITE_ERROR = 7;
const MAR_CHANNEL_MISMATCH_ERROR = 22;
const VERSION_DOWNGRADE_ERROR = 23;
const SERVICE_COULD_NOT_COPY_UPDATER = 49;
const SERVICE_INVALID_APPLYTO_DIR_STAGED_ERROR = 52;
const SERVICE_INVALID_APPLYTO_DIR_ERROR = 54;
const SERVICE_INVALID_INSTALL_DIR_PATH_ERROR = 55;
const SERVICE_INVALID_WORKING_DIR_PATH_ERROR = 56;
const INVALID_APPLYTO_DIR_STAGED_ERROR = 72;
const INVALID_APPLYTO_DIR_ERROR = 74;
const INVALID_INSTALL_DIR_PATH_ERROR = 75;
const INVALID_WORKING_DIR_PATH_ERROR = 76;
const STATE_FAILED_DELIMETER = ": ";
@ -60,10 +67,24 @@ const STATE_FAILED_MAR_CHANNEL_MISMATCH_ERROR =
STATE_FAILED + STATE_FAILED_DELIMETER + MAR_CHANNEL_MISMATCH_ERROR;
const STATE_FAILED_VERSION_DOWNGRADE_ERROR =
STATE_FAILED + STATE_FAILED_DELIMETER + VERSION_DOWNGRADE_ERROR;
const STATE_FAILED_SERVICE_COULD_NOT_COPY_UPDATER =
STATE_FAILED + STATE_FAILED_DELIMETER + SERVICE_COULD_NOT_COPY_UPDATER
const STATE_FAILED_SERVICE_INVALID_APPLYTO_DIR_STAGED_ERROR =
STATE_FAILED + STATE_FAILED_DELIMETER + SERVICE_INVALID_APPLYTO_DIR_STAGED_ERROR;
const STATE_FAILED_SERVICE_INVALID_APPLYTO_DIR_ERROR =
STATE_FAILED + STATE_FAILED_DELIMETER + SERVICE_INVALID_APPLYTO_DIR_ERROR;
const STATE_FAILED_SERVICE_INVALID_INSTALL_DIR_PATH_ERROR =
STATE_FAILED + STATE_FAILED_DELIMETER + SERVICE_INVALID_INSTALL_DIR_PATH_ERROR;
const STATE_FAILED_SERVICE_INVALID_WORKING_DIR_PATH_ERROR =
STATE_FAILED + STATE_FAILED_DELIMETER + SERVICE_INVALID_WORKING_DIR_PATH_ERROR;
const STATE_FAILED_INVALID_APPLYTO_DIR_STAGED_ERROR =
STATE_FAILED + STATE_FAILED_DELIMETER + INVALID_APPLYTO_DIR_STAGED_ERROR;
const STATE_FAILED_INVALID_APPLYTO_DIR_ERROR =
STATE_FAILED + STATE_FAILED_DELIMETER + INVALID_APPLYTO_DIR_ERROR;
const STATE_FAILED_INVALID_INSTALL_DIR_PATH_ERROR =
STATE_FAILED + STATE_FAILED_DELIMETER + INVALID_INSTALL_DIR_PATH_ERROR;
const STATE_FAILED_INVALID_WORKING_DIR_PATH_ERROR =
STATE_FAILED + STATE_FAILED_DELIMETER + INVALID_WORKING_DIR_PATH_ERROR;
/**
* Constructs a string representing a remote update xml file.

Просмотреть файл

@ -39,7 +39,7 @@ const URL_HTTP_UPDATE_SJS = "http://test_details/";
/* global INSTALL_LOCALE, MOZ_APP_NAME, BIN_SUFFIX, MOZ_APP_VENDOR */
/* global MOZ_APP_BASENAME, APP_BIN_SUFFIX, APP_INFO_NAME, APP_INFO_VENDOR */
/* global IS_WIN, IS_MACOSX, IS_UNIX, MOZ_VERIFY_MAR_SIGNATURE */
/* global MOZ_VERIFY_MAR_SIGNATURE, IS_AUTHENTICODE_CHECK_ENABLED */
/* global IS_AUTHENTICODE_CHECK_ENABLED */
load("../data/xpcshellConstantsPP.js");
function getLogSuffix() {
@ -159,8 +159,6 @@ var gGREDirOrig;
var gGREBinDirOrig;
var gAppDirOrig;
var gApplyToDirOverride;
// Variables are used instead of contants so tests can override these values if
// necessary.
var gCallbackBinFile = "callback_app" + BIN_SUFFIX;
@ -1134,18 +1132,6 @@ function getAppVersion() {
return iniParser.getString("App", "Version");
}
/**
* Override the apply-to directory parameter to be passed to the updater.
* This ought to cause the updater to fail when using any value that isn't the
* default, automatically computed one.
*
* @param dir
* Complete string to use as the apply-to directory parameter.
*/
function overrideApplyToDir(dir) {
gApplyToDirOverride = dir;
}
/**
* Helper function for getting the relative path to the directory where the
* application binary is located (e.g. <test_file_leafname>/dir.app/).
@ -1673,9 +1659,20 @@ function readServiceLogFile() {
* tests.
* @param aCheckSvcLog
* Whether the service log should be checked for service tests.
* @param aPatchDirPath (optional)
* When specified the patch directory path to use for invalid argument
* tests otherwise the normal path will be used.
* @param aInstallDirPath (optional)
* When specified the install directory path to use for invalid
* argument tests otherwise the normal path will be used.
* @param aApplyToDirPath (optional)
* When specified the apply to / working directory path to use for
* invalid argument tests otherwise the normal path will be used.
*/
function runUpdate(aExpectedStatus, aSwitchApp, aExpectedExitValue,
aCheckSvcLog) {
function runUpdate(aExpectedStatus, aSwitchApp, aExpectedExitValue, aCheckSvcLog,
aPatchDirPath, aInstallDirPath, aApplyToDirPath) {
let isInvalidArgTest = !!aPatchDirPath || !!aInstallDirPath || !!aApplyToDirPath;
let svcOriginalLog;
if (IS_SERVICE_TEST) {
copyFileToTestAppDir(FILE_MAINTENANCE_SERVICE_BIN, false);
@ -1690,28 +1687,37 @@ function runUpdate(aExpectedStatus, aSwitchApp, aExpectedExitValue,
Assert.ok(updateBin.exists(),
MSG_SHOULD_EXIST + getMsgPath(updateBin.path));
let updatesDirPath = getUpdatesPatchDir().path;
let applyToDirPath = getApplyDirFile(null, true).path;
let stageDirPath = getStageDirFile(null, true).path;
let updatesDirPath = aPatchDirPath || getUpdatesPatchDir().path;
let installDirPath = aInstallDirPath || getApplyDirFile(null, true).path;
let applyToDirPath = aApplyToDirPath || getApplyDirFile(null, true).path;
let stageDirPath = aApplyToDirPath || getStageDirFile(null, true).path;
let callbackApp = getApplyDirFile(DIR_RESOURCES + gCallbackBinFile);
callbackApp.permissions = PERMS_DIRECTORY;
setAppBundleModTime();
let args = [updatesDirPath, applyToDirPath];
let args = [updatesDirPath, installDirPath];
if (aSwitchApp) {
args[2] = gApplyToDirOverride || stageDirPath;
args[2] = stageDirPath;
args[3] = "0/replace";
} else {
args[2] = gApplyToDirOverride || applyToDirPath;
args[2] = applyToDirPath;
args[3] = "0";
}
args = args.concat([callbackApp.parent.path, callbackApp.path]);
args = args.concat(gCallbackArgs);
debugDump("running the updater: " + updateBin.path + " " + args.join(" "));
if (aSwitchApp) {
let launchBin = IS_SERVICE_TEST && isInvalidArgTest ? callbackApp : updateBin;
if (!isInvalidArgTest) {
args = args.concat([callbackApp.parent.path, callbackApp.path]);
args = args.concat(gCallbackArgs);
} else if (IS_SERVICE_TEST) {
args = ["launch-service", updateBin.path].concat(args);
}
debugDump("launching the program: " + launchBin.path + " " + args.join(" "));
if (aSwitchApp && !isInvalidArgTest) {
// We want to set the env vars again
gShouldResetEnv = undefined;
}
@ -1720,7 +1726,7 @@ function runUpdate(aExpectedStatus, aSwitchApp, aExpectedExitValue,
let process = Cc["@mozilla.org/process/util;1"].
createInstance(Ci.nsIProcess);
process.init(updateBin);
process.init(launchBin);
process.run(true, args, args.length);
resetEnvironment();
@ -1751,9 +1757,11 @@ function runUpdate(aExpectedStatus, aSwitchApp, aExpectedExitValue,
Assert.notEqual(contents, svcOriginalLog,
"the contents of the maintenanceservice.log should not " +
"be the same as the original contents");
Assert.notEqual(contents.indexOf(LOG_SVC_SUCCESSFUL_LAUNCH), -1,
"the contents of the maintenanceservice.log should " +
"contain the successful launch string");
if (!isInvalidArgTest) {
Assert.notEqual(contents.indexOf(LOG_SVC_SUCCESSFUL_LAUNCH), -1,
"the contents of the maintenanceservice.log should " +
"contain the successful launch string");
}
}
do_execute_soon(runUpdateFinished);
@ -2581,8 +2589,12 @@ function waitForHelperExit() {
* @param aPostUpdateAsync
* When null the updater.ini is not created otherwise this parameter
* is passed to createUpdaterINI.
* @param aPostUpdateExeRelPathPrefix
* When aPostUpdateAsync null this value is ignored otherwise it is
* passed to createUpdaterINI.
*/
function setupUpdaterTest(aMarFile, aPostUpdateAsync) {
function setupUpdaterTest(aMarFile, aPostUpdateAsync,
aPostUpdateExeRelPathPrefix = "") {
let updatesPatchDir = getUpdatesPatchDir();
if (!updatesPatchDir.exists()) {
updatesPatchDir.create(Ci.nsIFile.DIRECTORY_TYPE, PERMS_DIRECTORY);
@ -2667,7 +2679,7 @@ function setupUpdaterTest(aMarFile, aPostUpdateAsync) {
setupActiveUpdate();
if (aPostUpdateAsync !== null) {
createUpdaterINI(aPostUpdateAsync);
createUpdaterINI(aPostUpdateAsync, aPostUpdateExeRelPathPrefix);
}
setupAppFilesAsync();
@ -2690,8 +2702,10 @@ function createUpdateSettingsINI() {
* True or undefined if the post update process should be async. If
* undefined ExeAsync will not be added to the updater.ini file in
* order to test the default launch behavior which is async.
* @param aExeRelPathPrefix
* A string to prefix the ExeRelPath values in the updater.ini.
*/
function createUpdaterINI(aIsExeAsync) {
function createUpdaterINI(aIsExeAsync, aExeRelPathPrefix) {
let exeArg = "ExeArg=post-update-async\n";
let exeAsync = "";
if (aIsExeAsync !== undefined) {
@ -2703,16 +2717,23 @@ function createUpdaterINI(aIsExeAsync) {
}
}
if (aExeRelPathPrefix && IS_WIN) {
aExeRelPathPrefix = aExeRelPathPrefix.replace("/", "\\");
}
let exeRelPathMac = "ExeRelPath=" + aExeRelPathPrefix + DIR_RESOURCES +
gPostUpdateBinFile + "\n";
let exeRelPathWin = "ExeRelPath=" + aExeRelPathPrefix + gPostUpdateBinFile + "\n";
let updaterIniContents = "[Strings]\n" +
"Title=Update Test\n" +
"Info=Running update test " + gTestID + "\n\n" +
"[PostUpdateMac]\n" +
"ExeRelPath=" + DIR_RESOURCES + gPostUpdateBinFile + "\n" +
exeRelPathMac +
exeArg +
exeAsync +
"\n" +
"[PostUpdateWin]\n" +
"ExeRelPath=" + gPostUpdateBinFile + "\n" +
exeRelPathWin +
exeArg +
exeAsync;
let updaterIni = getApplyDirFile(DIR_RESOURCES + FILE_UPDATER_INI, true);

Просмотреть файл

@ -0,0 +1,47 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* Too long install directory path failure test */
const STATE_AFTER_RUNUPDATE =
IS_SERVICE_TEST ? STATE_FAILED_SERVICE_INVALID_INSTALL_DIR_PATH_ERROR
: STATE_FAILED_INVALID_INSTALL_DIR_PATH_ERROR;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
let path = "123456789";
if (IS_WIN) {
path = "\\" + path;
path = path.repeat(30); // 300 characters
path = "C:" + path;
} else {
path = "/" + path;
path = path.repeat(1000); // 10000 characters
}
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, path, null);
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
waitForFilesInUse();
}

Просмотреть файл

@ -0,0 +1,44 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* Install directory path traversal failure test */
const STATE_AFTER_RUNUPDATE =
IS_SERVICE_TEST ? STATE_FAILED_SERVICE_INVALID_INSTALL_DIR_PATH_ERROR
: STATE_FAILED_INVALID_INSTALL_DIR_PATH_ERROR;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
let path = "123456789";
if (IS_WIN) {
path = "C:\\" + path + "\\..\\" + path;
} else {
path = "/" + path + "/../" + path;
}
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, path, null);
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
waitForFilesInUse();
}

Просмотреть файл

@ -3,9 +3,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* Test trying to use an apply-to directory different from the install
* directory, which should fail.
*/
/* Different install and working directories for a regular update failure */
const STATE_AFTER_RUNUPDATE =
IS_SERVICE_TEST ? STATE_FAILED_SERVICE_INVALID_APPLYTO_DIR_ERROR
: STATE_FAILED_INVALID_APPLYTO_DIR_ERROR;
function run_test() {
if (!setupTestCommon()) {
@ -21,11 +23,8 @@ function run_test() {
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
overrideApplyToDir(getApplyDirPath() + "/../NoSuchDir");
// If execv is used the updater process will turn into the callback process
// and the updater's return code will be that of the callback process.
runUpdate(STATE_FAILED_INVALID_APPLYTO_DIR_ERROR, false, (USE_EXECV ? 0 : 1),
false);
let path = getApplyDirFile("..", false).path;
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, path);
}
/**

Просмотреть файл

@ -0,0 +1,43 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* Patch directory path traversal failure test */
const STATE_AFTER_RUNUPDATE =
IS_SERVICE_TEST ? STATE_PENDING_SVC : STATE_PENDING;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
let path = getUpdatesPatchDir();
if (IS_WIN) {
path = path + "\\..\\";
} else {
path = path + "/../";
}
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, path, null, null);
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
waitForFilesInUse();
}

Просмотреть файл

@ -0,0 +1,38 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* Different install and working directories for a regular update failure */
const STATE_AFTER_RUNUPDATE =
IS_SERVICE_TEST ? STATE_FAILED_SERVICE_INVALID_APPLYTO_DIR_STAGED_ERROR
: STATE_FAILED_INVALID_APPLYTO_DIR_STAGED_ERROR;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
let path = getApplyDirFile("..", false).path;
runUpdate(STATE_AFTER_RUNUPDATE, true, 1, true, null, null, path);
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
waitForFilesInUse();
}

Просмотреть файл

@ -0,0 +1,38 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* Working directory path local UNC failure test */
const STATE_AFTER_RUNUPDATE =
IS_SERVICE_TEST ? STATE_FAILED_SERVICE_INVALID_WORKING_DIR_PATH_ERROR
: STATE_FAILED_INVALID_WORKING_DIR_PATH_ERROR;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
let path = "\\\\.\\" + getApplyDirFile(null, false).path;
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, path);
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
waitForFilesInUse();
}

Просмотреть файл

@ -0,0 +1,37 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* Relative working directory path failure test */
const STATE_AFTER_RUNUPDATE =
IS_SERVICE_TEST ? STATE_FAILED_SERVICE_INVALID_WORKING_DIR_PATH_ERROR
: STATE_FAILED_INVALID_WORKING_DIR_PATH_ERROR;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, "test");
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
waitForFilesInUse();
}

Просмотреть файл

@ -14,7 +14,10 @@ function run_test() {
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setupUpdaterTest(FILE_COMPLETE_MAR, undefined);
// The third parameter will test that a full path to the post update binary
// doesn't execute.
setupUpdaterTest(FILE_COMPLETE_MAR, undefined,
getApplyDirFile(null, true).path + "/");
}
/**
@ -28,13 +31,6 @@ function setupUpdaterTestFinished() {
* Called after the call to runUpdateUsingApp finishes.
*/
function runUpdateFinished() {
checkPostUpdateAppLog();
}
/**
* Called after the call to checkPostUpdateAppLog finishes.
*/
function checkPostUpdateAppLogFinished() {
checkAppBundleModTime();
standardInit();
Assert.equal(readStatusState(), STATE_NONE,
@ -45,7 +41,7 @@ function checkPostUpdateAppLogFinished() {
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(true);
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getApplyDirFile);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);

Просмотреть файл

@ -13,7 +13,6 @@ function run_test() {
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
createUpdaterINI(false);
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}

Просмотреть файл

@ -18,7 +18,9 @@ function run_test() {
gTestFiles[gTestFiles.length - 2].comparePerms = 0o644;
gTestDirs = gTestDirsPartialSuccess;
setupDistributionDir();
setupUpdaterTest(FILE_PARTIAL_MAR, false);
// The third parameter will test that a relative path that contains a
// directory traversal to the post update binary doesn't execute.
setupUpdaterTest(FILE_PARTIAL_MAR, false, "test/../");
}
/**
@ -32,13 +34,6 @@ function setupUpdaterTestFinished() {
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
checkPostUpdateAppLog();
}
/**
* Called after the call to checkPostUpdateAppLog finishes.
*/
function checkPostUpdateAppLogFinished() {
checkAppBundleModTime();
standardInit();
Assert.equal(readStatusState(), STATE_NONE,
@ -49,7 +44,7 @@ function checkPostUpdateAppLogFinished() {
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(true);
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getApplyDirFile);
checkUpdateLogContents(LOG_PARTIAL_SUCCESS);
checkDistributionDir();

Просмотреть файл

@ -10,6 +10,19 @@
tags = appupdate
head = head_update.js
[invalidArgInstallDirPathTooLongFailure.js]
[invalidArgInstallDirPathTraversalFailure.js]
[invalidArgInstallWorkingDirPathNotSameFailure_win.js]
skip-if = os != 'win'
reason = Windows only test
[invalidArgPatchDirPathTraversalFailure.js]
[invalidArgStageDirNotInInstallDirFailure_win.js]
skip-if = os != 'win'
reason = Windows only test
[invalidArgWorkingDirPathLocalUNCFailure_win.js]
skip-if = os != 'win'
reason = Windows only test
[invalidArgWorkingDirPathRelativeFailure.js]
[marSuccessComplete.js]
[marSuccessPartial.js]
[marFailurePartial.js]
@ -81,6 +94,3 @@ skip-if = os != 'win'
reason = Windows only test
[marAppApplyUpdateSuccess.js]
[marAppApplyUpdateStageSuccess.js]
[marWrongApplyToDirFailure_win.js]
skip-if = os != 'win'
reason = Windows only test

Просмотреть файл

@ -0,0 +1,47 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* Too long install directory path failure test */
const STATE_AFTER_RUNUPDATE =
IS_SERVICE_TEST ? STATE_FAILED_SERVICE_INVALID_INSTALL_DIR_PATH_ERROR
: STATE_FAILED_INVALID_INSTALL_DIR_PATH_ERROR;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
let path = "123456789";
if (IS_WIN) {
path = "\\" + path;
path = path.repeat(30); // 300 characters
path = "C:" + path;
} else {
path = "/" + path;
path = path.repeat(1000); // 10000 characters
}
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, path, null);
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
waitForFilesInUse();
}

Просмотреть файл

@ -0,0 +1,44 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* Install directory path traversal failure test */
const STATE_AFTER_RUNUPDATE =
IS_SERVICE_TEST ? STATE_FAILED_SERVICE_INVALID_INSTALL_DIR_PATH_ERROR
: STATE_FAILED_INVALID_INSTALL_DIR_PATH_ERROR;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
let path = "123456789";
if (IS_WIN) {
path = "C:\\" + path + "\\..\\" + path;
} else {
path = "/" + path + "/../" + path;
}
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, path, null);
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
waitForFilesInUse();
}

Просмотреть файл

@ -0,0 +1,38 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* Different install and working directories for a regular update failure */
const STATE_AFTER_RUNUPDATE =
IS_SERVICE_TEST ? STATE_FAILED_SERVICE_INVALID_APPLYTO_DIR_ERROR
: STATE_FAILED_INVALID_APPLYTO_DIR_ERROR;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
let path = getApplyDirFile("..", false).path;
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, path);
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
waitForFilesInUse();
}

Просмотреть файл

@ -0,0 +1,43 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* Patch directory path traversal failure test */
const STATE_AFTER_RUNUPDATE =
IS_SERVICE_TEST ? STATE_PENDING_SVC : STATE_PENDING;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
let path = getUpdatesPatchDir();
if (IS_WIN) {
path = path + "\\..\\";
} else {
path = path + "/../";
}
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, path, null, null);
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
waitForFilesInUse();
}

Просмотреть файл

@ -0,0 +1,38 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* Different install and working directories for a regular update failure */
const STATE_AFTER_RUNUPDATE =
IS_SERVICE_TEST ? STATE_FAILED_SERVICE_INVALID_APPLYTO_DIR_STAGED_ERROR
: STATE_FAILED_INVALID_APPLYTO_DIR_STAGED_ERROR;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
let path = getApplyDirFile("..", false).path;
runUpdate(STATE_AFTER_RUNUPDATE, true, 1, true, null, null, path);
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
waitForFilesInUse();
}

Просмотреть файл

@ -0,0 +1,38 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* Working directory path local UNC failure test */
const STATE_AFTER_RUNUPDATE =
IS_SERVICE_TEST ? STATE_FAILED_SERVICE_INVALID_WORKING_DIR_PATH_ERROR
: STATE_FAILED_INVALID_WORKING_DIR_PATH_ERROR;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
let path = "\\\\.\\" + getApplyDirFile(null, false).path;
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, path);
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
waitForFilesInUse();
}

Просмотреть файл

@ -0,0 +1,37 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* Relative working directory path failure test */
const STATE_AFTER_RUNUPDATE =
IS_SERVICE_TEST ? STATE_FAILED_SERVICE_INVALID_WORKING_DIR_PATH_ERROR
: STATE_FAILED_INVALID_WORKING_DIR_PATH_ERROR;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, "test");
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
waitForFilesInUse();
}

Просмотреть файл

@ -14,7 +14,10 @@ function run_test() {
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setupUpdaterTest(FILE_COMPLETE_MAR, undefined);
// The third parameter will test that a full path to the post update binary
// doesn't execute.
setupUpdaterTest(FILE_COMPLETE_MAR, undefined,
getApplyDirFile(null, true).path + "/");
}
/**
@ -28,13 +31,6 @@ function setupUpdaterTestFinished() {
* Called after the call to runUpdateUsingApp finishes.
*/
function runUpdateFinished() {
checkPostUpdateAppLog();
}
/**
* Called after the call to checkPostUpdateAppLog finishes.
*/
function checkPostUpdateAppLogFinished() {
checkAppBundleModTime();
standardInit();
Assert.equal(readStatusState(), STATE_NONE,
@ -45,7 +41,7 @@ function checkPostUpdateAppLogFinished() {
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(true);
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getApplyDirFile);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);

Просмотреть файл

@ -13,7 +13,6 @@ function run_test() {
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
createUpdaterINI(false);
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}

Просмотреть файл

@ -18,7 +18,9 @@ function run_test() {
gTestFiles[gTestFiles.length - 2].comparePerms = 0o644;
gTestDirs = gTestDirsPartialSuccess;
setupDistributionDir();
setupUpdaterTest(FILE_PARTIAL_MAR, false);
// The third parameter will test that a relative path that contains a
// directory traversal to the post update binary doesn't execute.
setupUpdaterTest(FILE_PARTIAL_MAR, false, "test/../");
}
/**
@ -32,13 +34,6 @@ function setupUpdaterTestFinished() {
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
checkPostUpdateAppLog();
}
/**
* Called after the call to checkPostUpdateAppLog finishes.
*/
function checkPostUpdateAppLogFinished() {
checkAppBundleModTime();
standardInit();
Assert.equal(readStatusState(), STATE_NONE,
@ -49,7 +44,7 @@ function checkPostUpdateAppLogFinished() {
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(true);
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getApplyDirFile);
checkUpdateLogContents(LOG_PARTIAL_SUCCESS);
checkDistributionDir();

Просмотреть файл

@ -10,6 +10,20 @@ head = head_update.js
[bootstrapSvc.js]
run-sequentially = Uses the Mozilla Maintenance Service.
[invalidArgInstallDirPathTooLongFailureSvc.js]
run-sequentially = Uses the Mozilla Maintenance Service.
[invalidArgInstallDirPathTraversalFailureSvc.js]
run-sequentially = Uses the Mozilla Maintenance Service.
[invalidArgInstallWorkingDirPathNotSameFailureSvc_win.js]
run-sequentially = Uses the Mozilla Maintenance Service.
[invalidArgPatchDirPathTraversalFailureSvc.js]
run-sequentially = Uses the Mozilla Maintenance Service.
[invalidArgStageDirNotInInstallDirFailureSvc_win.js]
run-sequentially = Uses the Mozilla Maintenance Service.
[invalidArgWorkingDirPathLocalUNCFailureSvc_win.js]
run-sequentially = Uses the Mozilla Maintenance Service.
[invalidArgWorkingDirPathRelativeFailureSvc.js]
run-sequentially = Uses the Mozilla Maintenance Service.
[marSuccessCompleteSvc.js]
run-sequentially = Uses the Mozilla Maintenance Service.
[marSuccessPartialSvc.js]