Skip to content

Commit 06f69a1

Browse files
authored
Merge pull request #6191 from mozilla/update-docs-testing-breach
chore(breach-alerts): update README to test breach alerts cron
2 parents 013f551 + 722a27c commit 06f69a1

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ curl -d '{ "breachName": "000webhost", "hashPrefix": "test", "hashSuffixes": ["t
212212
This emulates HIBP notifying our API that a new breach was found. Our API will
213213
then add it to the (emulated) pubsub queue.
214214

215+
You can also use this request with staging credentials and endpoint to manually trigger alerts in the staging environment. For instructions on how to generate the hashPrefix and hashSuffix values, see [instructions below](#testing-the-breach-alerts-cron-job-locally).
216+
215217
### This pubsub queue will be consumed by this cron job, which is responsible for looking up and emailing impacted users
216218

217219
```sh
@@ -281,6 +283,29 @@ environment variable (default 30s).
281283
You can also enforce the alert being sent for a specific email address via the
282284
`LOADTEST_BREACHED_EMAIL` environment variable.
283285

286+
#### Testing the Breach Alerts cron job locally
287+
288+
1. Ensure SMTP_URL environment variable is unset; this will log to JSON instead of attempting to send an email
289+
1. Follow instructions to start blurts server locally, including the database and emulated GCP PubSub topic
290+
1. Create a new account, and note the email address you used for the next step
291+
1. Update the email address below and paste into your terminal
292+
293+
```sh
294+
# Replace with whatever email address you used above, or omit and
295+
# export env var first to persist between runs
296+
297+
HIBP_TEST_EMAIL="[email protected]"; \
298+
HASH=$(echo -n "$HIBP_TEST_EMAIL" | sha1sum | awk '{print toupper($1)}'); \
299+
PREFIX=${HASH:0:7}; \
300+
SUFFIX=${HASH:7}; \
301+
curl -d "{\"breachName\": \"000webhost\", \"hashPrefix\": \"$PREFIX\", \"hashSuffixes\": [\"$SUFFIX\"]}" \
302+
-H "Authorization: Bearer unsafe-default-token-for-dev" \
303+
-H "Content-Type: application/json" \
304+
http://localhost:6060/api/v1/hibp/notify
305+
```
306+
307+
Note that the database must be seeded with breaches or else this request will not trigger emails due to validation error. The breachName must match the name of a breach in the database. Query the `breaches` table in the database for additional breach names to test more than once for the same email address (a user will be notified for a breach only once). Alternatively you can delete the record that was created in the `email_notifications` table to retest.
308+
284309
## Localization
285310

286311
All text that is visible to the user is defined in [Fluent](https://projectfluent.org/) files inside `/locales/en/` and `/locales-pending/`. After strings get added to files in the former directory on our `main` branch, they will be made available to our volunteer localizers via Pontoon, Mozilla's localization platform. Be sure to reference the [localization documentation](https://mozilla-l10n.github.io/documentation/localization/dev_best_practices.html) for best practices. It's best to only move the strings to `/locales/en/` when they are more-or-less final and ready for localization. Your PR should be automatically tagged with a reviewer from the [Mozilla L10n team](https://wiki.mozilla.org/L10n:Mozilla_Team) to approve your request.

0 commit comments

Comments
 (0)