-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for IAM Identity Center shortcut links (#129)
Co-authored-by: Niall Thomson <[email protected]>
- Loading branch information
1 parent
4a4a3af
commit 2e54c29
Showing
13 changed files
with
323 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export interface Config { | ||
aws?: { | ||
sso?: { | ||
/** | ||
* @visibility frontend | ||
*/ | ||
subdomain: string; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,8 @@ | |
"msw": "^1.0.0" | ||
}, | ||
"files": [ | ||
"dist" | ||
] | ||
"dist", | ||
"config.d.ts" | ||
], | ||
"configSchema": "config.d.ts" | ||
} |
77 changes: 77 additions & 0 deletions
77
plugins/codebuild/frontend/src/components/CodeBuildProjectCard/CodeBuildProjectCard.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import React from 'react'; | ||
import { renderInTestApp, TestApiProvider } from '@backstage/test-utils'; | ||
import { CodeBuildProjectCard } from '.'; | ||
import { AwsCodeBuildApi, awsCodeBuildApiRef } from '../../api'; | ||
import { ConfigApi, configApiRef } from '@backstage/core-plugin-api'; | ||
import { ConfigReader } from '@backstage/core-app-api'; | ||
import { EntityProvider } from '@backstage/plugin-catalog-react'; | ||
import { | ||
mockCodeBuildProject, | ||
mockCodeBuildProjectBuild, | ||
mockEntityWithTags, | ||
} from '@aws/aws-codebuild-plugin-for-backstage-common'; | ||
|
||
const configApi: ConfigApi = new ConfigReader({ | ||
aws: { | ||
sso: { | ||
subdomain: 'd-123456', | ||
}, | ||
}, | ||
}); | ||
|
||
const codeBuildApiSingle: Partial<AwsCodeBuildApi> = { | ||
getProjectsByEntity: () => | ||
Promise.resolve({ | ||
projects: [ | ||
{ | ||
projectAccountId: '1234567890', | ||
projectName: 'project1', | ||
projectRegion: 'us-west-2', | ||
project: mockCodeBuildProject('project1'), | ||
builds: [mockCodeBuildProjectBuild('project1', 'test')], | ||
}, | ||
], | ||
}), | ||
}; | ||
|
||
const PROJECT_URL = `https://us-west-2.console.aws.amazon.com/codesuite/codebuild/1234567890/projects/project1/?region=us-west-2`; | ||
const SSO_PROJECT_URL = `https://d-123456.awsapps.com/start/#/console?account_id=1234567890&destination=${encodeURIComponent( | ||
PROJECT_URL, | ||
)}`; | ||
|
||
describe('<CodeBuildProjectCard />', () => { | ||
describe('for a single project', () => { | ||
it('should show project status', async () => { | ||
const rendered = await renderInTestApp( | ||
<TestApiProvider apis={[[awsCodeBuildApiRef, codeBuildApiSingle]]}> | ||
<EntityProvider entity={mockEntityWithTags}> | ||
<CodeBuildProjectCard /> | ||
</EntityProvider> | ||
</TestApiProvider>, | ||
); | ||
|
||
expect((await rendered.findByText('project1')).getAttribute('href')).toBe( | ||
PROJECT_URL, | ||
); | ||
}); | ||
|
||
it('should use sso domain', async () => { | ||
const rendered = await renderInTestApp( | ||
<TestApiProvider | ||
apis={[ | ||
[awsCodeBuildApiRef, codeBuildApiSingle], | ||
[configApiRef, configApi], | ||
]} | ||
> | ||
<EntityProvider entity={mockEntityWithTags}> | ||
<CodeBuildProjectCard /> | ||
</EntityProvider> | ||
</TestApiProvider>, | ||
); | ||
|
||
expect((await rendered.findByText('project1')).getAttribute('href')).toBe( | ||
SSO_PROJECT_URL, | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export interface Config { | ||
aws?: { | ||
sso?: { | ||
/** | ||
* @visibility frontend | ||
*/ | ||
subdomain: string; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
...depipeline/frontend/src/components/CodePipelineExecutions/CodePipelineExecutions.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import React from 'react'; | ||
import { renderInTestApp, TestApiProvider } from '@backstage/test-utils'; | ||
import { CodePipelineExecutions } from '.'; | ||
import { AwsCodePipelineApi, awsCodePipelineApiRef } from '../../api'; | ||
import { | ||
mockCodePipelineExecutions, | ||
mockEntityWithTags, | ||
} from '@aws/aws-codepipeline-plugin-for-backstage-common'; | ||
import { ConfigApi, configApiRef } from '@backstage/core-plugin-api'; | ||
import { ConfigReader } from '@backstage/core-app-api'; | ||
|
||
const configApi: ConfigApi = new ConfigReader({ | ||
aws: { | ||
sso: { | ||
subdomain: 'd-123456', | ||
}, | ||
}, | ||
}); | ||
|
||
const codePipelineApiSingle: Partial<AwsCodePipelineApi> = { | ||
getPipelineExecutionsByEntity: () => | ||
Promise.resolve({ | ||
pipelineExecutions: [ | ||
{ | ||
pipelineName: 'pipeline1', | ||
pipelineRegion: 'us-west-2', | ||
pipelineArn: 'arn:aws:codepipeline:us-west-2:1234567890:pipeline1', | ||
pipelineExecutions: mockCodePipelineExecutions(), | ||
}, | ||
], | ||
}), | ||
}; | ||
|
||
const codePipelineApiMultiple: Partial<AwsCodePipelineApi> = { | ||
getPipelineExecutionsByEntity: () => | ||
Promise.resolve({ | ||
pipelineExecutions: [ | ||
{ | ||
pipelineName: 'pipeline1', | ||
pipelineRegion: 'us-west-2', | ||
pipelineArn: 'arn:aws:codepipeline:us-west-2:1234567890:pipeline1', | ||
pipelineExecutions: mockCodePipelineExecutions(), | ||
}, | ||
{ | ||
pipelineName: 'pipeline2', | ||
pipelineRegion: 'us-west-2', | ||
pipelineArn: 'arn:aws:codepipeline:us-west-2:1234567890:pipeline2', | ||
pipelineExecutions: mockCodePipelineExecutions(), | ||
}, | ||
], | ||
}), | ||
}; | ||
|
||
const EXECUTION_ID = 'e6c91a02-d844-4663-ad62-b719608f8fc5'; | ||
|
||
const CONSOLE_URL = `https://us-west-2.console.aws.amazon.com/codesuite/codepipeline/pipelines/pipeline1/executions/${EXECUTION_ID}/timeline?region=us-west-2`; | ||
const SSO_CONSOLE_URL = `https://d-123456.awsapps.com/start/#/console?account_id=1234567890&destination=${encodeURIComponent( | ||
CONSOLE_URL, | ||
)}`; | ||
|
||
describe('<CodePipelineExecutions />', () => { | ||
describe('for a single pipeline', () => { | ||
it('should show latest executions', async () => { | ||
const rendered = await renderInTestApp( | ||
<TestApiProvider | ||
apis={[[awsCodePipelineApiRef, codePipelineApiSingle]]} | ||
> | ||
<CodePipelineExecutions entity={mockEntityWithTags} /> | ||
</TestApiProvider>, | ||
); | ||
|
||
expect(await rendered.findByText(EXECUTION_ID)).toBeInTheDocument(); | ||
expect( | ||
await rendered.queryByTestId('select-pipeline'), | ||
).not.toBeInTheDocument(); | ||
expect( | ||
(await rendered.findByText(EXECUTION_ID)).getAttribute('href'), | ||
).toBe(CONSOLE_URL); | ||
}); | ||
|
||
it('should use sso domain', async () => { | ||
const rendered = await renderInTestApp( | ||
<TestApiProvider | ||
apis={[ | ||
[awsCodePipelineApiRef, codePipelineApiSingle], | ||
[configApiRef, configApi], | ||
]} | ||
> | ||
<CodePipelineExecutions entity={mockEntityWithTags} /> | ||
</TestApiProvider>, | ||
); | ||
|
||
expect(await rendered.findByText(EXECUTION_ID)).toBeInTheDocument(); | ||
expect( | ||
await rendered.queryByTestId('select-pipeline'), | ||
).not.toBeInTheDocument(); | ||
expect( | ||
(await rendered.findByText(EXECUTION_ID)).getAttribute('href'), | ||
).toBe(SSO_CONSOLE_URL); | ||
}); | ||
}); | ||
|
||
describe('for multiple pipelines', () => { | ||
it('should show latest executions', async () => { | ||
const rendered = await renderInTestApp( | ||
<TestApiProvider | ||
apis={[[awsCodePipelineApiRef, codePipelineApiMultiple]]} | ||
> | ||
<CodePipelineExecutions entity={mockEntityWithTags} /> | ||
</TestApiProvider>, | ||
); | ||
|
||
expect(await rendered.findByText(EXECUTION_ID)).toBeInTheDocument(); | ||
expect( | ||
await rendered.queryByTestId('select-pipeline'), | ||
).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.