Skip to content

Commit

Permalink
chore: add beta warning for integration requiring manual step
Browse files Browse the repository at this point in the history
  • Loading branch information
aarlaud committed Dec 19, 2024
1 parent fb20b36 commit e6a8109
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/commands/workflows/connections/integrate.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -44,6 +44,10 @@ export default class Workflows extends BaseCommand<typeof Workflows> {
},
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,
Expand All @@ -58,7 +62,7 @@ export default class Workflows extends BaseCommand<typeof Workflows> {
this.log(
ux.colorize(
'cyan',
`Connection ${connectionIntegration.data.id} (type: ${selectedConnection.type}) integrated with integration ${integrationId} on Org ${orgId}.`,
`Connection ${selectedConnection.id} (type: ${selectedConnection.type}) integrated with integration ${connectionIntegration.data.id} on Org ${orgId}.`,
),
)
this.log(ux.colorize('red', 'Connection Integrate Workflow completed.'))
Expand Down
19 changes: 16 additions & 3 deletions test/test-utils/nock-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const deploymentId4 = '00000000-0000-0000-0000-000000000004'
export const connectionId3 = '00000000-0000-0000-0000-000000000003'
export const connectionId4 = '00000000-0000-0000-0000-000000000004'
export const integrationId3 = '3a7c1ab9-8914-4f39-a8c0-5752af653a8a'
export const integrationId4 = '00000000-0000-0000-0000-000000000004'
export const integrationId4 = '3a7c1ab9-8914-4f39-a8c0-5752af653a8b'
export const clientId = '00000000-1234-0000-0000-000000000000'
const createConnectionResponse: ConnectionResponse = {
data: {
Expand Down Expand Up @@ -430,7 +430,7 @@ export const beforeStep = () => {
required: {
key: 'value',
},
type: 'github',
type: 'nexus',
validations: [{key: 'value'}],
},
},
Expand Down Expand Up @@ -531,13 +531,26 @@ export const beforeStep = () => {
.reply((uri, body) => {
const response = apiResponseSchema
response.data = {
id: connectionId3,
id: integrationId3,
integration_type: 'github',
org_id: orgId3,
type: 'broker-integration',
}
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: integrationId4,
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`,
)
Expand Down
6 changes: 3 additions & 3 deletions test/workflows/connections/delete-after-disconnect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {expect} from 'chai'
import {stdin as fstdin} from 'mock-stdin'

import Connections from '../../../src/commands/workflows/connections/delete'
import {beforeStep, downArrow, integrationId4, orgId4, snykToken} from '../../test-utils/nock-utils'
import {beforeStep, connectionId4, downArrow, integrationId4, orgId4, snykToken} from '../../test-utils/nock-utils'
import {sendScenario} from '../../test-utils/stdin-utils'

describe('deployment workflows', () => {
Expand All @@ -25,8 +25,8 @@ describe('deployment workflows', () => {
expect(error).to.be.undefined
expect(stdout).to.contain(`Disconnecting integration ${integrationId4} in org ${orgId4}`)
expect(stdout).to.contain(`✔ Disconnected.`)
expect(stdout).to.contain(`Selected Connection ID ${integrationId4}. Ready to delete Connection.`)
expect(stdout).to.contain(`Deleting Connection ${integrationId4}`)
expect(stdout).to.contain(`Selected Connection ID ${connectionId4}. Ready to delete Connection.`)
expect(stdout).to.contain(`Deleting Connection ${connectionId4}`)
expect(stdout).to.contain(`Connection Deletion Workflow completed.`)
})
})
Original file line number Diff line number Diff line change
@@ -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.')
})
})

0 comments on commit e6a8109

Please sign in to comment.