Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var ProjectManager = (function () {
*
* Overwrite this in your implementation!
*/
ProjectManager.prototype.createUpdateArchive = function (projectDirectory, targetPlatform, isDiff) { throw ProjectManager.NOT_IMPLEMENTED_ERROR_MSG; };
ProjectManager.prototype.createUpdateArchive = function (projectDirectory, targetPlatform) { throw ProjectManager.NOT_IMPLEMENTED_ERROR_MSG; };
/**
* Prepares a specific platform for tests.
*
Expand Down
5 changes: 1 addition & 4 deletions code-push-plugin-testing-framework/script/testUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ var TestUtil = (function () {
/**
* Archives the contents of sourceFolder and puts it in an archive at archivePath in targetFolder.
*/
TestUtil.archiveFolder = function (sourceFolder, targetFolder, archivePath, isDiff) {
TestUtil.archiveFolder = function (sourceFolder, targetFolder, archivePath) {
var deferred = Q.defer();
var archive = archiver.create("zip", {});
console.log("Creating an update archive at: " + archivePath);
Expand All @@ -139,9 +139,6 @@ var TestUtil = (function () {
archive.on("error", function (e) {
deferred.reject(e);
});
if (isDiff) {
archive.append("{\"deletedFiles\":[]}", { name: "hotcodepush.json" });
}
archive.directory(sourceFolder, targetFolder);
archive.pipe(writeStream);
archive.finalize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ declare module 'code-push-plugin-testing-framework/script/projectManager' {
*
* Overwrite this in your implementation!
*/
createUpdateArchive(projectDirectory: string, targetPlatform: platform.IPlatform, isDiff?: boolean): Q.Promise<string>;
createUpdateArchive(projectDirectory: string, targetPlatform: platform.IPlatform): Q.Promise<string>;
/**
* Prepares a specific platform for tests.
*
Expand Down Expand Up @@ -474,7 +474,7 @@ declare module 'code-push-plugin-testing-framework/script/testUtil' {
/**
* Archives the contents of sourceFolder and puts it in an archive at archivePath in targetFolder.
*/
static archiveFolder(sourceFolder: string, targetFolder: string, archivePath: string, isDiff: boolean): Q.Promise<string>;
static archiveFolder(sourceFolder: string, targetFolder: string, archivePath: string): Q.Promise<string>;
}

}
Expand Down
11 changes: 2 additions & 9 deletions test/codesign.mts
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,7 @@ function signUpdateContentsHash(contentHash: string): string {
* Code-signs the update contents with the test key pair and records the real hash, so the mock
* server hands back a package_hash that matches what the client's data-integrity check computes.
*/
export function signAndRecordUpdateArchive(bundleFolder: string, isDiff: boolean): void {
// TODO(RA-4875): Diff updates clear it instead, since they are poorly implemented in the entire test harness.
// It's going to be a bigger refactor, so for now we just skip signing/hashing to avoid using a stale value in diff tests.
if (isDiff) {
ServerUtil.setKnownPackageHash(undefined);
return;
}

export function signAndRecordUpdateArchive(bundleFolder: string): void {
const contentHash = computeUpdateContentsHash(bundleFolder);
const signatureFolder = path.join(bundleFolder, 'CodePush');
fs.mkdirSync(signatureFolder, { recursive: true });
Expand All @@ -114,5 +107,5 @@ export async function setupTamperedSignatureUpdateScenario(
signUpdateContentsHash(tamperedHash),
);

return await TestUtil.archiveFolder(bundleFolder, '', updatePath, false);
return await TestUtil.archiveFolder(bundleFolder, '', updatePath);
}
41 changes: 3 additions & 38 deletions test/test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -758,11 +758,7 @@ class RNProjectManager extends ProjectManager {
/**
* Creates a CodePush update package zip for a project.
*/
public createUpdateArchive(
projectDirectory: string,
targetPlatform: Platform.IPlatform,
isDiff?: boolean,
): Q.Promise<string> {
public createUpdateArchive(projectDirectory: string, targetPlatform: Platform.IPlatform): Q.Promise<string> {
const t0 = Date.now();
const bundleFolder: string = path.join(projectDirectory, TestConfig.TestAppName, 'CodePush/');
const bundleName: string = (targetPlatform as unknown as RNPlatform).getBundleName();
Expand Down Expand Up @@ -797,14 +793,13 @@ class RNProjectManager extends ProjectManager {
{ cwd: path.join(projectDirectory, TestConfig.TestAppName), noLogStdOut: true },
),
)
.then(() => signAndRecordUpdateArchive(bundleFolder, isDiff))
.then(() => signAndRecordUpdateArchive(bundleFolder))
.then<string>(
TestUtil.archiveFolder.bind(
undefined,
bundleFolder,
'',
path.join(projectDirectory, TestConfig.TestAppName, 'update.zip'),
isDiff,
),
)
.then((result) => {
Expand All @@ -825,14 +820,13 @@ class RNProjectManager extends ProjectManager {
{ cwd: path.join(projectDirectory, TestConfig.TestAppName), noLogStdOut: true },
),
)
.then(() => signAndRecordUpdateArchive(bundleFolder, isDiff))
.then(() => signAndRecordUpdateArchive(bundleFolder))
.then<string>(
TestUtil.archiveFolder.bind(
undefined,
bundleFolder,
'',
path.join(projectDirectory, TestConfig.TestAppName, 'update.zip'),
isDiff,
),
)
.then((result) => {
Expand Down Expand Up @@ -1375,35 +1369,6 @@ PluginTestingFramework.initializeTests(
// projectManager.runApplication(TestConfig.testRunDirectory, targetPlatform);
// }, false),

TestBuilder.it('localPackage.install.handlesDiff.againstBinary', false, (done: Mocha.Done) => {
ServerUtil.updateResponse = { update_info: ServerUtil.createUpdateResponse(false, targetPlatform) };

/* create an update */
setupUpdateScenario(projectManager, targetPlatform, UpdateNotifyApplicationReady, 'Diff Update 1')
.then<void>((updatePath: string) => {
ServerUtil.updatePackagePath = updatePath;
projectManager.runApplication(TestConfig.testRunDirectory, targetPlatform);
return ServerUtil.expectTestMessages([
ServerUtil.TestMessage.CHECK_UPDATE_AVAILABLE,
ServerUtil.TestMessage.DOWNLOAD_SUCCEEDED,
ServerUtil.TestMessage.DEVICE_READY_AFTER_UPDATE,
]);
})
.then<void>(() => {
/* run the app again to ensure it was not reverted */
targetPlatform.getEmulatorManager().restartApplication(TestConfig.TestNamespace);
return ServerUtil.expectTestMessages([ServerUtil.TestMessage.DEVICE_READY_AFTER_UPDATE]);
})
.done(
() => {
done();
},
(e) => {
done(e);
},
);
});

TestBuilder.it('localPackage.install.immediately', false, (done: Mocha.Done) => {
ServerUtil.updateResponse = { update_info: ServerUtil.createUpdateResponse(false, targetPlatform) };

Expand Down
Loading