From f92f47871363cdf397302986b5bc93608fb825a6 Mon Sep 17 00:00:00 2001 From: Aleksi Ahtiainen Date: Mon, 21 Oct 2024 09:15:05 +0300 Subject: [PATCH] =?UTF-8?q?WIP:=20Lis=C3=A4=C3=A4=20luovutuspalvelu=20e2e-?= =?UTF-8?q?testeihin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/omadataoauth2_setup_playwright/action.yml | 5 +++++ .github/workflows/omadataoauth2sample_test.yml | 10 +++++++++- omadata-oauth2-sample/client/package.json | 3 +++ omadata-oauth2-sample/client/playwright.config.ts | 2 +- omadata-oauth2-sample/server/src/index.ts | 10 ++++++++++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/.github/actions/omadataoauth2_setup_playwright/action.yml b/.github/actions/omadataoauth2_setup_playwright/action.yml index 6eb63475d64..2fb0eb55d9b 100644 --- a/.github/actions/omadataoauth2_setup_playwright/action.yml +++ b/.github/actions/omadataoauth2_setup_playwright/action.yml @@ -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 diff --git a/.github/workflows/omadataoauth2sample_test.yml b/.github/workflows/omadataoauth2sample_test.yml index 0853504f2ae..e491eca9429 100644 --- a/.github/workflows/omadataoauth2sample_test.yml +++ b/.github/workflows/omadataoauth2sample_test.yml @@ -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 }} diff --git a/omadata-oauth2-sample/client/package.json b/omadata-oauth2-sample/client/package.json index 0a4c6f85b8e..7e7b02b3d0b 100644 --- a/omadata-oauth2-sample/client/package.json +++ b/omadata-oauth2-sample/client/package.json @@ -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", diff --git a/omadata-oauth2-sample/client/playwright.config.ts b/omadata-oauth2-sample/client/playwright.config.ts index 04dc1324dbb..14b2ffe4478 100644 --- a/omadata-oauth2-sample/client/playwright.config.ts +++ b/omadata-oauth2-sample/client/playwright.config.ts @@ -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, }, diff --git a/omadata-oauth2-sample/server/src/index.ts b/omadata-oauth2-sample/server/src/index.ts index 069749e94dc..73ef85dd11b 100644 --- a/omadata-oauth2-sample/server/src/index.ts +++ b/omadata-oauth2-sample/server/src/index.ts @@ -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: @@ -208,6 +212,9 @@ async function fetchAccessToken(url: string): Promise { async function handleAccessTokenRequest(url: string): Promise { 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) } @@ -322,6 +329,9 @@ async function handleDataRequest( ): Promise { 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) }