Skip to content

Commit

Permalink
failing test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MunishSharmaHMCTS committed Nov 21, 2024
1 parent 32173c3 commit 27f3d19
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hmcts/rpx-xui-node-lib",
"version": "2.29.5-exui-2079-rc8",
"version": "2.29.5-exui-2079-rc9",
"description": "Common nodejs library components for XUI",
"main": "dist/index",
"types": "dist/index.d.ts",
Expand Down
8 changes: 4 additions & 4 deletions src/auth/models/strategy.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ export abstract class Strategy extends events.EventEmitter {

this.serializeUser()
this.deserializeUser()
;(async () => {
await Promise.all([this.initialiseStrategy(this.options)])
})()
; (async () => {

Check failure on line 244 in src/auth/models/strategy.class.ts

View workflow job for this annotation

GitHub Actions / build

Replace `····;·` with `;`

Check failure on line 244 in src/auth/models/strategy.class.ts

View workflow job for this annotation

GitHub Actions / build

Replace `····;·` with `;`
await Promise.all([this.initialiseStrategy(this.options)])

Check failure on line 245 in src/auth/models/strategy.class.ts

View workflow job for this annotation

GitHub Actions / build

Delete `····`

Check failure on line 245 in src/auth/models/strategy.class.ts

View workflow job for this annotation

GitHub Actions / build

Delete `····`
})()

Check failure on line 246 in src/auth/models/strategy.class.ts

View workflow job for this annotation

GitHub Actions / build

Delete `····`

Check failure on line 246 in src/auth/models/strategy.class.ts

View workflow job for this annotation

GitHub Actions / build

Delete `····`

this.initializePassport()
this.initializeSession()
Expand Down Expand Up @@ -413,7 +413,7 @@ export abstract class Strategy extends events.EventEmitter {
this.logger.error(
`User has no application access, as they do not have a ${this.options.allowRolesRegex} role.`,
)
return this.logout(req, res)
return this.logout(req, res, next)
}
if (!this.listenerCount(AUTH.EVENT.AUTHENTICATE_SUCCESS)) {
this.logger.log(`redirecting, no listener count: ${AUTH.EVENT.AUTHENTICATE_SUCCESS}`)
Expand Down
9 changes: 5 additions & 4 deletions src/auth/oidc/models/openid.class.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { oidc, OpenID } from './openid.class'
import passport from 'passport'
import express, { Request, response, Response, Router } from 'express'
import express, { NextFunction, Request, response, Response, Router } from 'express'
import { AUTH } from '../../auth.constants'
import { Client, Issuer, Strategy, TokenSet, UserinfoResponse } from 'openid-client'
import { createMock } from 'ts-auto-mock'
Expand Down Expand Up @@ -399,7 +399,7 @@ xtest('verify() Should return a no access roles messages if the User has no role
const tokenSet = createMock<TokenSet>()
const userinfo = createMock<UserinfoResponse>()

const doneFunction = jest.fn((err, user, message) => {})
const doneFunction = jest.fn((err, user, message) => { })

Check failure on line 402 in src/auth/oidc/models/openid.class.spec.ts

View workflow job for this annotation

GitHub Actions / build

Delete `·`

Check failure on line 402 in src/auth/oidc/models/openid.class.spec.ts

View workflow job for this annotation

GitHub Actions / build

Delete `·`

oidc.verify(tokenSet, userinfo, doneFunction)

Expand All @@ -421,7 +421,7 @@ xtest('verify() Should return the user token set if a User has roles.', async ()
idToken: tokenSet.id_token,
}

const doneFunction = jest.fn((err, user, message) => {})
const doneFunction = jest.fn((err, user, message) => { })

Check failure on line 424 in src/auth/oidc/models/openid.class.spec.ts

View workflow job for this annotation

GitHub Actions / build

Delete `·`

Check failure on line 424 in src/auth/oidc/models/openid.class.spec.ts

View workflow job for this annotation

GitHub Actions / build

Delete `·`

oidc.verify(tokenSet, userinfo, doneFunction)

Expand Down Expand Up @@ -452,6 +452,7 @@ xtest('makeAuthorization() Should make an authorisation string', async () => {
xtest('strategy logout', async () => {
const session = createMock<MySessionData>()
const mockRequest = createMock<Request>()
const mockNextFunction = createMock<NextFunction>()
session.passport = {
user: {
tokenset: {
Expand All @@ -472,7 +473,7 @@ xtest('strategy logout', async () => {
mockResponse.redirect = jest.fn()
const spyhttp = jest.spyOn(http, 'delete').mockImplementation(() => Promise.resolve({} as any))
const spySessionDestroy = jest.spyOn(oidc, 'destroySession').mockImplementation(() => Promise.resolve({} as any))
await oidc.logout(mockRequest, mockResponse)
await oidc.logout(mockRequest, mockResponse, mockNextFunction)
expect(spyhttp).toHaveBeenCalled()
expect(spySessionDestroy).toHaveBeenCalled()
})
Expand Down

0 comments on commit 27f3d19

Please sign in to comment.