Skip to content

Commit

Permalink
fix(admin-ui): write test for Openid connect client pages #295
Browse files Browse the repository at this point in the history
  • Loading branch information
syntrydy committed Nov 8, 2021
1 parent 4f3538d commit 82e3b8f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 248 deletions.
10 changes: 1 addition & 9 deletions plugins/auth-server/components/Clients/ClientAddPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ const INIT_STATE = {
config: {},
backendIsUp: true,
}

const INIT_CLIENTS_STATE = {
items: [],
item: {},
view: false,
loading: false,
}

const INIT_SCPOPES_STATE = {
items: [
{
Expand Down Expand Up @@ -75,7 +67,7 @@ const Wrapper = ({ children }) => (
)
const emptyArray = []

it('Should show the sidebar properly', () => {
it('Should he client add page properly', () => {
render(
<ClientAddPage
scopes={scopes}
Expand Down
56 changes: 4 additions & 52 deletions plugins/auth-server/components/Clients/ClientDetailPage.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import { render, screen } from '@testing-library/react'
import ClientDetailPage from './ClientDetailPage'
import clients from './clients'
import i18n from '../../../../app/i18n'
import { I18nextProvider } from 'react-i18next'

Expand All @@ -12,62 +13,13 @@ const permissions = [
'https://jans.io/oauth/config/openid/clients.write',
'https://jans.io/oauth/config/openid/clients.delete',
]
const row = {
applicationType: 'web',
includeClaimsInIdToken: false,
dn: 'inum=2073c8e7-1060-4c09-b0f6-7d46fb6ff8f5,ou=clients,o=jans',
inum: '2073c8e7-1060-4c09-b0f6-7d46fb6ff8f5',
clientSecret: '92bc4d8e-2f4c-4a4d-80ae-1e4eb1f5f463',
frontChannelLogoutUri: 'http://localhost:4100/logout',
frontChannelLogoutSessionRequired: false,
registrationAccessToken: 'de5aaa9c-d6b4-44a1-912f-40c97063544a',
clientIdIssuedAt: '2021-07-28T06:35:09.000Z',
redirectUris: [
'http://localhost:4100',
'https://admin-ui-test.gluu.org/admin',
],
responseTypes: ['code'],
grantTypes: ['authorization_code', 'refresh_token', 'client_credentials'],
clientName: 'admin-ui',
subjectType: 'pairwise',
idTokenSignedResponseAlg: 'RS256',
userInfoSignedResponseAlg: 'RS256',
tokenEndpointAuthMethod: 'client_secret_basic',
requireAuthTime: false,
defaultAcrValues: ['simple_password_auth'],
postLogoutRedirectUris: [
'http://localhost:4100',
'https://admin-ui-test.gluu.org/admin',
],
scopes: [
'inum=F0C4,ou=scopes,o=jans',
'inum=6D90,ou=scopes,o=jans',
'inum=43F1,ou=scopes,o=jans',
],
trustedClient: false,
lastAccessTime: '2021-07-28T06:35:09.000Z',
lastLogonTime: '2021-07-28T06:35:09.000Z',
persistClientAuthorizations: true,
customAttributes: [],
customObjectClasses: ['top'],
rptAsJwt: false,
accessTokenAsJwt: true,
accessTokenSigningAlg: 'RS256',
disabled: false,
attributes: {
runIntrospectionScriptBeforeAccessTokenAsJwtCreationAndIncludeClaims: false,
keepClientAuthorizationAfterExpiration: false,
allowSpontaneousScopes: false,
backchannelLogoutSessionRequired: false,
},
deletable: false,
}
const row = clients[0]
it('Should the client detail page properly properly', () => {
render(<ClientDetailPage row={row} scopes={permissions} />, {
wrapper: Wrapper,
})
screen.getByText(/2073c8e7-1060-4c09-b0f6-7d46fb6ff8f5/)
screen.getByText('admin-ui')
screen.getByText(/1801.a0beec01-617b-4607-8a35-3e46ac43deb5/)
screen.getByText('Jans Config Api Client')
screen.getByText('pairwise')
screen.getByText(/The openid connect client name/)
})
126 changes: 3 additions & 123 deletions plugins/auth-server/components/Clients/ClientEditPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { combineReducers } from 'redux'
import { BrowserRouter as Router } from 'react-router-dom'
import { createStore } from 'redux'
import { Provider } from 'react-redux'
import clients from './clients'
import i18n from '../../../../app/i18n'
import { I18nextProvider } from 'react-i18next'
import authReducer from '../../../../app/redux/reducers/AuthReducer'
Expand All @@ -31,129 +32,8 @@ const INIT_STATE = {
}

const INIT_CLIENTS_STATE = {
items: [
{
applicationType: 'web',
includeClaimsInIdToken: false,
dn: 'inum=2073c8e7-1060-4c09-b0f6-7d46fb6ff8f5,ou=clients,o=jans',
inum: '2073c8e7-1060-4c09-b0f6-7d46fb6ff8f5',
clientSecret: '92bc4d8e-2f4c-4a4d-80ae-1e4eb1f5f463',
frontChannelLogoutUri: 'http://localhost:4100/logout',
frontChannelLogoutSessionRequired: false,
registrationAccessToken: 'de5aaa9c-d6b4-44a1-912f-40c97063544a',
clientIdIssuedAt: '2021-07-28T06:35:09.000Z',
redirectUris: [
'http://localhost:4100',
'https://admin-ui-test.gluu.org/admin',
],
responseTypes: ['code'],
grantTypes: ['authorization_code', 'refresh_token', 'client_credentials'],
clientName: 'admin-ui',
subjectType: 'pairwise',
idTokenSignedResponseAlg: 'RS256',
userInfoSignedResponseAlg: 'RS256',
tokenEndpointAuthMethod: 'client_secret_basic',
requireAuthTime: false,
defaultAcrValues: ['simple_password_auth'],
postLogoutRedirectUris: [
'http://localhost:4100',
'https://admin-ui-test.gluu.org/admin',
],
scopes: [
'inum=F0C4,ou=scopes,o=jans',
'inum=6D90,ou=scopes,o=jans',
'inum=43F1,ou=scopes,o=jans',
],
trustedClient: false,
lastAccessTime: '2021-07-28T06:35:09.000Z',
lastLogonTime: '2021-07-28T06:35:09.000Z',
persistClientAuthorizations: true,
customAttributes: [],
customObjectClasses: ['top'],
rptAsJwt: false,
accessTokenAsJwt: true,
accessTokenSigningAlg: 'RS256',
disabled: false,
attributes: {
runIntrospectionScriptBeforeAccessTokenAsJwtCreationAndIncludeClaims: false,
keepClientAuthorizationAfterExpiration: false,
allowSpontaneousScopes: false,
backchannelLogoutSessionRequired: false,
},
deletable: false,
},
],
item: {
applicationType: 'web',
includeClaimsInIdToken: false,
dn: 'inum=2073c8e7-1060-4c09-b0f6-7d46fb6ff8f5,ou=clients,o=jans',
inum: '2073c8e7-1060-4c09-b0f6-7d46fb6ff8f5',
clientSecret: '92bc4d8e-2f4c-4a4d-80ae-1e4eb1f5f463',
frontChannelLogoutUri: 'http://localhost:4100/logout',
frontChannelLogoutSessionRequired: false,
registrationAccessToken: 'de5aaa9c-d6b4-44a1-912f-40c97063544a',
clientIdIssuedAt: '2021-07-28T06:35:09.000Z',
redirectUris: [
'http://localhost:4100',
'https://admin-ui-test.gluu.org/admin',
],
responseTypes: ['code'],
grantTypes: ['authorization_code', 'refresh_token', 'client_credentials'],
clientName: 'admin-ui',
subjectType: 'pairwise',
idTokenSignedResponseAlg: 'RS256',
userInfoSignedResponseAlg: 'RS256',
tokenEndpointAuthMethod: 'client_secret_basic',
requireAuthTime: false,
defaultAcrValues: ['simple_password_auth'],
postLogoutRedirectUris: [
'http://localhost:4100',
'https://admin-ui-test.gluu.org/admin',
],
scopes: [
'inum=F0C4,ou=scopes,o=jans',
'inum=6D90,ou=scopes,o=jans',
'inum=43F1,ou=scopes,o=jans',
],
trustedClient: false,
lastAccessTime: '2021-07-28T06:35:09.000Z',
lastLogonTime: '2021-07-28T06:35:09.000Z',
persistClientAuthorizations: true,
customAttributes: [],
customObjectClasses: ['top'],
rptAsJwt: false,
accessTokenAsJwt: true,
accessTokenSigningAlg: 'RS256',
disabled: false,
attributes: {
runIntrospectionScriptBeforeAccessTokenAsJwtCreationAndIncludeClaims: false,
keepClientAuthorizationAfterExpiration: false,
allowSpontaneousScopes: false,
backchannelLogoutSessionRequired: false,
},
deletable: false,
},
view: false,
loading: false,
}

const INIT_SCPOPES_STATE = {
items: [
{
id: 'https://jans.io/oauth/config/smtp.delete',
scopeType: 'oauth',
dn: 'inum=1800.85A227,ou=scopes,o=jans',
inum: '1800.85A227',
displayName: 'Config API scope https://jans.io/oauth/config/smtp.delete',
description: 'Delete SMTP related information',
defaultScope: false,
attributes: { showInConfigurationEndpoint: false },
umaType: false,
tableData: { id: 0 },
},
],
item: {},
loading: false,
items: [clients[0]],
item: clients[0],
}
const store = createStore(
combineReducers({
Expand Down
66 changes: 2 additions & 64 deletions plugins/auth-server/components/Clients/ClientListPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { BrowserRouter as Router } from 'react-router-dom'
import { createStore } from 'redux'
import { Provider } from 'react-redux'
import i18n from '../../../../app/i18n'
import clients from './clients'
import { I18nextProvider } from 'react-i18next'
import authReducer from '../../../../app/redux/reducers/AuthReducer'
import oidcReducer from '../../redux/reducers/OIDCReducer'
Expand All @@ -29,58 +30,7 @@ const INIT_STATE = {
}

const INIT_CLIENTS_STATE = {
items: [
{
applicationType: 'web',
includeClaimsInIdToken: false,
dn: 'inum=2073c8e7-1060-4c09-b0f6-7d46fb6ff8f5,ou=clients,o=jans',
inum: '2073c8e7-1060-4c09-b0f6-7d46fb6ff8f5',
clientSecret: '92bc4d8e-2f4c-4a4d-80ae-1e4eb1f5f463',
frontChannelLogoutUri: 'http://localhost:4100/logout',
frontChannelLogoutSessionRequired: false,
registrationAccessToken: 'de5aaa9c-d6b4-44a1-912f-40c97063544a',
clientIdIssuedAt: '2021-07-28T06:35:09.000Z',
redirectUris: [
'http://localhost:4100',
'https://admin-ui-test.gluu.org/admin',
],
responseTypes: ['code'],
grantTypes: ['authorization_code', 'refresh_token', 'client_credentials'],
clientName: 'admin-ui',
subjectType: 'pairwise',
idTokenSignedResponseAlg: 'RS256',
userInfoSignedResponseAlg: 'RS256',
tokenEndpointAuthMethod: 'client_secret_basic',
requireAuthTime: false,
defaultAcrValues: ['simple_password_auth'],
postLogoutRedirectUris: [
'http://localhost:4100',
'https://admin-ui-test.gluu.org/admin',
],
scopes: [
'inum=F0C4,ou=scopes,o=jans',
'inum=6D90,ou=scopes,o=jans',
'inum=43F1,ou=scopes,o=jans',
],
trustedClient: false,
lastAccessTime: '2021-07-28T06:35:09.000Z',
lastLogonTime: '2021-07-28T06:35:09.000Z',
persistClientAuthorizations: true,
customAttributes: [],
customObjectClasses: ['top'],
rptAsJwt: false,
accessTokenAsJwt: true,
accessTokenSigningAlg: 'RS256',
disabled: false,
attributes: {
runIntrospectionScriptBeforeAccessTokenAsJwtCreationAndIncludeClaims: false,
keepClientAuthorizationAfterExpiration: false,
allowSpontaneousScopes: false,
backchannelLogoutSessionRequired: false,
},
deletable: false,
},
],
items: [clients[0]],
item: {},
view: false,
loading: false,
Expand All @@ -100,18 +50,6 @@ const INIT_SCPOPES_STATE = {
umaType: false,
tableData: { id: 0 },
},
{
id: 'openid',
scopeType: 'openid',
dn: 'inum=F0C4,ou=scopes,o=jans',
inum: 'F0C4',
displayName: 'authenticate_openid_connect',
description: 'Authenticate using OpenID Connect.',
defaultScope: true,
attributes: { showInConfigurationEndpoint: true },
umaType: false,
tableData: { id: 1 },
},
],
item: {},
loading: false,
Expand Down

0 comments on commit 82e3b8f

Please sign in to comment.