Skip to content

Commit

Permalink
fix: Breach resolution test
Browse files Browse the repository at this point in the history
  • Loading branch information
flozia committed Apr 5, 2023
1 parent f5d2da1 commit a0290e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 1 addition & 3 deletions src/utils/breach-resolution.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,9 @@ async function appendBreachResolutionChecklist (userBreachData, options = {}) {
const showLink = b.Domain &&
!AppConstants.HIBP_BREACH_LINK_BLOCKLIST.includes(b.Domain)

console.log(b.Domain, showLink)

const args = {
companyName: b.Name,
breachedCompanyLink: !showLink
breachedCompanyLink: showLink
? `<a href="https://${b.Domain}" target="_blank">${b.Domain}</a>`
: 'empty',
firefoxRelayLink: `<a href="https://relay.firefox.com/?utm_medium=mozilla-websites&utm_source=monitor&utm_campaign=&utm_content=breach-resolution" target="_blank">${getMessage('breach-checklist-link-firefox-relay')}</a>`,
Expand Down
13 changes: 9 additions & 4 deletions src/utils/breach-resolution.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,18 @@ test('appendBreachResolutionChecklist: data class with a resolution referring to
unverifiedEmails: []
}
appendBreachResolutionChecklist(userBreachData)
// There should only be a resolution for `BreachDataTypes.Phone`, as
// `BreachDataTypes.Passwords` and `BreachDataTypes.SecurityQuestions` refer
// to the breached company's domain, which we don't know:
// There should be a resolution for `BreachDataTypes.Phone`,
// `BreachDataTypes.Passwords` and `BreachDataTypes.SecurityQuestions`.
// The last two should fallback to a more generic header string that does not
// include the breached company's domain, which we don't know:
t.deepEqual(
Object.keys(userBreachData.verifiedEmails[0].breaches[0].breachChecklist),
[BreachDataTypes.Phone]
[BreachDataTypes.Phone, BreachDataTypes.Passwords, BreachDataTypes.SecurityQuestions]
)
t.is(userBreachData.verifiedEmails[0].breaches[0].breachChecklist[BreachDataTypes.Passwords].header,
'Go to the company’s website to change your password and enable two-factor authentication (2FA).')
t.is(userBreachData.verifiedEmails[0].breaches[0].breachChecklist[BreachDataTypes.SecurityQuestions].header,
'Update your security questions on the company’s website.')
})

test('appendBreachResolutionChecklist: data class with a resolution referring to the breach\'s domain, which is available', t => {
Expand Down

0 comments on commit a0290e5

Please sign in to comment.