From dbe8d978465f7da830c6960b7825daf38c257932 Mon Sep 17 00:00:00 2001 From: Antoine Arlaud Date: Thu, 19 Dec 2024 22:17:51 +0100 Subject: [PATCH] chore: add beta warning for integration requiring manual step --- .../workflows/connections/integrate.ts | 8 +++-- test/test-utils/nock-utils.ts | 15 ++++++++- .../integrate-non-source-integration.test.ts | 31 +++++++++++++++++++ 3 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 test/workflows/connections/integrate-non-source-integration.test.ts diff --git a/src/commands/workflows/connections/integrate.ts b/src/commands/workflows/connections/integrate.ts index 4acbdd6..815856d 100644 --- a/src/commands/workflows/connections/integrate.ts +++ b/src/commands/workflows/connections/integrate.ts @@ -1,6 +1,6 @@ import {ux} from '@oclif/core' import {commonApiRelatedArgs} from '../../../common/args.js' -import {input} from '@inquirer/prompts' +import {confirm, input} from '@inquirer/prompts' import {BaseCommand} from '../../../base-command.js' import {nonSourceIntegrations} from '../../../command-helpers/connections/type-params-mapping.js' import {createIntegrationForConnection} from '../../../api/integrations.js' @@ -44,6 +44,10 @@ export default class Workflows extends BaseCommand { }, ValidationType.UUID, ) + } else { + await confirm({ + message: `During Universal Broker Early Access, the ${selectedConnection.type}-typed integration must first be manually Brokered via the UI. Have you manually brokered the connection?`, + }) } const connectionIntegration = await createIntegrationForConnection( tenantId, @@ -58,7 +62,7 @@ export default class Workflows extends BaseCommand { this.log( ux.colorize( 'cyan', - `Connection ${connectionIntegration.data.id} (type: ${selectedConnection.type}) integrated with integration ${integrationId} on Org ${orgId}.`, + `Connection ${connectionIntegration.data.id} (type: ${selectedConnection.type}) integrated with integration ${connectionIntegration.data.id} on Org ${orgId}.`, ), ) this.log(ux.colorize('red', 'Connection Integrate Workflow completed.')) diff --git a/test/test-utils/nock-utils.ts b/test/test-utils/nock-utils.ts index 54b9ea9..a0307f9 100644 --- a/test/test-utils/nock-utils.ts +++ b/test/test-utils/nock-utils.ts @@ -430,7 +430,7 @@ export const beforeStep = () => { required: { key: 'value', }, - type: 'github', + type: 'nexus', validations: [{key: 'value'}], }, }, @@ -538,6 +538,19 @@ export const beforeStep = () => { } return [201, response] }) + .post( + `${urlPrefixTenantId}/brokers/connections/${connectionId4}/orgs/${orgId4}/integration?version=2024-02-08~experimental`, + ) + .reply((uri, body) => { + const response = apiResponseSchema + response.data = { + id: connectionId4, + integration_type: 'nexus', + org_id: orgId4, + type: 'broker-integration', + } + return [201, response] + }) .patch( `${urlPrefixTenantIdAndInstallId}/deployments/00000000-0000-0000-0000-000000000000/connections/00000000-0000-0000-0000-000000000000?version=2024-02-08~experimental`, ) diff --git a/test/workflows/connections/integrate-non-source-integration.test.ts b/test/workflows/connections/integrate-non-source-integration.test.ts new file mode 100644 index 0000000..ee85c10 --- /dev/null +++ b/test/workflows/connections/integrate-non-source-integration.test.ts @@ -0,0 +1,31 @@ +import {captureOutput} from '@oclif/test' +import {expect} from 'chai' +import {stdin as fstdin} from 'mock-stdin' + +import Connections from '../../../src/commands/workflows/connections/integrate' +import {beforeStep, connectionId4, integrationId4, orgId4, snykToken} from '../../test-utils/nock-utils' +import {sendScenario} from '../../test-utils/stdin-utils' + +describe('deployment workflows', () => { + const stdin = fstdin() + before(beforeStep) + + it('runs workflow deployment create', async () => { + // @ts-ignore + const cfg: Config = {} + const integrateConnection = new Connections([], cfg) + const {stdout, stderr, error} = await captureOutput( + async () => { + sendScenario(stdin, [snykToken, 'n', orgId4, orgId4, orgId4, 'y']) + return integrateConnection.run() + }, + {print: false}, + ) + + expect(stdout).to.contain( + `Connection ${connectionId4} (type: nexus) integrated with integration ${integrationId4} on Org ${orgId4}.`, + ) + expect(error).to.be.undefined + expect(stdout).to.contain('Connection Integrate Workflow completed.') + }) +})