-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BAU: Remove source ip from send notication service
This is no longer required to set the ip in headers, since the common headers library that is now used gets this from the request that we now pass through. Also pulls out some common noisy setup from these tests
- Loading branch information
Showing
14 changed files
with
32 additions
and
85 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
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
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
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 |
---|---|---|
|
@@ -46,6 +46,12 @@ describe("setup-authenticator-app controller", () => { | |
}); | ||
|
||
describe("setupAuthenticatorAppPost", () => { | ||
let fakeNotificationService: SendNotificationServiceInterface; | ||
|
||
beforeEach(() => { | ||
fakeNotificationService = { sendNotification: sinon.fake() }; | ||
}); | ||
|
||
it("can send the journeyType when sending the MFA code", async () => { | ||
req.session.user.authAppSecret = "testsecret"; | ||
req.session.user.email = "[email protected]"; | ||
|
@@ -57,10 +63,6 @@ describe("setup-authenticator-app controller", () => { | |
verifyMfaCode: sinon.fake.returns({ success: true }), | ||
} as unknown as VerifyMfaCodeInterface; | ||
|
||
const fakeNotificationService: SendNotificationServiceInterface = { | ||
sendNotification: sinon.fake(), | ||
}; | ||
|
||
const getJourneyTypeFromUserSessionSpy = sinon.spy( | ||
journey, | ||
"getJourneyTypeFromUserSession" | ||
|
@@ -101,25 +103,20 @@ describe("setup-authenticator-app controller", () => { | |
verifyMfaCode: sinon.fake.returns({ success: true }), | ||
} as unknown as VerifyMfaCodeInterface; | ||
|
||
const fakeNotificationService: SendNotificationServiceInterface = { | ||
sendNotification: sinon.fake(), | ||
}; | ||
|
||
await setupAuthenticatorAppPost(fakeMfAService, fakeNotificationService)( | ||
req as Request, | ||
res as Response | ||
); | ||
|
||
expect(fakeMfAService.verifyMfaCode).to.have.been.calledOnce; | ||
expect(fakeNotificationService.sendNotification).to.have.been.calledOnce; | ||
expect(fakeNotificationService.sendNotification).to.have.calledWith( | ||
expect(fakeNotificationService.sendNotification).to.have.calledOnceWith( | ||
undefined, | ||
undefined, | ||
"[email protected]", | ||
NOTIFICATION_TYPE.ACCOUNT_CREATED_CONFIRMATION, | ||
"127.0.0.1", | ||
undefined, | ||
"" | ||
"", | ||
req | ||
); | ||
|
||
expect(res.redirect).to.have.calledWith( | ||
|
@@ -140,25 +137,20 @@ describe("setup-authenticator-app controller", () => { | |
verifyMfaCode: sinon.fake.returns({ success: true }), | ||
} as unknown as VerifyMfaCodeInterface; | ||
|
||
const fakeNotificationService: SendNotificationServiceInterface = { | ||
sendNotification: sinon.fake(), | ||
}; | ||
|
||
await setupAuthenticatorAppPost(fakeMfAService, fakeNotificationService)( | ||
req as Request, | ||
res as Response | ||
); | ||
|
||
expect(fakeMfAService.verifyMfaCode).to.have.been.calledOnce; | ||
expect(fakeNotificationService.sendNotification).to.have.been.calledOnce; | ||
expect(fakeNotificationService.sendNotification).to.have.calledWith( | ||
expect(fakeNotificationService.sendNotification).to.have.calledOnceWith( | ||
undefined, | ||
undefined, | ||
"[email protected]", | ||
NOTIFICATION_TYPE.CHANGE_HOW_GET_SECURITY_CODES_CONFIRMATION, | ||
"127.0.0.1", | ||
undefined, | ||
"" | ||
"", | ||
req | ||
); | ||
|
||
expect(res.redirect).to.have.calledWith( | ||
|
@@ -178,10 +170,6 @@ describe("setup-authenticator-app controller", () => { | |
}), | ||
} as unknown as VerifyMfaCodeInterface; | ||
|
||
const fakeNotificationService: SendNotificationServiceInterface = { | ||
sendNotification: sinon.fake(), | ||
}; | ||
|
||
await setupAuthenticatorAppPost(fakeMfAService, fakeNotificationService)( | ||
req as Request, | ||
res as Response | ||
|
@@ -205,10 +193,6 @@ describe("setup-authenticator-app controller", () => { | |
verifyMfaCode: sinon.fake.returns({ success: true }), | ||
} as unknown as VerifyMfaCodeInterface; | ||
|
||
const fakeNotificationService: SendNotificationServiceInterface = { | ||
sendNotification: sinon.fake(), | ||
}; | ||
|
||
await setupAuthenticatorAppPost(fakeMfAService, fakeNotificationService)( | ||
req as Request, | ||
res as Response | ||
|