• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / blurts-server / 00f7475d-b1a7-44af-928a-2bcf33438993

pending completion
00f7475d-b1a7-44af-928a-2bcf33438993

Pull #2989

circleci

Vincent
fixup! fixup! fixup! fixup! Store exposure scan data at OneRep
Pull Request #2989: Add API to store data to scan for exposures

282 of 1740 branches covered (16.21%)

Branch coverage included in aggregate %.

117 of 117 new or added lines in 9 files covered. (100.0%)

959 of 4624 relevant lines covered (20.74%)

3.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/client/js/partials/exposures-setup.js
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4

5
/** @type {HTMLDivElement} */
6
// @ts-ignore: We guard against a null value by not calling init():
7
const exposuresSetupPartial = document.querySelector("[data-partial='exposuresSetup']")
×
8

9
if (exposuresSetupPartial) {
×
10
  init()
×
11
}
12

13
async function init () {
14
  const dataEl = /** @type {HTMLTemplateElement} */ (exposuresSetupPartial.querySelector('#data'))
×
15
  const csrfToken = /** @type {string} */ (dataEl.dataset.csrfToken)
×
16

17
  const mockButton = /** @type {HTMLButtonElement} */ (exposuresSetupPartial.querySelector('#storeMockData'))
×
18
  mockButton.addEventListener('click', async () => {
×
19
    await storeMockData(csrfToken)
×
20
    document.location.reload()
×
21
  })
22
}
23

24
/**
25
 * @param {string} csrfToken
26
 */
27
async function storeMockData (csrfToken) {
28
  /** @type {import('../../../external/onerep').ProfileData} */
29
  const requestBody = {
×
30
    city: 'Tulsa',
31
    first_name: 'John',
32
    last_name: 'Doe',
33
    state: 'OK'
34
  }
35

36
  try {
×
37
    const res = await fetch('/api/v1/user/exposures/', {
×
38
      headers: {
39
        'Content-Type': 'application/json',
40
        'x-csrf-token': csrfToken,
41
        Accept: 'application/json'
42
      },
43
      mode: 'same-origin',
44
      method: 'POST',
45
      body: JSON.stringify(requestBody)
46
    })
47

48
    if (!res.ok) {
×
49
      throw new Error('Immediately caught to show an error message.')
×
50
    }
51

52
    /** @type {import("../../../controllers/request-breach-scan").RequestBreachScanResponse} */
53
    const responseBody = await res.json()
×
54

55
    if (!responseBody.success) {
×
56
      throw new Error('Immediately caught to show an error message.')
×
57
    }
58
  } catch (e) {
59
  }
60
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc