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

mozilla / blurts-server / d9c77947-e4e8-4674-963c-053f795817eb

pending completion
d9c77947-e4e8-4674-963c-053f795817eb

Pull #2989

circleci

Vincent
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
  /** @type {HTMLTemplateElement} */
15
  const dataEl = exposuresSetupPartial.querySelector('#data')
×
16
  const csrfToken = dataEl.dataset.csrfToken
×
17

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

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

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

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

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

53
    if (!responseBody.success) {
×
54
      throw new Error('Immediately caught to show an error message.')
×
55
    }
56
  } catch (e) {
57
  }
58
}
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