Skip to content

Commit

Permalink
Change urls to client and instance
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasridd committed Feb 21, 2024
1 parent a178067 commit 6943306
Show file tree
Hide file tree
Showing 22 changed files with 72 additions and 73 deletions.
16 changes: 8 additions & 8 deletions integration_tests/e2e/add-base-client.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import AuthSignInPage from '../pages/authSignIn'

const visitAddBaseClientPage = (options = { failOnStatusCode: true }): AddBaseClientGrantPage => {
const { failOnStatusCode } = options
cy.signIn({ failOnStatusCode, redirectPath: '/base-clients/new' })
cy.signIn({ failOnStatusCode, redirectPath: '/clients/new' })
return Page.verifyOnPage(AddBaseClientGrantPage)
}

const visitAddWithClientCredentialsPage = (): AddBaseClientDetailsPage => {
cy.signIn({ failOnStatusCode: true, redirectPath: '/base-clients/new?grant=client-credentials' })
cy.signIn({ failOnStatusCode: true, redirectPath: '/clients/new?grant=client-credentials' })
return Page.verifyOnPage(AddBaseClientDetailsPage)
}

Expand All @@ -26,25 +26,25 @@ context('Add client page', () => {

context('Authorisation and authentication', () => {
it('Unauthenticated user directed to auth', () => {
cy.visit('/base-clients/new')
cy.visit('/clients/new')
Page.verifyOnPage(AuthSignInPage)
})

it('Unauthenticated user accessing details directed to auth', () => {
cy.visit('/base-clients/new?grant=client-credentials')
cy.visit('/clients/new?grant=client-credentials')
Page.verifyOnPage(AuthSignInPage)
})

it('User without ROLE_OAUTH_ADMIN role denied access to grant screen', () => {
cy.task('stubSignIn', ['ROLE_OTHER'])
cy.signIn({ failOnStatusCode: false, redirectPath: '/base-clients/new' })
cy.signIn({ failOnStatusCode: false, redirectPath: '/clients/new' })

Page.verifyOnPage(AuthErrorPage)
})

it('User without ROLE_OAUTH_ADMIN role denied access to details screen', () => {
cy.task('stubSignIn', ['ROLE_OTHER'])
cy.signIn({ failOnStatusCode: false, redirectPath: '/base-clients/new?grant=client-credentials' })
cy.signIn({ failOnStatusCode: false, redirectPath: '/clients/new?grant=client-credentials' })

Page.verifyOnPage(AuthErrorPage)
})
Expand All @@ -59,7 +59,7 @@ context('Add client page', () => {

it('User without ROLE_OAUTH_ADMIN role denied access', () => {
cy.task('stubSignIn', ['ROLE_OTHER'])
cy.signIn({ failOnStatusCode: false, redirectPath: '/base-clients/new' })
cy.signIn({ failOnStatusCode: false, redirectPath: '/clients/new' })

Page.verifyOnPage(AuthErrorPage)
})
Expand Down Expand Up @@ -148,7 +148,7 @@ context('Add client page', () => {
addBaseClientDetailsPage.baseClientIdInput().type('new-client-id')

// set up to check the POST request
cy.intercept('POST', '/base-clients/new', req => {
cy.intercept('POST', '/clients/new', req => {
const { body } = req
expect(body).to.contain('baseClientId=new-client-id')
})
Expand Down
8 changes: 4 additions & 4 deletions integration_tests/e2e/edit-base-client-deployment.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import AuthSignInPage from '../pages/authSignIn'
import AuthErrorPage from '../pages/authError'

const visitEditBaseClientDeploymentDetailsPage = (): EditBaseClientDeploymentDetailsPage => {
cy.signIn({ failOnStatusCode: true, redirectPath: '/base-clients/base_client_id_1/deployment' })
cy.signIn({ failOnStatusCode: true, redirectPath: '/clients/base_client_id_1/deployment' })
return Page.verifyOnPage(EditBaseClientDeploymentDetailsPage)
}

Expand All @@ -21,13 +21,13 @@ context('Edit base client deployment: Auth', () => {
})

it('Unauthenticated user directed to auth', () => {
cy.visit('/base-clients/base_client_id_1/deployment')
cy.visit('/clients/base_client_id_1/deployment')
Page.verifyOnPage(AuthSignInPage)
})

it('User without ROLE_OAUTH_ADMIN role denied access', () => {
cy.task('stubSignIn', ['ROLE_OTHER'])
cy.signIn({ failOnStatusCode: false, redirectPath: '/base-clients/base_client_id_1/deployment' })
cy.signIn({ failOnStatusCode: false, redirectPath: '/clients/base_client_id_1/deployment' })

Page.verifyOnPage(AuthErrorPage)
})
Expand Down Expand Up @@ -75,7 +75,7 @@ context('Edit base client deployment details page', () => {
editBaseClientDeploymentDetailsPage.deploymentTeamInput().type('HAHA')

// set up to check the POST request
cy.intercept('POST', '/base-clients/base_client_id_1/deployment', req => {
cy.intercept('POST', '/clients/base_client_id_1/deployment', req => {
const { body } = req
expect(body).to.contain('team=HAHA')
})
Expand Down
14 changes: 7 additions & 7 deletions integration_tests/e2e/edit-base-client-details.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import AuthSignInPage from '../pages/authSignIn'
import AuthErrorPage from '../pages/authError'

const visitEditBaseClientDetailsPage = (): EditBaseClientDetailsPage => {
cy.signIn({ failOnStatusCode: false, redirectPath: '/base-clients/base_client_id_1/edit' })
cy.signIn({ failOnStatusCode: true, redirectPath: '/clients/base_client_id_1/edit' })
return Page.verifyOnPage(EditBaseClientDetailsPage)
}

Expand All @@ -21,13 +21,13 @@ context('Edit base client details: Auth', () => {
})

it('Unauthenticated user directed to auth', () => {
cy.visit('/base-clients/base_client_id_1/deployment')
cy.visit('/clients/base_client_id_1/deployment')
Page.verifyOnPage(AuthSignInPage)
})

it('User without ROLE_OAUTH_ADMIN role denied access', () => {
cy.task('stubSignIn', ['ROLE_OTHER'])
cy.signIn({ failOnStatusCode: false, redirectPath: '/base-clients/base_client_id_1/edit' })
cy.signIn({ failOnStatusCode: false, redirectPath: '/clients/base_client_id_1/edit' })

Page.verifyOnPage(AuthErrorPage)
})
Expand All @@ -47,7 +47,7 @@ context('Edit base client details page - client-credentials flow', () => {
editBaseClientDetailsPage = visitEditBaseClientDetailsPage()
})

it('User can see base-client form inputs', () => {
it('User can see client form inputs', () => {
editBaseClientDetailsPage.baseClientIdInput().should('exist')
editBaseClientDetailsPage.baseClientAccessTokenValidityDropdown().should('be.visible')
editBaseClientDetailsPage.baseClientApprovedScopesInput().should('be.visible')
Expand Down Expand Up @@ -98,18 +98,18 @@ context('Edit base client details page - client-credentials flow', () => {
})
})

it('User clicks cancel to return to base-client screen', () => {
it('User clicks cancel to return to client screen', () => {
editBaseClientDetailsPage.cancelLink().click()
Page.verifyOnPage(ViewBaseClientPage)
})

it('User clicks continue to post new client details screen', () => {
it('User clicks continue to post new client instance screen', () => {
// enter new audit details
editBaseClientDetailsPage.auditTrailDetailsInput().clear()
editBaseClientDetailsPage.auditTrailDetailsInput().type('updated')

// set up to check the POST request
cy.intercept('POST', '/base-clients/base_client_id_1/edit', req => {
cy.intercept('POST', '/clients/base_client_id_1/edit', req => {
const { body } = req
expect(body).to.contain('audit=updated')
})
Expand Down
8 changes: 4 additions & 4 deletions integration_tests/e2e/edit-client-instances.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import ConfirmDeleteClientPage from '../pages/confirmDeleteClient'
import { GrantTypes } from '../../server/data/enums/grantTypes'

const visitBaseClientPage = (): ViewBaseClientPage => {
cy.signIn({ failOnStatusCode: true, redirectPath: '/base-clients/base_client_id_1' })
cy.signIn({ failOnStatusCode: true, redirectPath: '/clients/base_client_id_1' })
return Page.verifyOnPage(ViewBaseClientPage)
}

const visitConfirmDeleteClientPage = (): ConfirmDeleteClientPage => {
cy.signIn({
failOnStatusCode: true,
redirectPath: '/base-clients/base_client_id_1/clients/base_client_id_1_01/delete',
redirectPath: '/clients/base_client_id_1/instances/base_client_id_1_01/delete',
})
return Page.verifyOnPage(ConfirmDeleteClientPage)
}
Expand All @@ -34,7 +34,7 @@ context('Base client page - client instances', () => {
baseClientsPage = visitBaseClientPage()
})

it('User can click Add on base-client page to create new client instance', () => {
it('User can click Add on client page to create new client instance', () => {
baseClientsPage.addClientInstanceButton().click()
Page.verifyOnPage(ViewClientSecretsPage)
})
Expand Down Expand Up @@ -74,7 +74,7 @@ context('Base client page - client instances', () => {
confirmDeleteClientPage.errorMessage().should('not.exist')
})

it('User can fill out confirm then click Delete on base-client page to delete client instance', () => {
it('User can fill out confirm then click Delete on client page to delete client instance', () => {
confirmDeleteClientPage.confirmInput().clear()
confirmDeleteClientPage.confirmInput().type('base_client_id_1_01')

Expand Down
8 changes: 4 additions & 4 deletions integration_tests/e2e/view-base-client-list.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ context('Homepage - Auth', () => {
})
})

context('Homepage - list base-clients', () => {
context('Homepage - list clients', () => {
let listBaseClientsPage: ViewBaseClientListPage

beforeEach(() => {
Expand All @@ -49,11 +49,11 @@ context('Homepage - list base-clients', () => {
listBaseClientsPage = visitBaseClientListPage()
})

it('User can see base-client list', () => {
it('User can see client list', () => {
listBaseClientsPage.baseClientList().should('have.length', 3)
})

it('User can click through to base-client', () => {
it('User can click through to client', () => {
listBaseClientsPage.baseClientList().first().children('a').click()
Page.verifyOnPage(ViewBaseClientPage)
})
Expand All @@ -62,7 +62,7 @@ context('Homepage - list base-clients', () => {
listBaseClientsPage.addNewBaseClient().should('exist')
})

it('User can click through to new base-client page', () => {
it('User can click through to new client page', () => {
listBaseClientsPage.addNewBaseClient().click()
Page.verifyOnPage(NewBaseClientGrantPage)
})
Expand Down
6 changes: 3 additions & 3 deletions integration_tests/e2e/view-base-client.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import AuthSignInPage from '../pages/authSignIn'
import AuthErrorPage from '../pages/authError'

const visitBaseClientPage = (): ViewBaseClientPage => {
cy.signIn({ failOnStatusCode: true, redirectPath: '/base-clients/base_client_id_1' })
cy.signIn({ failOnStatusCode: true, redirectPath: '/clients/base_client_id_1' })
return Page.verifyOnPage(ViewBaseClientPage)
}

Expand All @@ -24,13 +24,13 @@ context('Base client page - Auth', () => {
})

it('Unauthenticated user directed to auth', () => {
cy.visit('/base-clients/base_client_id_1')
cy.visit('/clients/base_client_id_1')
Page.verifyOnPage(AuthSignInPage)
})

it('User without ROLE_OAUTH_ADMIN role denied access', () => {
cy.task('stubSignIn', ['ROLE_OTHER'])
cy.signIn({ failOnStatusCode: false, redirectPath: '/base-clients/base_client_id_1' })
cy.signIn({ failOnStatusCode: false, redirectPath: '/clients/base_client_id_1' })

Page.verifyOnPage(AuthErrorPage)
})
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/pages/editBaseClientDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Page, { PageElement } from './page'

export default class EditBaseClientDetailsPage extends Page {
constructor() {
super('Edit base client details')
super('Edit client details')
}

baseClientIdInput = (): PageElement => cy.get('[data-qa="base-client-id-input"]')
Expand Down
8 changes: 4 additions & 4 deletions server/controllers/baseClientController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ describe('BaseClientController', () => {
expect(baseClientService.updateBaseClient).toHaveBeenCalled()

// AND the user is redirected to the view base client page
expect(response.redirect).toHaveBeenCalledWith(`/base-clients/${baseClient.baseClientId}`)
expect(response.redirect).toHaveBeenCalledWith(`/clients/${baseClient.baseClientId}`)
})

it('audits the update attempt', async () => {
Expand Down Expand Up @@ -484,7 +484,7 @@ describe('BaseClientController', () => {
expect(baseClientService.updateBaseClientDeployment).toHaveBeenCalled()

// AND the user is redirected to the view base client page
expect(response.redirect).toHaveBeenCalledWith(`/base-clients/${baseClient.baseClientId}`)
expect(response.redirect).toHaveBeenCalledWith(`/clients/${baseClient.baseClientId}`)
})

it('audits the update attempt', async () => {
Expand Down Expand Up @@ -662,7 +662,7 @@ describe('BaseClientController', () => {
describe(`delete the client instance`, () => {
it.each([
['one client instance exists', '/', 1],
['multiple client instances', '/base-clients/abcd', 3],
['multiple client instances', '/clients/abcd', 3],
])(`if delete successful and %s, redirects to %s`, async (_, redirectURL, clientCount) => {
// GIVEN a base client
const baseClient = baseClientFactory.build({ baseClientId: 'abcd' })
Expand Down Expand Up @@ -703,7 +703,7 @@ describe('BaseClientController', () => {
await baseClientController.deleteClientInstance()(request, response, next)

// THEN the user is redirected with error
const expectedURL = `/base-clients/${baseClient.baseClientId}/clients/${client.clientId}/delete?error=clientIdMismatch`
const expectedURL = `/clients/${baseClient.baseClientId}/instances/${client.clientId}/delete?error=clientIdMismatch`
expect(response.redirect).toHaveBeenCalledWith(expectedURL)
})

Expand Down
10 changes: 5 additions & 5 deletions server/controllers/baseClientController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export default class BaseClientController {
const baseClient = await this.baseClientService.getBaseClient(token, baseClientId)
const updatedClient = mapEditBaseClientDetailsForm(baseClient, req)
await this.baseClientService.updateBaseClient(token, updatedClient)
res.redirect(`/base-clients/${baseClientId}`)
res.redirect(`/clients/${baseClientId}`)
} catch (e) {
await audit(BaseClientEvent.UPDATE_BASE_CLIENT_FAILURE, baseClientId)
throw e
Expand Down Expand Up @@ -180,7 +180,7 @@ export default class BaseClientController {
const baseClient = await this.baseClientService.getBaseClient(token, baseClientId)
const updatedClient = mapEditBaseClientDeploymentForm(baseClient, req)
await this.baseClientService.updateBaseClientDeployment(token, updatedClient)
res.redirect(`/base-clients/${baseClientId}`)
res.redirect(`/clients/${baseClientId}`)
} catch (e) {
await audit(BaseClientEvent.UPDATE_BASE_CLIENT_DEPLOYMENT_FAILURE, baseClientId)
throw e
Expand Down Expand Up @@ -230,7 +230,7 @@ export default class BaseClientController {
try {
if (req.body.confirm !== clientId) {
await audit(BaseClientEvent.DELETE_CLIENT_FAILURE)
res.redirect(`/base-clients/${baseClientId}/clients/${clientId}/delete?error=clientIdMismatch`)
res.redirect(`/clients/${baseClientId}/instances/${clientId}/delete?error=clientIdMismatch`)
return
}

Expand All @@ -239,7 +239,7 @@ export default class BaseClientController {
const client = clients.find(c => c.clientId === clientId)

if (!client) {
res.redirect(`/base-clients/${baseClientId}/clients/${clientId}/delete?error=clientNotFound`)
res.redirect(`/clients/${baseClientId}/instances/${clientId}/delete?error=clientNotFound`)
return
}

Expand Down Expand Up @@ -321,7 +321,7 @@ export default class BaseClientController {
if (clients.length === 1) {
res.redirect(`/`)
} else {
res.redirect(`/base-clients/${baseClientId}`)
res.redirect(`/clients/${baseClientId}`)
}
}
}
20 changes: 10 additions & 10 deletions server/routes/baseClientRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ export default function baseClientRouter(services: Services): Router {
const baseClientController = new BaseClientController(services.baseClientService)

get('/', baseClientController.displayBaseClients())
get('/base-clients/new', baseClientController.displayNewBaseClient())
get('/base-clients/:baseClientId/deployment', baseClientController.displayEditBaseClientDeployment())
get('/base-clients/:baseClientId/edit', baseClientController.displayEditBaseClient())
get('/base-clients/:baseClientId', baseClientController.displayBaseClient())
get('/base-clients/:baseClientId/clients/:clientId/delete', baseClientController.displayDeleteClientInstance())
get('/clients/new', baseClientController.displayNewBaseClient())
get('/clients/:baseClientId/deployment', baseClientController.displayEditBaseClientDeployment())
get('/clients/:baseClientId/edit', baseClientController.displayEditBaseClient())
get('/clients/:baseClientId', baseClientController.displayBaseClient())
get('/clients/:baseClientId/instances/:clientId/delete', baseClientController.displayDeleteClientInstance())
post('/', baseClientController.filterBaseClients())
post('/base-clients/new', baseClientController.createBaseClient())
post('/base-clients/:baseClientId/deployment', baseClientController.updateBaseClientDeployment())
post('/base-clients/:baseClientId/edit', baseClientController.updateBaseClientDetails())
post('/base-clients/:baseClientId/clients', baseClientController.createClientInstance())
post('/base-clients/:baseClientId/clients/:clientId/delete', baseClientController.deleteClientInstance())
post('/clients/new', baseClientController.createBaseClient())
post('/clients/:baseClientId/deployment', baseClientController.updateBaseClientDeployment())
post('/clients/:baseClientId/edit', baseClientController.updateBaseClientDetails())
post('/clients/:baseClientId/instances', baseClientController.createClientInstance())
post('/clients/:baseClientId/instances/:clientId/delete', baseClientController.deleteClientInstance())
return router
}
6 changes: 3 additions & 3 deletions server/views/pages/base-client.njk
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
}
}) }}

<form class="govuk-grid-row" action="/base-clients/{{ baseClient.baseClientId }}/clients" method="POST">
<form class="govuk-grid-row" action="/clients/{{ baseClient.baseClientId }}/instances" method="POST">
<input type="hidden" name="_csrf" value="{{ csrfToken }}">
<div class="govuk-grid-column-one-quarter">
{{ govukButton({
Expand All @@ -69,7 +69,7 @@
<h2 class="govuk-heading-l">Client details</h2>
</div>
<div class="govuk-grid-column-one-third">
<a class="govuk-link" href="/base-clients/{{ baseClient.baseClientId }}/edit" data-qa='change-client-details-link'>Change
<a class="govuk-link" href="/clients/{{ baseClient.baseClientId }}/edit" data-qa='change-client-details-link'>Change
client details</a>
</div>
</div>
Expand Down Expand Up @@ -324,7 +324,7 @@
<h2 class="govuk-heading-l">Deployment details</h2>
</div>
<div class="govuk-grid-column-one-third">
<a class="govuk-link" href="/base-clients/{{ baseClient.baseClientId }}/deployment" data-qa='change-deployment-details-link'>Change
<a class="govuk-link" href="/clients/{{ baseClient.baseClientId }}/deployment" data-qa='change-deployment-details-link'>Change
deployment details</a>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion server/views/pages/base-clients.njk
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
{{ mojButtonMenu({
items: [{
text: 'Add new client',
href:"/base-clients/new",
href:"/clients/new",
classes: 'govuk-button--primary',
attributes: {
'data-qa': 'addNewBaseClientButton'
Expand Down
Loading

0 comments on commit 6943306

Please sign in to comment.