Skip to content

Commit

Permalink
Remove Okta integration (#4)
Browse files Browse the repository at this point in the history
* Remove Okta integration

* Added port
  • Loading branch information
kebrahim committed Oct 1, 2020
1 parent 557c33f commit a00f1b4
Show file tree
Hide file tree
Showing 27 changed files with 335 additions and 536 deletions.
4 changes: 0 additions & 4 deletions client/author/.env.development

This file was deleted.

4 changes: 0 additions & 4 deletions client/author/.env.production

This file was deleted.

4 changes: 0 additions & 4 deletions client/author/.env.test

This file was deleted.

1 change: 0 additions & 1 deletion client/author/package.json
Expand Up @@ -82,7 +82,6 @@
]
},
"dependencies": {
"@okta/okta-react": "^3.0.7",
"@reduxjs/toolkit": "^1.1.0",
"@types/react-redux": "^7.1.9",
"axios": "^0.20.0",
Expand Down
5 changes: 0 additions & 5 deletions client/author/public/locales/en/translation.json
Expand Up @@ -44,11 +44,6 @@
"title": "Oops...",
"validationFailed": "This service could not be saved because one or more fields were reported as invalid by the server."
},
"authentication": {
"authFailedRedirect": "You will be redirected to the home screen after 10 seconds.",
"notLoggedIn": "You need to log in.",
"loading": "Loading..."
},
"manageServices": {
"addService": "Add Service",
"dismiss": "Dismiss",
Expand Down
5 changes: 0 additions & 5 deletions client/author/public/locales/translation.description.json
Expand Up @@ -28,11 +28,6 @@
"label": ""
}
},
"authentication": {
"authFailedRedirect": "Notifies the user why authentication failed and notifies of a redirect to home screen. Appears if authentication failed.",
"notLoggedIn": "Notifies the user they need to login. Appears if the user refreshes on the callback redirect page.",
"loading": "A simple loading placeholder text while user is being authenticated. Appears while authentication is occurring for the first time on the current session."
},
"report": {
"apply": {
"criteria": "Header highlighting information describing additional criteria needed to apply for the service. This and the others in the report section should be the same as the equivalent keys in Maslow Access.",
Expand Down
8 changes: 1 addition & 7 deletions client/author/src/App.test.js
Expand Up @@ -4,12 +4,6 @@ import React from "react";
import { renderWith } from "maslow-shared/src/util/testing";
import axios from "axios";

jest.mock("@okta/okta-react", () => ({
useOktaAuth: () => ({
authState: { isAuthenticated: true },
authService: { handleAuthentication: jest.fn() },
}),
}));
jest.mock("axios");
// @ts-ignore
axios.get.mockResolvedValue({
Expand All @@ -32,7 +26,7 @@ axios.get.mockResolvedValue({
},
});

describe.skip("App entrypoint", () => {
describe("App entrypoint", () => {
beforeEach(async () => {
const options = {
routerOptions: {
Expand Down
48 changes: 20 additions & 28 deletions client/author/src/Routes.jsx
Expand Up @@ -4,42 +4,34 @@ import ManageServices from "features/manageServices/ManageServices";
import UpdateService from "features/updateService/UpdateService";
import UpdateServiceLocale from "features/updateServiceLocale/UpdateServiceLocale";
import HttpError from "components/HttpError";
import oktaConfig from "./auth/oktaConfig";
import CustomLoginCallback from "./auth/CustomLoginCallback";
import { useTranslation } from "react-i18next";
import { Security, SecureRoute } from "@okta/okta-react";

/**
* @returns {React.ReactElement} Routes the supported paths to components
*/
function Routes() {
const { t } = useTranslation();

return (
<Security {...oktaConfig.oidc}>
<Switch>
<SecureRoute exact path="/">
<Redirect to="/app/services" push={true} />
</SecureRoute>
<Route path="/callback" component={CustomLoginCallback} />
<SecureRoute
path="/app/services/create"
render={() => <UpdateService isNew={true} />}
/>
<SecureRoute
path="/app/services/update/:id/locale/:lng"
component={UpdateServiceLocale}
/>
<SecureRoute
path="/app/services/update/:id"
component={UpdateService}
/>
<SecureRoute path="/app/services" component={ManageServices} />
<SecureRoute
path="*"
render={() => <HttpError errorMessage={t("httpError.generic404")} />}
/>
</Switch>
</Security>
<Switch>
<Route exact path="/">
<Redirect to="/app/services" push={true} />
</Route>
<Route
path="/app/services/create"
render={() => <UpdateService isNew={true} />}
/>
<Route
path="/app/services/update/:id/locale/:lng"
component={UpdateServiceLocale}
/>
<Route path="/app/services/update/:id" component={UpdateService} />
<Route path="/app/services" component={ManageServices} />
<Route
path="*"
render={() => <HttpError errorMessage={t("httpError.generic404")} />}
></Route>
</Switch>
);
}

Expand Down
8 changes: 1 addition & 7 deletions client/author/src/Routes.test.js
Expand Up @@ -5,12 +5,6 @@ import { renderWith } from "maslow-shared/src/util/testing";
import Routes from "Routes";
import axios from "axios";

jest.mock("@okta/okta-react", () => ({
useOktaAuth: () => ({
authState: { isAuthenticated: true },
authService: { handleAuthentication: jest.fn() },
}),
}));
jest.mock("react-router-dom", () => ({
...jest.requireActual("react-router-dom"),
useParams: () => ({ id: "DOL_UA", lng: "es" }),
Expand Down Expand Up @@ -52,7 +46,7 @@ const services = {
DOL_UA: DOL_UA,
};

describe.skip("Routes", () => {
describe("Routes", () => {
afterEach(() => jest.clearAllMocks);
it("routes / to ManageServices", async () => {
// @ts-ignore
Expand Down
46 changes: 0 additions & 46 deletions client/author/src/auth/CustomLoginCallback.jsx

This file was deleted.

88 changes: 0 additions & 88 deletions client/author/src/auth/CustomLoginCallback.test.js

This file was deleted.

21 changes: 0 additions & 21 deletions client/author/src/auth/oktaConfig.js

This file was deleted.

12 changes: 0 additions & 12 deletions client/author/src/auth/setAuthToken.js

This file was deleted.

2 changes: 1 addition & 1 deletion client/author/src/components/HttpError.test.js
Expand Up @@ -7,7 +7,7 @@ import { renderWith } from "maslow-shared/src/util/testing";

expect.extend(toHaveNoViolations);

describe.skip("The 404 page", () => {
describe("The 404 page", () => {
let container;

beforeEach(() => {
Expand Down
9 changes: 1 addition & 8 deletions client/author/src/features/manageServices/ManageServices.jsx
Expand Up @@ -8,8 +8,6 @@ import _ from "lodash";
import HttpError from "components/HttpError";
import { renderMessage, visibilityMapper } from "utils/inputUtils";
import { TranslationStatus } from "./TranslationStatus";
import { useOktaAuth } from "@okta/okta-react";
import { setAuthToken } from "auth/setAuthToken";

/**
* ManageServices is a component for seeing all services in the Author UI.
Expand All @@ -22,18 +20,13 @@ function ManageServices() {
const [updateMessage] = useState(_.get(location, "state.updateMessage", ""));
const [dismissed, setDismissed] = useState(false);

const { authState } = useOktaAuth();

const [services, setServices] = useState({});
const [order, setOrder] = useState([]);
const [loadingError, setLoadingError] = useState(false);

// Retrieves catalog data from API.
const fetchData = useCallback(async () => {
try {
const accessToken = authState.accessToken;
// set default http requests to have Bearer accessToken in Authorization header
setAuthToken(accessToken);
const response = await axios.get("/api/author/v1/services");
const data = response.data;
const services = data.services;
Expand All @@ -49,7 +42,7 @@ function ManageServices() {
} catch (err) {
setLoadingError(true);
}
}, [setServices, setOrder, setLoadingError, authState]);
}, [setServices, setOrder, setLoadingError]);

// Fetch data from the API upon page load.
useEffect(() => {
Expand Down

0 comments on commit a00f1b4

Please sign in to comment.