Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mntor-3289-1: tests reverted in mntor-3289 #4742

Closed
wants to merge 49 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
bccbb1e
feat: mock HIBP
mansaj May 29, 2024
b32ca9f
Merge branch 'MNTOR-3227-2' of https://github.com/mozilla/blurts-serv…
Jun 11, 2024
a0d9df7
able to default to mock endpoint on failure locally.
Jun 13, 2024
695e1fc
made it host-flexibile for HIBP fallback
Jun 13, 2024
e07af0e
npx prettified fakeBraches.json
Jun 13, 2024
c0b253a
made the code cleaner, and switch back to true endpoint after using f…
Jun 13, 2024
25b590b
got rid of second promise wait
Jun 13, 2024
ffb0550
Merge branch 'main' of https://github.com/mozilla/blurts-server into …
Jun 17, 2024
ab680af
removed other features, kept only the mock endpoint
Jun 17, 2024
184cfcf
made breaches list match the fake breaches for a user
Jun 17, 2024
b7d9575
Merge branch 'main' of https://github.com/mozilla/blurts-server into …
Jun 17, 2024
c922556
Merge branch 'main' of https://github.com/mozilla/blurts-server into …
Jun 18, 2024
dda9c22
file endpoint additions
Jun 20, 2024
d809bea
Merge branch 'main' of https://github.com/mozilla/blurts-server into …
Jun 24, 2024
0f1d778
Merge branch 'main' of https://github.com/mozilla/blurts-server into …
Jun 25, 2024
988997c
funtional commit - mocked accessed endpoints
Jun 25, 2024
fb2d028
fixed the path overwriting issue, added responsive dynamic configurat…
Jun 25, 2024
2a4e504
moved mock user data into a separate file
Jun 26, 2024
0b1d9e5
fixed some code quality and substitued constants with function calls
Jun 26, 2024
f94238e
Merge branch 'main' of https://github.com/mozilla/blurts-server into …
Jun 26, 2024
29b6f0e
Allowed for data to be configured dynamically using an endpoint
Jun 26, 2024
8ec080d
lint fail fixed
Jun 26, 2024
9140e01
Merge branch 'main' of https://github.com/mozilla/blurts-server into …
Jun 26, 2024
f3e9b37
most tests pass when using mock onerep endpoint
Jun 26, 2024
bc7c4de
Merge branch 'main' of https://github.com/mozilla/blurts-server into …
Jun 28, 2024
11cb314
Merge branch 'main' of https://github.com/mozilla/blurts-server into …
Jun 28, 2024
71e5ddf
passes all tests except for those in purchase spec
Jun 28, 2024
d6eb4ed
added production checks
Jun 28, 2024
842b229
fixed lint errors
Jun 29, 2024
9d368c0
reverting smoke test
Jun 29, 2024
29af535
cleaned up query params and dynamic routing
Jun 29, 2024
fa16c41
fixed lint errors and corrected a POST endpoint
Jun 29, 2024
f3378b0
added form input
Jun 30, 2024
0a4e15b
substituted direct magic numbers access to wrapper methods
Jun 30, 2024
f076a56
merging with 3285
Jun 30, 2024
06b25ca
mock endpoint config - basic version
Jun 30, 2024
cf0ebf6
added more type checks and proper defaults
Jun 30, 2024
9fed164
functional OneRep config page, with styling
Jun 30, 2024
c98d0b2
lint error
Jun 30, 2024
f8e6b52
added a configuration endpoint and page for HIBP
Jul 1, 2024
a249654
reset package-lock
Jul 1, 2024
cb8e013
lint
Jul 1, 2024
21a6bc5
package-lock
Jul 1, 2024
839a9da
slightly modified hibp/breaches
Jul 1, 2024
feaf567
removed database retrieval from mock hibp endpoint
Jul 1, 2024
d3219fb
Merge branch 'main' of https://github.com/mozilla/blurts-server into …
Jul 1, 2024
f693e1a
Merged with main + minor error log change
Jul 1, 2024
9401fed
reverted e2e changes
Jul 2, 2024
d581682
e2e check
Jul 2, 2024
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: mock HIBP
  • Loading branch information
mansaj committed May 29, 2024
commit bccbb1e704c05050aeb0cc3c7dade28d03dfd136
61 changes: 61 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
"jest-fail-on-console": "^3.3.0",
"lint-staged": "^15.2.2",
"mjml-browser": "^4.15.3",
"oauth2-mock-server": "^7.1.2",
"prettier": "3.2.5",
"react-intersection-observer": "^9.10.2",
"sass": "^1.77.2",
Expand Down
38 changes: 38 additions & 0 deletions src/app/api/mock/hibp/breachedaccount/range/[hashPrefix]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import { NextResponse } from "next/server";
import { logger } from "../../../../../../functions/server/logging";
import { getSha1 } from "../../../../../../../utils/fxa";
import type { BinaryLike } from "crypto";
type BreachedAccountResponse = {
hashSuffix: string;
websites: string[];
}[];

export function GET() {
const { APP_ENV } = process.env;

// Check if APP_ENV is set to production
if (APP_ENV === "production") {
return NextResponse.json(
{ error: "Endpoint not available in production environment" },
{ status: 403 },
);
}

// Mock data for test email, can be randomized
const userEmail = process.env.E2E_TEST_ACCOUNT_EMAIL;
const currentUserSha = getSha1(userEmail as BinaryLike);
logger.info("Mock endpoint: /breachedaccount/range/");

const data: BreachedAccountResponse = [
{
hashSuffix: currentUserSha.slice(6).toUpperCase(),
websites: ["Adobe"],
},
];

return NextResponse.json(data);
}