generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration tests for GOV.UK One Login
- Loading branch information
Showing
20 changed files
with
256 additions
and
257 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
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 HomePage from '../pages/home' | ||
import GovukOneLoginPage from '../pages/govukOneLogin' | ||
import Page from '../pages/page' | ||
|
||
context('Sign in with GOV.UK One Login', () => { | ||
beforeEach(() => { | ||
cy.task('reset') | ||
cy.task('stubSignIn') | ||
}) | ||
|
||
it('Unauthenticated user redirected to GOV.UK One Login - home page', () => { | ||
cy.visit('/') | ||
Page.verifyOnPage(GovukOneLoginPage) | ||
}) | ||
|
||
it('Unauthenticated user redirected to GOV.UK One Login - sign-in URL', () => { | ||
cy.visit('/auth/sign-in') | ||
Page.verifyOnPage(GovukOneLoginPage) | ||
}) | ||
|
||
it('Unauthenticated user redirected to GOV.UK One Login - callback URL', () => { | ||
cy.visit('/auth/callback') | ||
Page.verifyOnPage(GovukOneLoginPage) | ||
}) | ||
|
||
it('Unauthenticated user redirected to GOV.UK One Login - non-existant route', () => { | ||
cy.visit('/NON-EXISTANT-PAGE') | ||
Page.verifyOnPage(GovukOneLoginPage) | ||
}) | ||
|
||
it('User can sign in and view home page', () => { | ||
cy.signIn() | ||
Page.verifyOnPage(HomePage) | ||
|
||
// just testing sample data dumped to the page for now | ||
cy.contains('"sub": "user1"') | ||
cy.contains('"phone_number": "+440123456789"') | ||
cy.contains('"email": "user1@example.com"') | ||
}) | ||
|
||
it('User sent to auth error page if sign in fails', () => { | ||
// setting an invalid nonce value should cause ID token validation to fail | ||
cy.signIn({ failOnStatusCode: false, nonce: 'INVALID_NONCE' }) | ||
cy.get('h1').contains('Authorisation Error') | ||
}) | ||
|
||
it('User can log out', () => { | ||
cy.signIn() | ||
const homePage = Page.verifyOnPage(HomePage) | ||
homePage.signOut().click() | ||
Page.verifyOnPage(GovukOneLoginPage) | ||
cy.contains('You have been logged out.') | ||
}) | ||
}) |
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.