diff --git a/messages/bundle_install.md b/messages/bundle_install.md index 71321c49..20e65f40 100644 --- a/messages/bundle_install.md +++ b/messages/bundle_install.md @@ -40,6 +40,10 @@ Number of minutes to wait for the installation to complete. Display extended installation detail. +# flags.installation-key.summary + +Installation key for key-protected bundle. + # requestInProgress Installing bundle. diff --git a/messages/bundle_version_create.md b/messages/bundle_version_create.md index 933ca834..d1acee0d 100644 --- a/messages/bundle_version_create.md +++ b/messages/bundle_version_create.md @@ -40,6 +40,10 @@ Version number of the package bundle version to be created; overrides the sfdx-p Description of the package bundle version. +# flags.installation-key.summary + +Installation key for key-protected bundle. + # bundleVersionCreateWaitingStatus Waiting for bundle version creation to complete. %s minutes remaining. Current status: %s diff --git a/src/commands/package/bundle/install.ts b/src/commands/package/bundle/install.ts index 25d9296c..99088531 100644 --- a/src/commands/package/bundle/install.ts +++ b/src/commands/package/bundle/install.ts @@ -53,6 +53,10 @@ export class PackageBundlesInstall extends SfCommand { expect(logStub.args[0]).to.deep.equal(['Successfully installed bundle version 1Q83i000000fxw1AAA to test@org.org']); }); + it('should install a package bundle version with installation key', async () => { + installStub = $$.SANDBOX.stub(PackageBundleInstall, 'installBundle'); + installStub.resolves(pkgBundleInstallSuccessResult); + + const cmd = new PackageBundlesInstall( + ['-b', 'TestBundle@1.0', '--target-org', 'test@org.org', '--dev-hub-org', '00D3i000000TNHYCA4', '-k', 'mySecretKey123'], + config + ); + stubSpinner(cmd); + const res = await cmd.run(); + expect(res).to.deep.equal({ + Id: '08c3i000000fylgAAA', + InstallStatus: 'Success', + PackageBundleVersionId: '1Q83i000000fxw1AAA', + DevelopmentOrganization: '00D3i000000TNHYCA4', + ValidationError: '', + CreatedDate: '2022-11-03 09:46', + CreatedById: '0053i000001ZIyGAAW', + Error: [], + }); + expect(warnStub.callCount).to.equal(0); + expect(logStub.callCount).to.equal(1); + expect(logStub.args[0]).to.deep.equal(['Successfully installed bundle version 1Q83i000000fxw1AAA to test@org.org']); + // Verify that the installBundle function was called with the installation key + expect(installStub.firstCall.args[2]).to.have.property('InstallationKey', 'mySecretKey123'); + }); + it('should handle queued status', async () => { installStub = $$.SANDBOX.stub(PackageBundleInstall, 'installBundle'); installStub.resolves(pkgBundleInstallQueuedResult); diff --git a/test/commands/bundle/packageBundleVersionCreate.test.ts b/test/commands/bundle/packageBundleVersionCreate.test.ts index c60b6c1a..8d7b99a1 100644 --- a/test/commands/bundle/packageBundleVersionCreate.test.ts +++ b/test/commands/bundle/packageBundleVersionCreate.test.ts @@ -186,6 +186,37 @@ describe('package:bundle:version:create - tests', () => { expect(logStub.args[0]).to.deep.equal(['Successfully created bundle version with ID 05i3i000000fxw1AAA']); }); + it('should create a new package bundle version with installation key', async () => { + createStub = $$.SANDBOX.stub(PackageBundleVersion, 'create'); + createStub.resolves(pkgBundleVersionCreateSuccessResult); + + const cmd = new PackageBundlesCreate( + ['-b', 'TestBundle', '-p', 'path/to/definition.json', '-k', 'mySecretKey123', '--target-dev-hub', 'test@hub.org'], + config + ); + stubSpinner(cmd); + const res = await cmd.run(); + expect(res).to.deep.equal({ + Id: '08c3i000000fylgAAA', + RequestStatus: 'Success', + PackageBundleId: '0Ho3i000000TNHYCA4', + PackageBundleVersionId: '05i3i000000fxw1AAA', + VersionName: 'TestBundle@1.0', + MajorVersion: '1', + MinorVersion: '0', + BundleVersionComponents: '[{"packageId": "0Ho3i000000TNHYCA4", "versionNumber": "1.0.0"}]', + Error: [], + CreatedDate: '2022-11-03 09:46', + CreatedById: '0053i000001ZIyGAAW', + Ancestor: null, + }); + expect(warnStub.callCount).to.equal(0); + expect(logStub.callCount).to.equal(1); + expect(logStub.args[0]).to.deep.equal(['Successfully created bundle version with ID 05i3i000000fxw1AAA']); + // Verify that the create function was called with the installation key + expect(createStub.firstCall.args[0]).to.have.property('InstallationKey', 'mySecretKey123'); + }); + it('should handle queued status', async () => { createStub = $$.SANDBOX.stub(PackageBundleVersion, 'create'); createStub.resolves(pkgBundleVersionCreateQueuedResult);