Test coverage for codesigned updates - #51
Conversation
There was a problem hiding this comment.
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
--expoiOS path returns frominstallPlatformat 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 receiveDOWNLOAD_SUCCEEDEDrather than the expectedDOWNLOAD_ERROR. AddCodePushPublicKeyto 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.
| 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>`); |
500fb6e to
f01e321
Compare
f01e321 to
c177c00
Compare
| @@ -0,0 +1,96 @@ | |||
| "use strict"; | |||
There was a problem hiding this comment.
New file, I think it's time to start splitting up that really long test.ts
|
|
||
| import { Platform, ProjectManager, ServerUtil, setupUpdateScenario, TestConfig, TestUtil } from "code-push-plugin-testing-framework"; | ||
|
|
||
| const CODEPUSH_METADATA_FILE_NAME = ".codepushrelease"; |
There was a problem hiding this comment.
This and the next few functions are existing code, moving from test.ts
| "CodePushDeploymentKey": "mock-ios-deployment-key", | ||
| "CodePushServerURL": "http://127.0.0.1:3000" | ||
| "CodePushServerURL": "http://127.0.0.1:3000", | ||
| "CodePushPublicKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApZtuvtGcQmmeUh81n/jA\njeDkktkX1QryINqRZrcoofjw+w89FdW3XxQOhsjIJLr5u0xqjHde6Hzpx9sbcUGi\nvmW1O0HBuCsAeiVHyiTq/t+sEiKP0VZa1mbnSM3EEQl09Si3NpLs4sHK+uvttLT3\nKEZy+Zhx54gaM5iz7ErqavpDADaWDWplIXUK/D/pQulbM1oM+04V1XkKw5bBqEHT\ni6Whq/YUPWs2+7KXyLnvKyO+33YFWnHhHGbGkGLYE02sAGonYgaP220vJ4lnwLx0\nOcEagfdlM8YwfyOUSWn7LB0VCJazltDiuM1ZhL1rDA8d0rHZvtxKJDLz3uIRuppj\n7wIDAQAB\n-----END PUBLIC KEY-----" |
There was a problem hiding this comment.
Can't we read these from a .env file so the public key doesn't have to be duplicated? Or is that overkill for testing?
There was a problem hiding this comment.
Possible, but this JSON file would have to be converted to TS. I'll take a look at how complex this would be.
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:
.codepushreleaseJWT token for each update packageCodePushUpdateKeyfor the test apps, enabling signature checking behaviorTwo smaller fixes are also included in this PR, surfaced by the main change:
expo.jsat the repo root) didn't handle theCodePushPublicKeyconfig field, so even if users added this field toapp.json, it had no effect on the Expo app prebuild.Info.plistediting. It was matching the string1.0as 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 stableplutilcalls (this is part of macOS at/usr/bin/plutil).