-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[v17] backport aws oidc dash (#49428)
* Add route and header for aws oidc dash (#49163) * Add OSS integration status (#49485) - Add to oss features - Move header null check to parent * Show aws summary stats on dashboard (#49516) * Navigate to aws status dash from integrations list (#49847)
- Loading branch information
1 parent
6e777d4
commit 3e94b0e
Showing
19 changed files
with
1,092 additions
and
49 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
64 changes: 64 additions & 0 deletions
64
web/packages/teleport/src/Integrations/IntegrationList.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,64 @@ | ||
/** | ||
* Teleport | ||
* Copyright (C) 2023 Gravitational, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { fireEvent, render, screen, userEvent } from 'design/utils/testing'; | ||
|
||
import { Router } from 'react-router'; | ||
|
||
import { createMemoryHistory } from 'history'; | ||
|
||
import { IntegrationList } from 'teleport/Integrations/IntegrationList'; | ||
import { | ||
IntegrationKind, | ||
IntegrationStatusCode, | ||
} from 'teleport/services/integrations'; | ||
|
||
test('integration list shows edit and view action menu for aws-oidc, row click navigates', async () => { | ||
const history = createMemoryHistory(); | ||
history.push = jest.fn(); | ||
|
||
render( | ||
<Router history={history}> | ||
<IntegrationList | ||
list={[ | ||
{ | ||
resourceType: 'integration', | ||
name: 'aws-integration', | ||
kind: IntegrationKind.AwsOidc, | ||
statusCode: IntegrationStatusCode.Running, | ||
spec: { roleArn: '', issuerS3Prefix: '', issuerS3Bucket: '' }, | ||
}, | ||
]} | ||
/> | ||
</Router> | ||
); | ||
|
||
fireEvent.click(screen.getByRole('button', { name: 'Options' })); | ||
expect(screen.getByText('View Status')).toBeInTheDocument(); | ||
expect(screen.getByText('View Status')).toHaveAttribute( | ||
'href', | ||
'/web/integrations/status/aws-oidc/aws-integration' | ||
); | ||
expect(screen.getByText('Edit...')).toBeInTheDocument(); | ||
expect(screen.getByText('Delete...')).toBeInTheDocument(); | ||
|
||
await userEvent.click(screen.getAllByRole('row')[1]); | ||
expect(history.push).toHaveBeenCalledWith( | ||
'/web/integrations/status/aws-oidc/aws-integration' | ||
); | ||
}); |
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,93 @@ | ||
/** | ||
* Teleport | ||
* Copyright (C) 2024 Gravitational, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { | ||
Integration, | ||
IntegrationStatusCode, | ||
} from 'teleport/services/integrations'; | ||
import { getStatus, getStatusAndLabel } from 'teleport/Integrations/helpers'; | ||
import { IntegrationLike, Status } from 'teleport/Integrations/IntegrationList'; | ||
|
||
test.each` | ||
type | code | expected | ||
${'integration'} | ${IntegrationStatusCode.Draft} | ${Status.Success} | ||
${'integration'} | ${IntegrationStatusCode.Running} | ${Status.Success} | ||
${'integration'} | ${IntegrationStatusCode.Unauthorized} | ${Status.Success} | ||
${'integration'} | ${IntegrationStatusCode.SlackNotInChannel} | ${Status.Success} | ||
${'integration'} | ${IntegrationStatusCode.Unknown} | ${Status.Success} | ||
${'integration'} | ${IntegrationStatusCode.OtherError} | ${Status.Success} | ||
${'external-audit-storage'} | ${IntegrationStatusCode.Draft} | ${Status.Warning} | ||
${'external-audit-storage'} | ${IntegrationStatusCode.Running} | ${Status.Success} | ||
${'external-audit-storage'} | ${IntegrationStatusCode.Unauthorized} | ${Status.Success} | ||
${'external-audit-storage'} | ${IntegrationStatusCode.SlackNotInChannel} | ${Status.Success} | ||
${'external-audit-storage'} | ${IntegrationStatusCode.Unknown} | ${Status.Success} | ||
${'external-audit-storage'} | ${IntegrationStatusCode.OtherError} | ${Status.Success} | ||
${'any'} | ${IntegrationStatusCode.Draft} | ${Status.Warning} | ||
${'any'} | ${IntegrationStatusCode.Running} | ${Status.Success} | ||
${'any'} | ${IntegrationStatusCode.Unauthorized} | ${Status.Error} | ||
${'any'} | ${IntegrationStatusCode.SlackNotInChannel} | ${Status.Warning} | ||
${'any'} | ${IntegrationStatusCode.Unknown} | ${null} | ||
${'any'} | ${IntegrationStatusCode.OtherError} | ${Status.Error} | ||
`( | ||
'getStatus type $type with code $code returns $expected', | ||
async ({ type, code, expected }) => { | ||
const item: IntegrationLike = { | ||
name: '', | ||
kind: undefined, | ||
resourceType: type, | ||
statusCode: code, | ||
}; | ||
const status = getStatus(item); | ||
expect(status).toBe(expected); | ||
} | ||
); | ||
|
||
test.each` | ||
type | code | expectedLabelKind | expectedTitle | ||
${'integration'} | ${IntegrationStatusCode.Draft} | ${'success'} | ${'Draft'} | ||
${'integration'} | ${IntegrationStatusCode.Running} | ${'success'} | ${'Running'} | ||
${'integration'} | ${IntegrationStatusCode.Unauthorized} | ${'success'} | ${'Unauthorized'} | ||
${'integration'} | ${IntegrationStatusCode.SlackNotInChannel} | ${'success'} | ${'Bot not invited to channel'} | ||
${'integration'} | ${IntegrationStatusCode.Unknown} | ${'success'} | ${'Unknown'} | ||
${'integration'} | ${IntegrationStatusCode.OtherError} | ${'success'} | ${'Unknown error'} | ||
${'external-audit-storage'} | ${IntegrationStatusCode.Draft} | ${'warning'} | ${'Draft'} | ||
${'external-audit-storage'} | ${IntegrationStatusCode.Running} | ${'success'} | ${'Running'} | ||
${'external-audit-storage'} | ${IntegrationStatusCode.Unauthorized} | ${'success'} | ${'Unauthorized'} | ||
${'external-audit-storage'} | ${IntegrationStatusCode.SlackNotInChannel} | ${'success'} | ${'Bot not invited to channel'} | ||
${'external-audit-storage'} | ${IntegrationStatusCode.Unknown} | ${'success'} | ${'Unknown'} | ||
${'external-audit-storage'} | ${IntegrationStatusCode.OtherError} | ${'success'} | ${'Unknown error'} | ||
${'any'} | ${IntegrationStatusCode.Draft} | ${'warning'} | ${'Draft'} | ||
${'any'} | ${IntegrationStatusCode.Running} | ${'success'} | ${'Running'} | ||
${'any'} | ${IntegrationStatusCode.Unauthorized} | ${'danger'} | ${'Unauthorized'} | ||
${'any'} | ${IntegrationStatusCode.SlackNotInChannel} | ${'warning'} | ${'Bot not invited to channel'} | ||
${'any'} | ${IntegrationStatusCode.Unknown} | ${'secondary'} | ${'Unknown'} | ||
${'any'} | ${IntegrationStatusCode.OtherError} | ${'danger'} | ${'Unknown error'} | ||
`( | ||
'getStatusAndLabel type $type with code $code returns expected', | ||
async ({ type, code, expectedLabelKind, expectedTitle }) => { | ||
const item: Integration = { | ||
name: '', | ||
kind: undefined, | ||
resourceType: type, | ||
statusCode: code, | ||
}; | ||
const status = getStatusAndLabel(item); | ||
expect(status.status).toBe(expectedTitle); | ||
expect(status.labelKind).toBe(expectedLabelKind); | ||
} | ||
); |
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,74 @@ | ||
/** | ||
* Teleport | ||
* Copyright (C) 2024 Gravitational, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { LabelKind } from 'design/Label'; | ||
|
||
import { | ||
getStatusCodeTitle, | ||
Integration, | ||
IntegrationStatusCode, | ||
} from 'teleport/services/integrations'; | ||
import { IntegrationLike, Status } from 'teleport/Integrations/IntegrationList'; | ||
|
||
export function getStatus(item: IntegrationLike): Status { | ||
if (item.resourceType === 'integration') { | ||
return Status.Success; | ||
} | ||
|
||
if (item.resourceType === 'external-audit-storage') { | ||
switch (item.statusCode) { | ||
case IntegrationStatusCode.Draft: | ||
return Status.Warning; | ||
default: | ||
return Status.Success; | ||
} | ||
} | ||
|
||
switch (item.statusCode) { | ||
case IntegrationStatusCode.Unknown: | ||
return null; | ||
case IntegrationStatusCode.Running: | ||
return Status.Success; | ||
case IntegrationStatusCode.SlackNotInChannel: | ||
return Status.Warning; | ||
case IntegrationStatusCode.Draft: | ||
return Status.Warning; | ||
default: | ||
return Status.Error; | ||
} | ||
} | ||
|
||
export function getStatusAndLabel(integration: Integration): { | ||
labelKind: LabelKind; | ||
status: string; | ||
} { | ||
const modifiedStatus = getStatus(integration); | ||
const statusCode = integration.statusCode; | ||
const title = getStatusCodeTitle(statusCode); | ||
|
||
switch (modifiedStatus) { | ||
case Status.Success: | ||
return { labelKind: 'success', status: title }; | ||
case Status.Error: | ||
return { labelKind: 'danger', status: title }; | ||
case Status.Warning: | ||
return { labelKind: 'warning', status: title }; | ||
default: | ||
return { labelKind: 'secondary', status: title }; | ||
} | ||
} |
Oops, something went wrong.