Skip to content

Commit

Permalink
WIP: Lisää luovutuspalvelu e2e-testeihin
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksiAhtiainen committed Oct 21, 2024
1 parent e661665 commit f92f478
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .github/actions/omadataoauth2_setup_playwright/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ runs:
working-directory: omadata-oauth2-sample/client
run: npm ci
shell: bash
- name: Install project dependencies luovutuspalvelu
working-directory: koski-luovutuspalvelu/proxy
run: npm ci
shell: bash

- name: Get playwright version
working-directory: omadata-oauth2-sample/client
id: playwright-version
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/omadataoauth2sample_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,15 @@ jobs:
shardTotal: [1]
if: ${{ !contains(github.event.head_commit.message, '[skip-tests]') }}
steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4

- name: Checkout luovutuspalvelu for e2e tests
uses: actions/checkout@v4
with:
repository: Opetushallitus/koski-luovutuspalvelu
path: koski-luovutuspalvelu

- uses: ./.github/actions/omadataoauth2_e2e_test
with:
shardIndex: ${{ matrix.shardIndex }}
Expand Down
3 changes: 3 additions & 0 deletions omadata-oauth2-sample/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
"start": "react-scripts start",
"start-server": "npm run --prefix ../server start",
"start-with-server": "npm-run-all --parallel start-server start",
"start-with-server-and-luovutuspalvelu": "npm-run-all --parallel start-luovutuspalvelu start-server start",
"build-luovutuspalvelu": "cd ../../koski-luovutuspalvelu/proxy && mkdir -p ./target && npm run buildversion && npm run testca && node ./scripts/create-local-config.js > ./target/koski-luovutuspalvelu-proxy-config-ci.json && docker build --rm --pull --platform=linux/amd64 --tag koski-luovutuspalvelu-proxy:latest . && sleep 5",
"start-luovutuspalvelu": "docker run --name koski-luovutuspalvelu-proxy -p 7022:443 -v \"$PWD/../../koski-luovutuspalvelu/proxy/target/koski-luovutuspalvelu-proxy-config-ci.json:/etc/nginx/koski-luovutuspalvelu-proxy-config.json:ro\" -d -m 256m --rm koski-luovutuspalvelu-proxy:latest",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
Expand Down
2 changes: 1 addition & 1 deletion omadata-oauth2-sample/client/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default defineConfig({

/* Run your local dev server before starting the tests */
webServer: {
command: `KOSKI_BACKEND_HOST=${process.env.KOSKI_BACKEND_HOST} npm-run-all --parallel start-server start`,
command: `npm run build-luovutuspalvelu && npm run start-with-server-and-luovutuspalvelu`,
url: "http://localhost:7050",
reuseExistingServer: !process.env.CI,
},
Expand Down
10 changes: 10 additions & 0 deletions omadata-oauth2-sample/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ const enableMTLS = process.env.ENABLE_MTLS
? process.env.ENABLE_MTLS !== 'false'
: true

const enableLocalMTLS = process.env.ENABLE_LOCAL_MTLS
? process.env.ENABLE_LOCAL_MTLS !== 'false'
: true

const clientId = process.env.CLIENT_ID || 'oauth2client'

// Käytössä, jos mTLS on disabloitu:
Expand Down Expand Up @@ -208,6 +212,9 @@ async function fetchAccessToken(url: string): Promise<AccessTokenData> {
async function handleAccessTokenRequest(url: string): Promise<FetchResponse> {
if (enableMTLS) {
return await handleAccessTokenRequestMTLS(url)
} else if (enableLocalMTLS) {
// TODO: TOR-2210: käytä paikallista konffia, avaimet luovutuspalvelun testi-certeistä
return await handleAccessTokenRequestMTLS(url)
} else {
return await handleAccessTokenRequestBasicAuth(url)
}
Expand Down Expand Up @@ -322,6 +329,9 @@ async function handleDataRequest(
): Promise<FetchResponse> {
if (enableMTLS) {
return await handleDataRequestMTLS(accessToken, url)
} else if (enableLocalMTLS) {
// TODO: TOR-2210: käytä paikallista konffia, avaimet luovutuspalvelun testi-certeistä
return await handleDataRequestMTLS(accessToken, url)
} else {
return await handleDataRequestBasicAuth(accessToken, url)
}
Expand Down

0 comments on commit f92f478

Please sign in to comment.