Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display current filters #81

Merged
merged 10 commits into from
Mar 13, 2024
Prev Previous commit
Next Next commit
Rename GrantTypes to make singular
thomasridd committed Feb 29, 2024
commit 0d8044bd643d1953880757db5412c8f3f599514f
6 changes: 3 additions & 3 deletions integration_tests/e2e/edit-base-client-deployment.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Page from '../pages/page'
import ViewBaseClientPage from '../pages/viewBaseClient'
import EditBaseClientDeploymentDetailsPage from '../pages/editBaseClientDeploymentDetails'
import { GrantTypes } from '../../server/data/enums/grantTypes'
import { GrantType } from '../../server/data/enums/grantType'
import AuthSignInPage from '../pages/authSignIn'
import AuthErrorPage from '../pages/authError'

@@ -16,7 +16,7 @@ context('Edit base client deployment: Auth', () => {
cy.task('stubSignIn')
cy.task('stubManageUser')
cy.task('stubListBaseClients')
cy.task('stubGetBaseClient', { grantType: GrantTypes.ClientCredentials })
cy.task('stubGetBaseClient', { grantType: GrantType.ClientCredentials })
cy.task('stubGetListClientInstancesList')
})

@@ -41,7 +41,7 @@ context('Edit base client deployment details page', () => {
cy.task('stubSignIn')
cy.task('stubManageUser')
cy.task('stubListBaseClients')
cy.task('stubGetBaseClient', { grantType: GrantTypes.ClientCredentials })
cy.task('stubGetBaseClient', { grantType: GrantType.ClientCredentials })
cy.task('stubGetListClientInstancesList')
editBaseClientDeploymentDetailsPage = visitEditBaseClientDeploymentDetailsPage()
})
8 changes: 4 additions & 4 deletions integration_tests/e2e/edit-base-client-details.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Page from '../pages/page'
import EditBaseClientDetailsPage from '../pages/editBaseClientDetails'
import ViewBaseClientPage from '../pages/viewBaseClient'
import { GrantTypes } from '../../server/data/enums/grantTypes'
import { GrantType } from '../../server/data/enums/grantType'
import AuthSignInPage from '../pages/authSignIn'
import AuthErrorPage from '../pages/authError'

@@ -16,7 +16,7 @@ context('Edit base client details: Auth', () => {
cy.task('stubSignIn')
cy.task('stubManageUser')
cy.task('stubListBaseClients')
cy.task('stubGetBaseClient', { grantType: GrantTypes.ClientCredentials })
cy.task('stubGetBaseClient', { grantType: GrantType.ClientCredentials })
cy.task('stubGetListClientInstancesList')
})

@@ -41,7 +41,7 @@ context('Edit base client details page - client-credentials flow', () => {
cy.task('stubSignIn')
cy.task('stubManageUser')
cy.task('stubListBaseClients')
cy.task('stubGetBaseClient', { grantType: GrantTypes.ClientCredentials })
cy.task('stubGetBaseClient', { grantType: GrantType.ClientCredentials })
cy.task('stubGetListClientInstancesList')
cy.task('stubAuthManageDetails')
editBaseClientDetailsPage = visitEditBaseClientDetailsPage()
@@ -126,7 +126,7 @@ context('Edit base client details page - authorization-code flow', () => {
cy.task('stubSignIn')
cy.task('stubManageUser')
cy.task('stubListBaseClients')
cy.task('stubGetBaseClient', { grantType: GrantTypes.AuthorizationCode })
cy.task('stubGetBaseClient', { grantType: GrantType.AuthorizationCode })
cy.task('stubGetListClientInstancesList')
editBaseClientDetailsPage = visitEditBaseClientDetailsPage()
})
4 changes: 2 additions & 2 deletions integration_tests/e2e/edit-client-instances.cy.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import Page from '../pages/page'
import ViewBaseClientPage from '../pages/viewBaseClient'
import ViewClientSecretsPage from '../pages/viewClientSecrets'
import ConfirmDeleteClientPage from '../pages/confirmDeleteClient'
import { GrantTypes } from '../../server/data/enums/grantTypes'
import { GrantType } from '../../server/data/enums/grantType'

const visitBaseClientPage = (): ViewBaseClientPage => {
cy.signIn({ failOnStatusCode: true, redirectPath: '/base-clients/base_client_id_1' })
@@ -21,7 +21,7 @@ context('Base client page - client instances', () => {
beforeEach(() => {
cy.task('reset')
cy.task('stubSignIn')
cy.task('stubGetBaseClient', { grantType: GrantTypes.ClientCredentials })
cy.task('stubGetBaseClient', { grantType: GrantType.ClientCredentials })
cy.task('stubManageUser')
cy.task('stubGetListClientInstancesList')
})
4 changes: 2 additions & 2 deletions integration_tests/e2e/login.cy.ts
Original file line number Diff line number Diff line change
@@ -2,15 +2,15 @@ import IndexPage from '../pages/index'
import AuthSignInPage from '../pages/authSignIn'
import Page from '../pages/page'
import AuthManageDetailsPage from '../pages/authManageDetails'
import { GrantTypes } from '../../server/data/enums/grantTypes'
import { GrantType } from '../../server/data/enums/grantType'
import AuthErrorPage from '../pages/authError'

context('SignIn', () => {
beforeEach(() => {
cy.task('reset')
cy.task('stubSignIn', ['ROLE_OAUTH_ADMIN'])
cy.task('stubListBaseClients')
cy.task('stubGetBaseClient', { grantType: GrantTypes.ClientCredentials })
cy.task('stubGetBaseClient', { grantType: GrantType.ClientCredentials })
cy.task('stubManageUser')
cy.task('stubAuthManageDetails')
})
6 changes: 3 additions & 3 deletions integration_tests/e2e/view-base-client-list.cy.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import Page from '../pages/page'
import ViewBaseClientListPage from '../pages/viewBaseClientList'
import ViewBaseClientPage from '../pages/viewBaseClient'
import NewBaseClientGrantPage from '../pages/newBaseClientGrant'
import { GrantTypes } from '../../server/data/enums/grantTypes'
import { GrantType } from '../../server/data/enums/grantType'
import AuthSignInPage from '../pages/authSignIn'
import AuthErrorPage from '../pages/authError'

@@ -17,7 +17,7 @@ context('Homepage - Auth', () => {
cy.task('reset')
cy.task('stubSignIn')
cy.task('stubListBaseClients')
cy.task('stubGetBaseClient', { grantType: GrantTypes.ClientCredentials })
cy.task('stubGetBaseClient', { grantType: GrantType.ClientCredentials })
cy.task('stubManageUser')
cy.task('stubGetListClientInstancesList')
})
@@ -42,7 +42,7 @@ context('Homepage - list base-clients', () => {
cy.task('reset')
cy.task('stubSignIn')
cy.task('stubListBaseClients')
cy.task('stubGetBaseClient', { grantType: GrantTypes.ClientCredentials })
cy.task('stubGetBaseClient', { grantType: GrantType.ClientCredentials })
cy.task('stubManageUser')
cy.task('stubGetListClientInstancesList')

8 changes: 4 additions & 4 deletions integration_tests/e2e/view-base-client.cy.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import ViewClientSecretsPage from '../pages/viewClientSecrets'
import ConfirmDeleteClientPage from '../pages/confirmDeleteClient'
import EditBaseClientDetailsPage from '../pages/editBaseClientDetails'
import EditBaseClientDeploymentDetailsPage from '../pages/editBaseClientDeploymentDetails'
import { GrantTypes } from '../../server/data/enums/grantTypes'
import { GrantType } from '../../server/data/enums/grantType'
import AuthSignInPage from '../pages/authSignIn'
import AuthErrorPage from '../pages/authError'

@@ -17,7 +17,7 @@ context('Base client page - Auth', () => {
beforeEach(() => {
cy.task('reset')
cy.task('stubSignIn')
cy.task('stubGetBaseClient', { grantType: GrantTypes.ClientCredentials })
cy.task('stubGetBaseClient', { grantType: GrantType.ClientCredentials })
cy.task('stubManageUser')
cy.task('stubGetListClientInstancesList')
cy.task('stubAddClientInstance')
@@ -42,7 +42,7 @@ context('Base client page - client credentials flow', () => {
beforeEach(() => {
cy.task('reset')
cy.task('stubSignIn')
cy.task('stubGetBaseClient', { grantType: GrantTypes.ClientCredentials })
cy.task('stubGetBaseClient', { grantType: GrantType.ClientCredentials })
cy.task('stubManageUser')
cy.task('stubGetListClientInstancesList')
cy.task('stubAddClientInstance')
@@ -115,7 +115,7 @@ context('Base client page - authorization-code flow', () => {
beforeEach(() => {
cy.task('reset')
cy.task('stubSignIn')
cy.task('stubGetBaseClient', { grantType: GrantTypes.AuthorizationCode })
cy.task('stubGetBaseClient', { grantType: GrantType.AuthorizationCode })
cy.task('stubManageUser')
cy.task('stubGetListClientInstancesList')
cy.task('stubAddClientInstance')
4 changes: 2 additions & 2 deletions integration_tests/mockApis/baseClientsApi.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import {
getListClientInstancesResponseMock,
getSecretsResponseMock,
} from '../../server/data/localMockData/baseClientsResponseMock'
import { GrantTypes } from '../../server/data/enums/grantTypes'
import { GrantType } from '../../server/data/enums/grantType'

export default {
stubListBaseClients: () => {
@@ -24,7 +24,7 @@ export default {
})
},

stubGetBaseClient: (config: { grantType: GrantTypes }) => {
stubGetBaseClient: (config: { grantType: GrantType }) => {
return stubFor({
request: {
method: 'GET',
4 changes: 2 additions & 2 deletions server/controllers/baseClientController.ts
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import { mapCreateBaseClientForm, mapEditBaseClientDeploymentForm, mapEditBaseCl
import { BaseClient, BaseClientListFilter, ClientSecrets } from '../interfaces/baseClientApi/baseClient'
import editBaseClientPresenter from '../views/presenters/editBaseClientPresenter'
import mapFilterForm from '../mappers/forms/mapFilterForm'
import { GrantTypes } from '../data/enums/grantTypes'
import { GrantType } from '../data/enums/grantType'
import { kebab } from '../utils/utils'
import baseClientAudit, { BaseClientAuditFunction } from '../audit/baseClientAudit'
import { BaseClientEvent } from '../audit/baseClientEvent'
@@ -71,7 +71,7 @@ export default class BaseClientController {
public displayNewBaseClient(): RequestHandler {
return async (req, res) => {
const { grant } = req.query
if (!(grant === kebab(GrantTypes.ClientCredentials) || grant === kebab(GrantTypes.AuthorizationCode))) {
if (!(grant === kebab(GrantType.ClientCredentials) || grant === kebab(GrantType.AuthorizationCode))) {
res.render('pages/new-base-client-grant.njk', { enableAuthorizationCode })
return
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// eslint-disable-next-line no-shadow,import/prefer-default-export
export enum GrantTypes {
export enum GrantType {
ClientCredentials = 'client_credentials',
AuthorizationCode = 'authorization_code',
}
6 changes: 3 additions & 3 deletions server/data/localMockData/baseClientsResponseMock.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import {
ListBaseClientsResponse,
ListClientInstancesResponse,
} from '../../interfaces/baseClientApi/baseClientResponse'
import { GrantTypes } from '../enums/grantTypes'
import { GrantType } from '../enums/grantType'
import { MfaType } from '../enums/mfaTypes'
import { snake } from '../../utils/utils'

@@ -36,7 +36,7 @@ export const listBaseClientsResponseMock: ListBaseClientsResponse = {
],
}

export const getBaseClientResponseMock: (grantType: GrantTypes) => GetBaseClientResponse = (grantType: GrantTypes) => {
export const getBaseClientResponseMock: (grantType: GrantType) => GetBaseClientResponse = (grantType: GrantType) => {
const response: GetBaseClientResponse = {
grantType: 'CLIENT_CREDENTIALS',
clientId: 'base_client_id_1',
@@ -59,7 +59,7 @@ export const getBaseClientResponseMock: (grantType: GrantTypes) => GetBaseClient
deploymentInfo: 'deployment deployment info',
},
}
if (snake(grantType) === GrantTypes.ClientCredentials) {
if (snake(grantType) === GrantType.ClientCredentials) {
return {
...response,
grantType: 'CLIENT_CREDENTIALS',
2 changes: 2 additions & 0 deletions server/interfaces/baseClientApi/baseClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { MfaType } from '../../data/enums/mfaTypes'
import { GrantType } from '../../data/enums/grantType'
import { ClientType } from '../../data/enums/clientTypes'

export interface BaseClient {
baseClientId: string
8 changes: 4 additions & 4 deletions server/mappers/forms/mapEditBaseClientDetailsForm.test.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import { createMock } from '@golevelup/ts-jest'
import { baseClientFactory } from '../../testutils/factories'
import { dateISOString, offsetNow } from '../../utils/utils'
import { mapEditBaseClientDetailsForm } from '../index'
import { GrantTypes } from '../../data/enums/grantTypes'
import { GrantType } from '../../data/enums/grantType'
import { MfaType } from '../../data/enums/mfaTypes'

const formRequest = (form: Record<string, unknown>) => {
@@ -99,7 +99,7 @@ describe('mapEditBaseClientDetailsForm', () => {
baseClientId: detailedBaseClient.baseClientId,
approvedScopes: 'requestscope1,requestscope2',
audit: 'request audit',
grantType: GrantTypes.ClientCredentials,
grantType: GrantType.ClientCredentials,
authorities: 'requestauthority1\r\nrequestauthority2',
databaseUsername: 'request databaseUsername',
allowedIPs: 'requestallowedIP1\r\nrequestallowedIP2',
@@ -114,7 +114,7 @@ describe('mapEditBaseClientDetailsForm', () => {
expect(update.baseClientId).toEqual(detailedBaseClient.baseClientId)
expect(update.scopes).toEqual(['requestscope1', 'requestscope2'])
expect(update.audit).toEqual('request audit')
expect(update.grantType).toEqual(GrantTypes.ClientCredentials)
expect(update.grantType).toEqual(GrantType.ClientCredentials)
expect(update.clientCredentials.authorities).toEqual(['requestauthority1', 'requestauthority2'])
expect(update.clientCredentials.databaseUserName).toEqual('request databaseUsername')
expect(update.config.allowedIPs).toEqual(['requestallowedIP1', 'requestallowedIP2'])
@@ -141,7 +141,7 @@ describe('mapEditBaseClientDetailsForm', () => {
baseClientId: detailedBaseClient.baseClientId,
approvedScopes: 'requestscope1,requestscope2',
audit: 'request audit',
grantType: GrantTypes.AuthorizationCode,
grantType: GrantType.AuthorizationCode,
redirectUris: 'requestredirectUri1\r\nrequestredirectUri2',
jwtFields: 'request jwtFields',
azureAdLoginFlow: 'redirect',