-
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.
fix(admin-ui): write test for all pages under auth-server plugin #301
- Loading branch information
Showing
5 changed files
with
169 additions
and
13 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
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
54 changes: 54 additions & 0 deletions
54
plugins/auth-server/components/Configuration/Keys/Jwks/JwksPage.test.js
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,54 @@ | ||
import React from 'react' | ||
import { render, screen } from '@testing-library/react' | ||
import JwksPage from './JwksPage' | ||
import { combineReducers, createStore } from 'redux' | ||
import { Provider } from 'react-redux' | ||
import i18n from '../../../../../../app/i18n' | ||
import { I18nextProvider } from 'react-i18next' | ||
const jwks_config = { | ||
keys: [ | ||
{ | ||
kid: 'da42021d-a00d-4c39-a3e7-828f96045269_sig_rs256', | ||
kty: 'RSA', | ||
use: 'sig', | ||
alg: 'RS256', | ||
exp: 1636569490123, | ||
x5c: [ | ||
'MIIDCTCCAfGgAwIBAgIgR4Vwlqjkzg6kyd6Hl4FzlLwfZgJJXcN7M7hX2DDOo20wDQYJKoZIhvcNAQELBQAwJDEiMCAGA1UEAwwZSmFucyBBdXRoIENBIENlcnRpZmljYXRlczAeFw0yMTExMDgxNzM4MDBaFw0yMTExMTAxODM4MTBaMCQxIjAgBgNVBAMMGUphbnMgQXV0aCBDQSBDZXJ0aWZpY2F0ZXMwggEiMA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ParVbU3ElfzuV0BQkRdi0ZArvpSeydycND94aYYeQ-WsQMJfnywRcwML0eAwA5ncdW7yEfuGoP_0Q6dg3mwpq9XshQK5sOzF67S59w', | ||
e: 'AQAB', | ||
}, | ||
], | ||
} | ||
|
||
const INIT_STATE = { | ||
jwks: jwks_config, | ||
loading: false, | ||
} | ||
const store = createStore( | ||
combineReducers({ | ||
jwksReducer: (state = INIT_STATE) => state, | ||
noReducer: (state = {}) => state, | ||
}), | ||
) | ||
|
||
const Wrapper = ({ children }) => ( | ||
<I18nextProvider i18n={i18n}> | ||
<Provider store={store}>{children}</Provider> | ||
</I18nextProvider> | ||
) | ||
|
||
it('Should render jwks page properly', () => { | ||
render(<JwksPage />, { | ||
wrapper: Wrapper, | ||
}) | ||
expect(screen.getByText(/JSON Web Keys/)).toBeInTheDocument() | ||
expect(screen.getByTestId('x5c')).toHaveValue(String(jwks_config.keys[0].x5c)) | ||
expect(screen.getByTestId('kid')).toHaveValue(jwks_config.keys[0].kid) | ||
expect(screen.getByTestId('kty')).toHaveValue(jwks_config.keys[0].kty) | ||
expect(screen.getByTestId('use')).toHaveValue(jwks_config.keys[0].use) | ||
expect(screen.getByTestId('alg')).toHaveValue(jwks_config.keys[0].alg) | ||
expect(screen.getByTestId('exp')).toHaveValue(String(jwks_config.keys[0].exp)) | ||
}) |
56 changes: 56 additions & 0 deletions
56
plugins/auth-server/components/Configuration/Keys/KeysPage.test.js
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,56 @@ | ||
import React from 'react' | ||
import { render, screen } from '@testing-library/react' | ||
import KeysPage from './KeysPage' | ||
import { combineReducers, createStore } from 'redux' | ||
import { Provider } from 'react-redux' | ||
import i18n from '../../../../../app/i18n' | ||
import { I18nextProvider } from 'react-i18next' | ||
|
||
const jwks_config = { | ||
keys: [ | ||
{ | ||
kid: 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xdqy4eFhawv+oY11zgp7wNwwOgQpgX3GekKFb2V+X/VnawOo4Pg9+KiAWQXo7SqKphPcl5jiVCrw==', | ||
], | ||
n: | ||
'mct2nzaIDwkWfyP2h4XtnbCzuqkVNP9rz7zstMvAPYAMxisfVzFmo_FySLEWN-EFJg4iu0x4YjgSlTU2-YXEpPeZbL6EOxBWhIPicZkvFrL89p_0pp6G_RXPvtV6jqkI2GXOdGXmLxUdcNVZ8BEGQ7Ox0I8m9cumrlo5JBcnzYWZRP_D_y6EUaIOIS0De-IBRTdb9NFKcMyFwNP9Wr74InZZ3Xdj5p7qhRqvczAq87hGY9VpParVbU3ElfzuV0BQkRdi0ZArvpSeydycND94aYYeQ-WsQMJfnywRcwML0eAwA5ncdW7yEfuGoP_0Q6dg3mwpq9XshQK5sOzF67S59w', | ||
e: 'AQAB', | ||
}, | ||
], | ||
} | ||
|
||
const INIT_STATE = { | ||
jwks: jwks_config, | ||
loading: false, | ||
} | ||
|
||
const store = createStore( | ||
combineReducers({ | ||
jwksReducer: (state = INIT_STATE) => state, | ||
noReducer: (state = {}) => state, | ||
}), | ||
) | ||
|
||
const Wrapper = ({ children }) => ( | ||
<I18nextProvider i18n={i18n}> | ||
<Provider store={store}>{children}</Provider> | ||
</I18nextProvider> | ||
) | ||
|
||
it('Should render keys page properly', () => { | ||
render(<KeysPage />, { | ||
wrapper: Wrapper, | ||
}) | ||
expect(screen.getByText(/JSON Web Keys/)).toBeInTheDocument() | ||
expect(screen.getByTestId('x5c')).toHaveValue(String(jwks_config.keys[0].x5c)) | ||
expect(screen.getByTestId('kid')).toHaveValue(jwks_config.keys[0].kid) | ||
expect(screen.getByTestId('kty')).toHaveValue(jwks_config.keys[0].kty) | ||
expect(screen.getByTestId('use')).toHaveValue(jwks_config.keys[0].use) | ||
expect(screen.getByTestId('alg')).toHaveValue(jwks_config.keys[0].alg) | ||
expect(screen.getByTestId('exp')).toHaveValue(String(jwks_config.keys[0].exp)) | ||
}) |