Skip to content

Commit

Permalink
HAAR 1902 - Data layer (#22)
Browse files Browse the repository at this point in the history
* Add initial data-layer files

* implement call to listBaseClients endpoint - currently clients/all

* surface data layer on homepage to demonstrate layer model

* Util function for splitting string responses from API

* tidy front end code

* update package-lock

* clean up for linter - (only comment out upcoming work)

* update integration test specification for home page

* updates for integration testing

* updates to integration tests

* HAAR-1902: Fix for integration tests

* move list base-clients endpoint to new authorization-server schema

* For getBaseClient api

- add response type
- add to api client + tests
- add mapper
- add to base client service + tests

* fix linting errors

* post base-client endpoint added

* update base client

* update base client deployment details

* list client instances

* delete client instance

* remove commented code

* remove clientid and secret from authorization server until needed

* respond to review comments

---------

Co-authored-by: Jon Brighton <brightonsbox@hotmail.com>
  • Loading branch information
thomasridd and brightonsbox committed Oct 18, 2023
1 parent 1aef1f8 commit c32923e
Show file tree
Hide file tree
Showing 48 changed files with 2,828 additions and 4,090 deletions.
17 changes: 17 additions & 0 deletions assets/js/initMOJFilterPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
new MOJFrontend.FilterToggleButton({
bigModeMediaQuery: '(min-width: 48.063em)',
startHidden: true,
toggleButton: {
container: $('.moj-action-bar__filter'),
showText: 'Show filter',
hideText: 'Hide filter',
classes: 'govuk-button--secondary',
},
closeButton: {
container: $('.moj-filter__header-action'),
text: 'Close',
},
filter: {
container: $('.moj-filter'),
},
})
6 changes: 6 additions & 0 deletions assets/scss/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ $govuk-page-width: $moj-page-width;

@import './components/header-bar';
@import 'assets/scss/local';

.extra-wide {
.govuk-width-container {
max-width: 1300px;
}
}
2 changes: 2 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineConfig } from 'cypress'
import { resetStubs } from './integration_tests/mockApis/wiremock'
import auth from './integration_tests/mockApis/auth'
import tokenVerification from './integration_tests/mockApis/tokenVerification'
import baseClientsApi from './integration_tests/mockApis/baseClientsApi'

export default defineConfig({
chromeWebSecurity: false,
Expand All @@ -21,6 +22,7 @@ export default defineConfig({
reset: resetStubs,
...auth,
...tokenVerification,
...baseClientsApi,
})
},
baseUrl: 'http://localhost:3007',
Expand Down
1 change: 1 addition & 0 deletions feature.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
PORT=3007
HMPPS_AUTH_URL=http://localhost:9091/auth
HMPPS_AUTHORIZATION_SERVER_URL=http://localhost:9091/baseClientsApi
TOKEN_VERIFICATION_API_URL=http://localhost:9091/verification
TOKEN_VERIFICATION_ENABLED=true
NODE_ENV=development
Expand Down
10 changes: 8 additions & 2 deletions integration_tests/e2e/login.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ context('SignIn', () => {
cy.task('reset')
cy.task('stubSignIn')
cy.task('stubAuthUser')
cy.task('stubListBaseClients')
cy.task('stubGetBaseClient')
})

it('Unauthenticated user directed to auth', () => {
Expand Down Expand Up @@ -58,17 +60,21 @@ context('SignIn', () => {
})

it('Token verification failure clears user session', () => {
// sign in as one user
cy.signIn()
const indexPage = Page.verifyOnPage(IndexPage)
cy.task('stubVerifyToken', false)

// can't do a visit here as cypress requires only one domain
// invalidate the token
cy.task('stubVerifyToken', false)
// and check they are sent to sign in - can't do a visit here as cypress requires only one domain
cy.request('/').its('body').should('contain', 'Sign in')

// sign back in as a different person
cy.task('stubVerifyToken', true)
cy.task('stubAuthUser', 'bobby brown')
cy.signIn()

// check the new user is signed in
indexPage.headerUserName().contains('B. Brown')
})
})
39 changes: 39 additions & 0 deletions integration_tests/mockApis/baseClientsApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { stubFor } from './wiremock'
import {
listBaseClientsResponseMock,
getBaseClientResponseMock,
} from '../../server/data/localMockData/baseClientsResponseMock'

export default {
stubListBaseClients: () => {
return stubFor({
request: {
method: 'GET',
urlPattern: `/baseClientsApi/base-clients`,
},
response: {
status: 200,
headers: {
'Content-Type': 'application/json;charset=UTF-8',
},
jsonBody: listBaseClientsResponseMock,
},
})
},

stubGetBaseClient: () => {
return stubFor({
request: {
method: 'GET',
urlPattern: `/baseClientsApi/base-clients/baseClientId`,
},
response: {
status: 200,
headers: {
'Content-Type': 'application/json;charset=UTF-8',
},
jsonBody: getBaseClientResponseMock,
},
})
},
}
2 changes: 1 addition & 1 deletion integration_tests/pages/index.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 IndexPage extends Page {
constructor() {
super('This site is under construction...')
super('OAuth Client details')
}

headerUserName = (): PageElement => cy.get('[data-qa=header-user-name]')
Expand Down

0 comments on commit c32923e

Please sign in to comment.