-
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.
Merge pull request #1428 from govuk-one-login/AUT-2440/fixed-password…
…-reset-blocked-and-suspended-journeys AUT-2440: Fixed forgotten password journey while a user is suspended or blocked
- Loading branch information
Showing
5 changed files
with
52 additions
and
20 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 |
---|---|---|
|
@@ -16,6 +16,8 @@ import { | |
} from "../reset-password-2fa-sms-controller"; | ||
import { VerifyCodeInterface } from "../../common/verify-code/types"; | ||
import { MfaServiceInterface } from "../../common/mfa/types"; | ||
import { fakeVerifyCodeServiceHelper } from "../../../../test/helpers/verify-code-helpers"; | ||
import { accountInterventionsFakeHelper } from "../../../../test/helpers/account-interventions-helpers"; | ||
|
||
describe("reset password 2fa auth app controller", () => { | ||
let req: RequestOutput; | ||
|
@@ -35,6 +37,7 @@ describe("reset password 2fa auth app controller", () => { | |
}); | ||
|
||
afterEach(() => { | ||
delete process.env.SUPPORT_ACCOUNT_INTERVENTIONS; | ||
sinon.restore(); | ||
}); | ||
|
||
|
@@ -105,6 +108,46 @@ describe("reset password 2fa auth app controller", () => { | |
expect(res.render).to.have.calledWith("reset-password-2fa-sms/index.njk"); | ||
}); | ||
|
||
it("should redirect to /unavailable-temporary when temporarilySuspended status applied to account and they try to reset their password", async () => { | ||
process.env.SUPPORT_ACCOUNT_INTERVENTIONS = "1"; | ||
const fakeService = fakeVerifyCodeServiceHelper(true); | ||
const fakeInterventionsService = accountInterventionsFakeHelper( | ||
"[email protected]", | ||
false, | ||
false, | ||
true | ||
); | ||
req.session.user = { | ||
email: "[email protected]", | ||
}; | ||
await resetPassword2FASmsPost(fakeService, fakeInterventionsService)( | ||
req as Request, | ||
res as Response | ||
); | ||
|
||
expect(res.redirect).to.have.calledWith(PATH_NAMES.UNAVAILABLE_TEMPORARY); | ||
}); | ||
|
||
it("should redirect to /unavailable-temporary when temporarilySuspended status applied to account and they try to reset their password", async () => { | ||
process.env.SUPPORT_ACCOUNT_INTERVENTIONS = "1"; | ||
const fakeService = fakeVerifyCodeServiceHelper(true); | ||
const fakeInterventionsService = accountInterventionsFakeHelper( | ||
"[email protected]", | ||
false, | ||
true, | ||
false | ||
); | ||
req.session.user = { | ||
email: "[email protected]", | ||
}; | ||
await resetPassword2FASmsPost(fakeService, fakeInterventionsService)( | ||
req as Request, | ||
res as Response | ||
); | ||
|
||
expect(res.redirect).to.have.calledWith(PATH_NAMES.UNAVAILABLE_PERMANENT); | ||
}); | ||
|
||
it("should render security code entered too many times page view when user is account is locked from entering security codes", async () => { | ||
const fakeService: MfaServiceInterface = { | ||
sendMfaCode: sinon.fake.returns({ | ||
|
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 |
---|---|---|
|
@@ -141,25 +141,6 @@ describe("reset password check email controller", () => { | |
); | ||
}); | ||
|
||
it("should redirect to /password-reset-required when temporarilySuspended and passwordResetRequired statuses applied to users account and they try to reset their password", async () => { | ||
const fakeService = fakeVerifyCodeServiceHelper(true); | ||
const fakeInterventionsService = accountInterventionsFakeHelper( | ||
"[email protected]", | ||
true, | ||
false, | ||
true | ||
); | ||
|
||
await resetPasswordCheckEmailPost(fakeService, fakeInterventionsService)( | ||
req as Request, | ||
res as Response | ||
); | ||
|
||
expect(res.redirect).to.have.calledWith( | ||
PATH_NAMES.PASSWORD_RESET_REQUIRED | ||
); | ||
}); | ||
|
||
it("should redirect to /reset-password without calling the account interventions service when session.user.withinForcedPasswordResetJourney === true", async () => { | ||
req.session.user.withinForcedPasswordResetJourney = true; | ||
const fakeService = fakeVerifyCodeServiceHelper(true); | ||
|