Skip to content

Commit

Permalink
Throw new error for wrong device id, and add test to test for it
Browse files Browse the repository at this point in the history
  • Loading branch information
MilapNaik committed Mar 18, 2024
1 parent 0da4110 commit 2ad743a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
18 changes: 18 additions & 0 deletions src/RokuDeploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,24 @@ describe('index', () => {
'Unknown error signing package'
);
});

it('should return our fallback error if neither error or package link was detected', async () => {
mockDoGetRequest(`
<device-info>
<keyed-developer-id>789</keyed-developer-id>
</device-info>
`);
await expectThrowsAsync(
rokuDeploy.createSignedPackage({
host: '1.2.3.4',
password: 'password',
signingPassword: options.signingPassword,
stagingDir: stagingDir,
devId: '123'
}),
`Package signing cancelled: provided devId '123' does not match on-device devId '789'`
);
});
});

describe('prepublishToStaging', () => {
Expand Down
7 changes: 5 additions & 2 deletions src/RokuDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,11 @@ export class RokuDeploy {
let appName = parsedManifest.title + '/' + parsedManifest.major_version + '.' + parsedManifest.minor_version;

//prevent devId mismatch (if devId is specified)
if (options.devId && options.devId !== await this.getDevId()) {
throw new Error('devId mismatch. nope, not gonna sign');
if (options.devId) {
const deviceDevId = await this.getDevId();
if (options.devId !== deviceDevId) {
throw new Error(`Package signing cancelled: provided devId '${options.devId}' does not match on-device devId '${deviceDevId}'`);
}
}

let requestOptions = this.generateBaseRequestOptions('plugin_package', options as any, {
Expand Down

0 comments on commit 2ad743a

Please sign in to comment.