Skip to content

Commit

Permalink
Merge branch 'AddEnvVariableForKeycloakClient' into PrefillAnnotation…
Browse files Browse the repository at this point in the history
…ClassesWithValues
  • Loading branch information
TomDijkema committed Dec 11, 2024
2 parents 2420772 + c10405f commit f8dc551
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- image: public.ecr.aws/dissco/${{ github.event.repository.name }}-production
keycloak_client: production-disscover-fe
- image: public.ecr.aws/dissco/${{ github.event.repository.name }}
keycloak_client: orchestration-service
steps:
- uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -36,7 +43,7 @@ jobs:
id: meta
uses: docker/metadata-action@v4
with:
images: public.ecr.aws/dissco/${{ github.event.repository.name }}
images: ${{ matrix.image }}
tags: |
type=sha
type=raw,value=latest
Expand All @@ -48,6 +55,8 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
"VITE_KEYCLOAK_CLIENT=${{ matrix.keycloak_client }}"
- name: Set outputs
id: vars
Expand Down
4 changes: 4 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ RUN cp 'src/app/GenerateTypes.js' 'src/app/GenerateTypes.cjs'
RUN rm 'src/app/GenerateTypes.js'
RUN node 'src/app/GenerateTypes.cjs'

# Set env variables
ARG VITE_KEYCLOAK_CLIENT
ENV VITE_KEYCLOAK_CLIENT ${VITE_KEYCLOAK_CLIENT}

# Setting app to production build
RUN npm run build

Expand Down
2 changes: 1 addition & 1 deletion src/app/Keycloak.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Callback = () => Function | void;
const keycloak = new Keycloak({
url: "https://login-demo.dissco.eu/auth",
realm: "dissco",
clientId: "orchestration-service",
clientId: import.meta.env.VITE_KEYCLOAK_CLIENT,
});

const InitKeyCloak = (callback?: Callback, token?: string) => {
Expand Down
2 changes: 1 addition & 1 deletion src/tests/AppRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ afterEach(() => Server.resetHandlers());
afterAll(() => Server.close());

/* Mock Keycloak Service */
vi.mock('keycloak/Keycloak.ts', async () => {
vi.mock('app/Keycloak.ts', async () => {
const KeycloakService = await vi.importMock('tests/mock/keycloak/KeycloakService.ts');

return {
Expand Down
13 changes: 10 additions & 3 deletions src/tests/mock/keycloak/KeycloakService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,28 @@ const Logout = () => {

const GetToken = () => {
return 'KeycloakToken';
}
};

const GetParsedToken = () => ({
orcid: 'https://orcid.org/0000-0000-0000-0000',
given_name: 'Pietje',
family_name: 'Puk'
});

const IsLoggedIn = () => {
return true;
}
};

const GetSubject = () => {
return 'SubjectId';
}
};

const KeycloakService = {
Login,
Logout,
IsLoggedIn,
GetToken,
GetParsedToken,
GetSubject
};

Expand Down

0 comments on commit f8dc551

Please sign in to comment.