-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mfa support to user login (#649)
* Adding 2fa keys * Working 2fa login * Jump on single device * Test fix * Backend tests * Add tests * Fix code style issues with ESLint --------- Co-authored-by: Lint Action <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
3f9759e
commit 83d8765
Showing
37 changed files
with
2,191 additions
and
34 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
grai-frontend/src/components/auth/login/LoginWrapper.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import userEvent from "@testing-library/user-event" | ||
import { act, render, screen, waitFor } from "testing" | ||
import { LOGIN } from "./LoginForm" | ||
import LoginWrapper from "./LoginWrapper" | ||
|
||
test("submit required 2fa", async () => { | ||
const user = userEvent.setup() | ||
|
||
const mocks = [ | ||
{ | ||
request: { | ||
query: LOGIN, | ||
variables: { | ||
username: "email@grai.io", | ||
password: "password", | ||
}, | ||
}, | ||
result: { | ||
data: { | ||
login: { | ||
data: [ | ||
{ | ||
id: "1", | ||
name: "", | ||
__typename: "DeviceData", | ||
}, | ||
], | ||
__typename: "DeviceDataWrapper", | ||
}, | ||
}, | ||
}, | ||
}, | ||
] | ||
|
||
render(<LoginWrapper />, { | ||
guestRoute: true, | ||
loggedIn: false, | ||
path: "/login", | ||
route: "/login", | ||
routes: ["/"], | ||
mocks, | ||
}) | ||
|
||
await act( | ||
async () => await user.type(screen.getByTestId("email"), "email@grai.io"), | ||
) | ||
await act( | ||
async () => await user.type(screen.getByTestId("password"), "password"), | ||
) | ||
|
||
await waitFor(() => { | ||
expect(screen.getByTestId("password")).toHaveValue("password") | ||
}) | ||
|
||
await act( | ||
async () => | ||
await user.click(screen.getByRole("button", { name: /log in/i })), | ||
) | ||
|
||
await waitFor(() => { | ||
expect(screen.getByText("Two Factor Authentication")).toBeInTheDocument() | ||
}) | ||
|
||
await act( | ||
async () => await user.click(screen.getByRole("button", { name: /back/i })), | ||
) | ||
|
||
await act( | ||
async () => await user.click(screen.getByRole("button", { name: /back/i })), | ||
) | ||
}) |
Oops, something went wrong.