Skip to content

Commit

Permalink
Fix missing IDP headers in E2E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joonashak committed May 20, 2024
1 parent 1f85d7b commit 0932fb5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
10 changes: 10 additions & 0 deletions e2e/tests/global.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { test as setup } from "@playwright/test";

setup("Mock Shibboleth headers", async ({ page }) => {
await page.route("**/*", async (route) => {
const headers = route.request().headers();
headers["x-shib-employeeid"] = "123";
headers["x-shib-eppn"] = "joku@testi.com";
await route.continue({ headers });
});
});
1 change: 1 addition & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ WORKDIR /usr/src/web
COPY web/package.json web/package-lock.json ./
RUN npm ci
COPY web .
ARG VITE_MOCK_EMPLOYEE_NUMBER=123
RUN --mount=type=secret,id=mui_x_license \
VITE_MUI_X_LICENSE=$(cat /run/secrets/mui_x_license) npm run build

Expand Down
9 changes: 3 additions & 6 deletions web/src/common/ApolloProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ const apiUrl = import.meta.env.VITE_API_URL_OVERRIDE || import.meta.env.VITE_API

const httpLink = new HttpLink({
uri: apiUrl,
headers:
import.meta.env.NODE_ENV === "production"
? {}
: {
"x-shib-employeeid": import.meta.env.VITE_MOCK_EMPLOYEE_NUMBER || "",
},
headers: import.meta.env.VITE_MOCK_EMPLOYEE_NUMBER
? { "x-shib-employeeid": import.meta.env.VITE_MOCK_EMPLOYEE_NUMBER || "" }
: {},
});

const errorLink = onError(({ graphQLErrors, networkError }) => {
Expand Down

0 comments on commit 0932fb5

Please sign in to comment.