-
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.
- Loading branch information
1 parent
dd7e49f
commit cf18b6f
Showing
9 changed files
with
276 additions
and
131 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
57 changes: 0 additions & 57 deletions
57
web/packages/teleport/src/Integrations/status/AwsOidc/Details/Ec2.tsx
This file was deleted.
Oops, something went wrong.
56 changes: 0 additions & 56 deletions
56
web/packages/teleport/src/Integrations/status/AwsOidc/Details/Eks.tsx
This file was deleted.
Oops, something went wrong.
111 changes: 111 additions & 0 deletions
111
web/packages/teleport/src/Integrations/status/AwsOidc/Details/Rules.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,111 @@ | ||
/** | ||
* 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 { render, screen, waitFor } from 'design/utils/testing'; | ||
import React from 'react'; | ||
|
||
import { MemoryRouter } from 'react-router'; | ||
|
||
import { within } from '@testing-library/react'; | ||
|
||
import { Rules } from 'teleport/Integrations/status/AwsOidc/Details/Rules'; | ||
import { | ||
IntegrationDiscoveryRule, | ||
integrationService, | ||
} from 'teleport/services/integrations'; | ||
|
||
test('renders region & labels from response', async () => { | ||
jest.spyOn(integrationService, 'fetchIntegrationRules').mockResolvedValue({ | ||
rules: [ | ||
makeIntegrationDiscoveryRule({ | ||
region: 'us-west-2', | ||
labelMatcher: [ | ||
{ name: 'env', value: 'prod' }, | ||
{ name: 'key', value: '123' }, | ||
], | ||
}), | ||
makeIntegrationDiscoveryRule({ | ||
region: 'us-east-2', | ||
labelMatcher: [{ name: 'env', value: 'stage' }], | ||
}), | ||
makeIntegrationDiscoveryRule({ | ||
region: 'us-west-1', | ||
labelMatcher: [{ name: 'env', value: 'test' }], | ||
}), | ||
makeIntegrationDiscoveryRule({ | ||
region: 'us-east-1', | ||
labelMatcher: [{ name: 'env', value: 'dev' }], | ||
}), | ||
], | ||
nextKey: '', | ||
}); | ||
render( | ||
<MemoryRouter | ||
initialEntries={[ | ||
`/web/integrations/status/aws-oidc/some-name/resources/eks`, | ||
]} | ||
> | ||
<Rules /> | ||
</MemoryRouter> | ||
); | ||
|
||
await waitFor(() => { | ||
expect(screen.getByText('env:prod')).toBeInTheDocument(); | ||
}); | ||
|
||
expect(getTableCellContents()).toEqual({ | ||
header: ['Region', 'Labels'], | ||
rows: [ | ||
['us-west-1', 'env:test'], | ||
['us-east-1', 'env:dev'], | ||
['us-west-2', 'env:prodkey:123'], | ||
['us-east-2', 'env:stage'], | ||
], | ||
}); | ||
|
||
jest.clearAllMocks(); | ||
}); | ||
|
||
function makeIntegrationDiscoveryRule( | ||
overrides: Partial<IntegrationDiscoveryRule> = {} | ||
): IntegrationDiscoveryRule { | ||
return Object.assign( | ||
{ | ||
resourceType: '', | ||
region: '', | ||
labelMatcher: [], | ||
discoveryConfig: '', | ||
lastSync: 0, | ||
}, | ||
overrides | ||
); | ||
} | ||
|
||
function getTableCellContents() { | ||
const [header, ...rows] = screen.getAllByRole('row'); | ||
return { | ||
header: within(header) | ||
.getAllByRole('columnheader') | ||
.map(cell => cell.textContent), | ||
rows: rows.map(row => | ||
within(row) | ||
.getAllByRole('cell') | ||
.map(cell => cell.textContent) | ||
), | ||
}; | ||
} |
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
Oops, something went wrong.