Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AUT-1432: Fix secret key display in error state and tests #1632

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ export function setupAuthenticatorAppPost(
);
return renderBadRequest(res, req, TEMPLATE, error, {
qrCode: req.session.user.authAppQrCodeUrl,
secretKey: req.session.user.authAppSecret,
secretKeyFragmentArray: splitSecretKeyIntoFragments(
req.session.user.authAppSecret
),
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { body } from "express-validator";
import { validateBodyMiddleware } from "../../middleware/form-validation-middleware";
import { ValidationChainFunc } from "../../types";
import { Request } from "express";
import { containsNumbersOnly } from "../../utils/strings";
import {
containsNumbersOnly,
splitSecretKeyIntoFragments,
} from "../../utils/strings";

export function validateSetupAuthAppRequest(): ValidationChainFunc {
return [
Expand Down Expand Up @@ -47,6 +50,8 @@ const postValidationLocals = function locals(
): Record<string, unknown> {
return {
qrCode: req.session.user.authAppQrCodeUrl,
secretKey: req.session.user.authAppSecret,
secretKeyFragmentArray: splitSecretKeyIntoFragments(
req.session.user.authAppSecret
),
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe("Integration::setup-authenticator-app", () => {
let cookies: string;
let app: any;
let baseApi: string;
const AUTH_APP_SECRET: string = "MJRGA2KMETI7BEVNT33MOITMEQQUJMAQ";

before(async () => {
decache("../../../app");
Expand All @@ -33,7 +34,7 @@ describe("Integration::setup-authenticator-app", () => {
journey: {
nextPath: PATH_NAMES.CREATE_ACCOUNT_SETUP_AUTHENTICATOR_APP,
},
authAppSecret: "secret",
authAppSecret: AUTH_APP_SECRET,
};

next();
Expand Down Expand Up @@ -89,7 +90,7 @@ describe("Integration::setup-authenticator-app", () => {
expect($("#code-error").text()).to.contains(
"Enter the security code shown in your authenticator app"
);
expect($("#secret-key").text()).to.not.be.empty;
expect($("#secret-key").text()).to.contain(AUTH_APP_SECRET);
})
.expect(400, done);
});
Expand All @@ -108,7 +109,7 @@ describe("Integration::setup-authenticator-app", () => {
expect($("#code-error").text()).to.contains(
"Enter the security code using only 6 digits"
);
expect($("#secret-key").text()).to.not.be.empty;
expect($("#secret-key").text()).to.contain(AUTH_APP_SECRET);
})
.expect(400, done);
});
Expand All @@ -127,7 +128,7 @@ describe("Integration::setup-authenticator-app", () => {
expect($("#code-error").text()).to.contains(
"Enter the security code using only 6 digits"
);
expect($("#secret-key").text()).to.not.be.empty;
expect($("#secret-key").text()).to.contain(AUTH_APP_SECRET);
})
.expect(400, done);
});
Expand Down
Loading