Skip to content

Commit

Permalink
ui test
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmweisz committed Dec 17, 2024
1 parent b13c0fc commit 54b351d
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 28 deletions.
31 changes: 31 additions & 0 deletions src/Template.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { renderFile } from "ejs";
import { join } from "path";

describe("button configuration renders correctly", () => {
const templatePath = join(__dirname, "..", "views", "login_selection.ejs");

test("does not render element", async () => {
const html = await renderFile(templatePath, {
login_gov_enabled: false,
mhv_logon_enabled: false,
ds_logon_enabled: false,
id_me_login_link: "something",
});
expect(html).not.toMatch(/DS Logon/);
expect(html).not.toMatch(/My HealtheVet/);
});

test("does render element", async () => {
const html = await renderFile(templatePath, {
login_gov_enabled: true,
mhv_logon_enabled: true,
ds_logon_enabled: true,
id_me_login_link: "something",
mhv_login_link: "something",
dslogon_login_link: "something",
login_gov_login_link: "something",
});
expect(html).toMatch(/DS Logon/);
expect(html).toMatch(/My HealtheVet/);
});
});
2 changes: 1 addition & 1 deletion src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ export function processArgs() {
default: true,
},
mhvLogonEnabled: {
description: "Enables MHV Logon signin option, enabled by default",
description: "Enables MHV signin option, enabled by default",
required: false,
boolean: true,
default: true,
Expand Down
34 changes: 7 additions & 27 deletions src/routes/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ export const samlLogin = function (template) {
});
});
}, Promise.resolve({}))
.then((authOptions) => {
authOptions.mhv_logon_enabled = isMhvLogonEnabled(req);
authOptions.ds_logon_enabled = isDsLogonEnabled(req);
authOptions.body = template;
authOptions.login_gov_enabled = login_gov_enabled;
authOptions.login_gov_signup_link_enabled =
.then((loginViewModel) => {
loginViewModel.mhv_logon_enabled = !!req.sps?.options?.id_me?.mhvLogonEnabled;

Check failure on line 126 in src/routes/handlers.js

View workflow job for this annotation

GitHub Actions / Lint

Insert `⏎··········`

Check failure on line 126 in src/routes/handlers.js

View workflow job for this annotation

GitHub Actions / Lint

Insert `⏎··········`
loginViewModel.ds_logon_enabled = !!req.sps?.options?.id_me?.dsLogonEnabled;

Check failure on line 127 in src/routes/handlers.js

View workflow job for this annotation

GitHub Actions / Lint

Insert `⏎··········`

Check failure on line 127 in src/routes/handlers.js

View workflow job for this annotation

GitHub Actions / Lint

Insert `⏎··········`
loginViewModel.body = template;
loginViewModel.login_gov_enabled = login_gov_enabled;
loginViewModel.login_gov_signup_link_enabled =
login_gov_enabled && req.sps.options.logingov.signupLinkEnabled;
res.render("layout", authOptions);
res.render("layout", loginViewModel);
logger.info("User arrived from Okta. Rendering IDP login template.", {
action: "parseSamlRequest",
result: "success",
Expand Down Expand Up @@ -201,23 +201,3 @@ function enabled_logingov(req) {
}
return false;
}

/**
* Is MHV enabled?
*
* @param {*} req service provider request
* @returns {*} boolean
*/
function isMhvLogonEnabled(req) {
return !!req.sps.options.id_me.mhvLogonEnabled;
}

/**
* Is DS Logon enabled?
*
* @param {*} req service provider request
* @returns {*} boolean
*/
function isDsLogonEnabled(req) {
return !!req.sps.options.id_me.dsLogonEnabled;
}
14 changes: 14 additions & 0 deletions src/routes/handlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ describe("samlLogin", () => {

const spOptionsJustIdMe = {
id_me: {
dsLogonEnabled: true,
mhvLogonEnabled: true,
idpLoginLink:
"https://api.idmelabs.com/saml/SingleSignOnService?SAMLRequest=fVJNTwIxED37Lza9s13BaGxYAoGYkOBHQD14G8sITfqxdmYR%2F73dZSEc1GQP3c57M%2B%2B96ZDA2UpNat76JX7WSJztnfWk2kIp6uhVADKkPDgkxVqtJvcL1c8LVcXAQQcrzij%2FM4AII5vgRTaflWI8ns%2FG43QmqnHuicFzKfpFv%2BgVt71i8Hx5ra7Sd%2FsmsovJkTsNnmqHcYVxZzS%2BLBel2DJXSkobNNhtIFY3RVHI1kMM%2B29JVfsjiYK4mCWXxkPT68CkRIXK5Gbt0MI75Tq4A35l%2FMbiymz8o%2B%2FmiewVI7XcZElkdyFqbAMsBccaxWjYUFVrKo5OGvIdbMIuX%2BNuKM8Bw8MKHlJY89lTsEZ%2FNz0d8P9ZNjdm3ftooapqNBGjZ5FNrA1f04jA2EmSxyndjnHdCk5JMu45mwZXQTTUeMI9aD56OEdNbdreEj9GXdYpLPCwQZdm5smZ9CQToo7gNaZNgBx0Rn%2Ftcqj9oehUPX%2BYox8%3D&RelayState=%2F&SigAlg=http%3A%2F%2Fwww.w3.org%2F2001%2F04%2Fxmldsig-more%23rsa-sha256&Signature=crqsP27LiAeJpKx7%2Bjshr4OeqHvFnp1rYmkP4rHTYXdEIjp6iIo7Zu3uwzXfkm%2BJp0ShXPAy7R6855y1dMBmOz3eVjdvdm8rQ7%2B044hTw3Cxmcuf836up4rsKLeT4vIHc3%2FA3qtDK3ut%2FXiArNLZJ%2FwOrC6KNWAuhJQ8fZIPv18uiCw1eNBJA2iCUD6KKtI%2FDgwA%2B1MtpRCsHNcpX23XQryIPkH8l6MsRDw1ZM3vttF7UZa6OkIsxFEXFJ4VZMal%2BciNZV%2FiB0%2FK3QvmbbKX8k%2BuJKL8rmIJr0XhNw%2BYLcMTNnpL%2FTQloi0xS18gu3J6GY%2BTEsG1CeJRNHkuJyF3LQ%3D%3D",
getResponseParams: () => {
Expand All @@ -135,6 +137,8 @@ describe("samlLogin", () => {

const spOptionsJustwithLoginGov = {
id_me: {
dsLogonEnabled: true,
mhvLogonEnabled: true,
idpLoginLink:
"https://api.idmelabs.com/saml/SingleSignOnService?SAMLRequest=fVJNTwIxED37Lza9s13BaGxYAoGYkOBHQD14G8sITfqxdmYR%2F73dZSEc1GQP3c57M%2B%2B96ZDA2UpNat76JX7WSJztnfWk2kIp6uhVADKkPDgkxVqtJvcL1c8LVcXAQQcrzij%2FM4AII5vgRTaflWI8ns%2FG43QmqnHuicFzKfpFv%2BgVt71i8Hx5ra7Sd%2FsmsovJkTsNnmqHcYVxZzS%2BLBel2DJXSkobNNhtIFY3RVHI1kMM%2B29JVfsjiYK4mCWXxkPT68CkRIXK5Gbt0MI75Tq4A35l%2FMbiymz8o%2B%2FmiewVI7XcZElkdyFqbAMsBccaxWjYUFVrKo5OGvIdbMIuX%2BNuKM8Bw8MKHlJY89lTsEZ%2FNz0d8P9ZNjdm3ftooapqNBGjZ5FNrA1f04jA2EmSxyndjnHdCk5JMu45mwZXQTTUeMI9aD56OEdNbdreEj9GXdYpLPCwQZdm5smZ9CQToo7gNaZNgBx0Rn%2Ftcqj9oehUPX%2BYox8%3D&RelayState=%2F&SigAlg=http%3A%2F%2Fwww.w3.org%2F2001%2F04%2Fxmldsig-more%23rsa-sha256&Signature=crqsP27LiAeJpKx7%2Bjshr4OeqHvFnp1rYmkP4rHTYXdEIjp6iIo7Zu3uwzXfkm%2BJp0ShXPAy7R6855y1dMBmOz3eVjdvdm8rQ7%2B044hTw3Cxmcuf836up4rsKLeT4vIHc3%2FA3qtDK3ut%2FXiArNLZJ%2FwOrC6KNWAuhJQ8fZIPv18uiCw1eNBJA2iCUD6KKtI%2FDgwA%2B1MtpRCsHNcpX23XQryIPkH8l6MsRDw1ZM3vttF7UZa6OkIsxFEXFJ4VZMal%2BciNZV%2FiB0%2FK3QvmbbKX8k%2BuJKL8rmIJr0XhNw%2BYLcMTNnpL%2FTQloi0xS18gu3J6GY%2BTEsG1CeJRNHkuJyF3LQ%3D%3D",
getResponseParams: () => {
Expand All @@ -155,6 +159,8 @@ describe("samlLogin", () => {
},
},
logingov: {
dsLogonEnabled: true,
mhvLogonEnabled: true,
idpLoginLink:
"https://idp.int.identitysandbox.gov/api/saml/metadata2021?SAMLRequest=fVJNTwIxED37Lza9s13BaGxYAoGYkOBHQD14G8sITfqxdmYR%2F73dZSEc1GQP3c57M%2B%2B96ZDA2UpNat76JX7WSJztnfWk2kIp6uhVADKkPDgkxVqtJvcL1c8LVcXAQQcrzij%2FM4AII5vgRTaflWI8ns%2FG43QmqnHuicFzKfpFv%2BgVt71i8Hx5ra7Sd%2FsmsovJkTsNnmqHcYVxZzS%2BLBel2DJXSkobNNhtIFY3RVHI1kMM%2B29JVfsjiYK4mCWXxkPT68CkRIXK5Gbt0MI75Tq4A35l%2FMbiymz8o%2B%2FmiewVI7XcZElkdyFqbAMsBccaxWjYUFVrKo5OGvIdbMIuX%2BNuKM8Bw8MKHlJY89lTsEZ%2FNz0d8P9ZNjdm3ftooapqNBGjZ5FNrA1f04jA2EmSxyndjnHdCk5JMu45mwZXQTTUeMI9aD56OEdNbdreEj9GXdYpLPCwQZdm5smZ9CQToo7gNaZNgBx0Rn%2Ftcqj9oehUPX%2BYox8%3D&RelayState=%2F&SigAlg=http%3A%2F%2Fwww.w3.org%2F2001%2F04%2Fxmldsig-more%23rsa-sha256&Signature=crqsP27LiAeJpKx7%2Bjshr4OeqHvFnp1rYmkP4rHTYXdEIjp6iIo7Zu3uwzXfkm%2BJp0ShXPAy7R6855y1dMBmOz3eVjdvdm8rQ7%2B044hTw3Cxmcuf836up4rsKLeT4vIHc3%2FA3qtDK3ut%2FXiArNLZJ%2FwOrC6KNWAuhJQ8fZIPv18uiCw1eNBJA2iCUD6KKtI%2FDgwA%2B1MtpRCsHNcpX23XQryIPkH8l6MsRDw1ZM3vttF7UZa6OkIsxFEXFJ4VZMal%2BciNZV%2FiB0%2FK3QvmbbKX8k%2BuJKL8rmIJr0XhNw%2BYLcMTNnpL%2FTQloi0xS18gu3J6GY%2BTEsG1CeJRNHkuJyF3LQ%3D%3D",
getResponseParams: () => {
Expand Down Expand Up @@ -206,6 +212,8 @@ describe("samlLogin", () => {
"https://identityProviderUrl.com?SAMLRequest=utrequest&RelayState=&op=signup",
login_gov_enabled: false,
login_gov_signup_link_enabled: false,
ds_logon_enabled: true,
mhv_logon_enabled: true,
};

const expected_authoptions = {
Expand All @@ -220,6 +228,8 @@ describe("samlLogin", () => {
"https://identityProviderUrl.com?SAMLRequest=utrequest&RelayState=&op=signup",
login_gov_enabled: false,
login_gov_signup_link_enabled: false,
ds_logon_enabled: true,
mhv_logon_enabled: true,
};

const expected_authoptions_failure_to_proof = {
Expand All @@ -234,6 +244,8 @@ describe("samlLogin", () => {
"https://identityProviderUrl.com?SAMLRequest=utrequest&RelayState=&op=signup",
login_gov_enabled: false,
login_gov_signup_link_enabled: false,
ds_logon_enabled: true,
mhv_logon_enabled: true,
};
const expected_authoptions_login_gov_enabled = {
body: "login_selection",
Expand All @@ -251,6 +263,8 @@ describe("samlLogin", () => {
login_gov_signup_link_enabled: true,
login_gov_signup_link:
"https://identityProviderUrl.com?SAMLRequest=utrequest&RelayState=",
ds_logon_enabled: true,
mhv_logon_enabled: true,
};

const mockGetSamlRequestUrl = jest
Expand Down

0 comments on commit 54b351d

Please sign in to comment.