Skip to content

Test coverage for codesigned updates - #51

Open
ofalvai wants to merge 1 commit into
masterfrom
push-qntptxzvpzzy
Open

Test coverage for codesigned updates#51
ofalvai wants to merge 1 commit into
masterfrom
push-qntptxzvpzzy

Conversation

@ofalvai

@ofalvai ofalvai commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Why

We want to make bigger changes to the iOS package signature codepath, but integration tests don't verify codesigned updates at the moment.

What

Instead of adding a ton of new test cases for codesigned updates, this PR makes existing test cases run codesigned updates. Signature verification is an additional step during package install, we don't lose test coverage by testing codesigned updates.

Main changes:

  • A dummy keypair is checked into the repo as a test fixture
  • The test harness creates the .codepushrelease JWT token for each update package
  • Test harness also sets CodePushUpdateKey for the test apps, enabling signature checking behavior
  • Add one more integration test case for the signature mismatch scenario

Two smaller fixes are also included in this PR, surfaced by the main change:

  • The Expo config plugin (expo.js at the repo root) didn't handle the CodePushPublicKey config field, so even if users added this field to app.json, it had no effect on the Expo app prebuild.
  • The test harness was using regex string replace for Info.plist editing. It was matching the string 1.0 as a regular expression (note the dot char!), which also started matching sections of the public key, as soon as I added one to the plist. This PR replaces that fragile regex string replace logic with much simpler and stable plutil calls (this is part of macOS at /usr/bin/plutil).

@ofalvai
ofalvai requested a balanced review from Copilot September 1, 2026 12:35
Comment thread test/codesign.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds integration coverage for signed CodePush updates across native platforms.

Changes:

  • Signs generated update archives using a test RSA keypair.
  • Configures native test applications with the public key.
  • Adds a tampered-signature rejection scenario.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
test/test.ts Integrates signing and adds signature validation coverage.
test/codesign.ts Implements hashing, JWT signing, and tampering helpers.
test/fixtures/codesigning/test-public-key.pem Adds the test public key.
test/fixtures/codesigning/test-private-key.pem Adds the test private key.
Suppressed comments (1)

test/test.ts:247

  • The --expo iOS path returns from installPlatform at line 234 before this plist replacement runs. Expo iOS is a supported integration-test mode (package.json:28,33,38), so its app has no public key: signed updates are not actually verified, and the tampered-signature test will receive DOWNLOAD_SUCCEEDED rather than the expected DOWNLOAD_ERROR. Add CodePushPublicKey to the generated Expo Info.plist before that branch returns too.
                    "<key>CodePushDeploymentKey</key>\n\t<string>" + this.getDefaultDeploymentKey() + "</string>\n\t<key>CodePushServerURL</key>\n\t<string>" + this.getServerUrl() + "</string>\n\t<key>CodePushPublicKey</key>\n\t<string>" + codeSigningPublicKey + "</string>\n\t</dict>\n</plist>"))

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread test/test.ts
const string = path.join(innerprojectDirectory, "android", "app", "src", "main", "res", "values", "strings.xml");
TestUtil.replaceString(string, TestUtil.SERVER_URL_PLACEHOLDER, this.getServerUrl());
TestUtil.replaceString(string, TestUtil.ANDROID_KEY_PLACEHOLDER, this.getDefaultDeploymentKey());
TestUtil.replaceString(string, "</resources>", `<string moduleConfig="true" name="CodePushPublicKey">${codeSigningPublicKey}</string>\n</resources>`);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@ofalvai
ofalvai force-pushed the push-qntptxzvpzzy branch 2 times, most recently from 500fb6e to f01e321 Compare September 2, 2026 05:50
@ofalvai
ofalvai marked this pull request as ready for review September 2, 2026 06:28
Comment thread test/codesign.ts
@@ -0,0 +1,96 @@
"use strict";

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New file, I think it's time to start splitting up that really long test.ts

Comment thread test/codesign.ts

import { Platform, ProjectManager, ServerUtil, setupUpdateScenario, TestConfig, TestUtil } from "code-push-plugin-testing-framework";

const CODEPUSH_METADATA_FILE_NAME = ".codepushrelease";

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the next few functions are existing code, moving from test.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants