Use compute auth service and fix static code analyzer warnings (#15)

* Clean up formatting

* Use new compute_auth service
Implment SSO
Implement token refresh
Clean up unit tests

* Fix unit tests

* Fix auth test
Fix warnings

* Update default settings for compute_auth
This commit is contained in:
John Wu
2021-03-04 14:30:56 -08:00
committed by GitHub
parent e1f0006d5e
commit 39e779dc1d
34 changed files with 703 additions and 1462 deletions

View File

@@ -1,11 +1,11 @@
jest.mock("../Contexts/UserContext");
jest.mock("../Contexts/FileUploadContext");
import { render, screen, cleanup, waitForElementToBeRemoved, waitFor } from "@testing-library/react"
import { render, screen, cleanup, waitForElementToBeRemoved } from "@testing-library/react";
import { setToken } from "../Contexts/UserContext";
import App from ".";
const TEST_TOKEN = { idToken: { jwtToken: "TEST" }};
const TEST_TOKEN = { idToken: { jwtToken: "TEST" } };
const LOADING_STATUS = "Loading...";
const renderRoute = async (route) => {
@@ -26,19 +26,13 @@ describe("App", () => {
it("Route / unauthenticated", async () => {
const container = await renderRoute("/");
expect(container.querySelector("h1").innerHTML).toEqual("Sign in");
expect(container).toMatchSnapshot();
});
it("Route /signup unauthenticated", async () => {
const container = await renderRoute("/signup");
expect(container.querySelector("h1").innerHTML).toEqual("Sign up");
expect(container.querySelector("h1").innerHTML).toEqual("Fisker OTA Portal");
expect(container).toMatchSnapshot();
});
it("Route /home unauthenticated", async () => {
const container = await renderRoute("/home");
expect(container.querySelector("h1").innerHTML).toEqual("Sign in");
expect(container.querySelector("h1").innerHTML).toEqual("Fisker OTA Portal");
expect(container).toMatchSnapshot();
});
@@ -49,13 +43,6 @@ describe("App", () => {
expect(container).toMatchSnapshot();
});
it("Route /signup authenticated", async () => {
setToken(TEST_TOKEN);
const container = await renderRoute("/signup");
expect(container.querySelector("h1").innerHTML).toEqual("Upload file");
expect(container).toMatchSnapshot();
});
it("Route /home authenticated", async () => {
setToken(TEST_TOKEN);
const container = await renderRoute("/home");