From a726c6f41c578016e9401697a876394fa8974ff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Dybvik=20Langfors?= Date: Tue, 5 Nov 2024 14:33:00 +0100 Subject: [PATCH] Use yt01 token generator environment for k6 tests running on yt01 --- tests/k6/common/config.js | 1 + tests/k6/common/token.js | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/k6/common/config.js b/tests/k6/common/config.js index 9841e1c16..faf9a4500 100644 --- a/tests/k6/common/config.js +++ b/tests/k6/common/config.js @@ -41,5 +41,6 @@ if (!baseUrls[__ENV.API_VERSION]["serviceowner"][__ENV.API_ENVIRONMENT]) { export const baseUrlEndUser = baseUrls[__ENV.API_VERSION]["enduser"][__ENV.API_ENVIRONMENT]; export const baseUrlServiceOwner = baseUrls[__ENV.API_VERSION]["serviceowner"][__ENV.API_ENVIRONMENT]; +export const tokenGeneratorEnv = __ENV.API_ENVIRONMENT == "yt01" ? "yt01" : "tt02"; // yt01 is the only environment that has a separate token generator environment export const sentinelValue = "dialogporten-e2e-sentinel"; diff --git a/tests/k6/common/token.js b/tests/k6/common/token.js index cd9ed8dae..c1f69ad34 100644 --- a/tests/k6/common/token.js +++ b/tests/k6/common/token.js @@ -1,7 +1,7 @@ import http from "k6/http"; import encoding from "k6/encoding"; import { extend } from "./extend.js"; -import { defaultEndUserSsn, defaultServiceOwnerOrgNo } from "./config.js"; +import { defaultEndUserSsn, defaultServiceOwnerOrgNo, tokenGeneratorEnv } from "./config.js"; let defaultTokenOptions = { scopes: "digdir:dialogporten digdir:dialogporten.serviceprovider digdir:dialogporten.serviceprovider.search", @@ -57,14 +57,14 @@ function fetchToken(url, tokenOptions, type) { export function getServiceOwnerTokenFromGenerator(tokenOptions = null) { let fullTokenOptions = extend({}, defaultTokenOptions, tokenOptions); - const url = `http://altinn-testtools-token-generator.azurewebsites.net/api/GetEnterpriseToken?env=tt02&scopes=${encodeURIComponent(fullTokenOptions.scopes)}&org=${fullTokenOptions.orgName}&orgNo=${fullTokenOptions.orgNo}&ttl=${tokenTtl}`; - return fetchToken(url, fullTokenOptions, `service owner (orgno:${fullTokenOptions.orgNo} orgName:${fullTokenOptions.orgName})`); + const url = `http://altinn-testtools-token-generator.azurewebsites.net/api/GetEnterpriseToken?env=${tokenGeneratorEnv}&scopes=${encodeURIComponent(fullTokenOptions.scopes)}&org=${fullTokenOptions.orgName}&orgNo=${fullTokenOptions.orgNo}&ttl=${tokenTtl}`; + return fetchToken(url, fullTokenOptions, `service owner (orgno:${fullTokenOptions.orgNo} orgName:${fullTokenOptions.orgName} tokenGeneratorEnv:${tokenGeneratorEnv})`); } export function getEnduserTokenFromGenerator(tokenOptions = null) { let fullTokenOptions = extend({}, defaultTokenOptions, tokenOptions); - const url = `http://altinn-testtools-token-generator.azurewebsites.net/api/GetPersonalToken?env=tt02&scopes=${encodeURIComponent(fullTokenOptions.scopes)}&pid=${fullTokenOptions.ssn}&ttl=${tokenTtl}`; - return fetchToken(url, fullTokenOptions, `end user (ssn:${fullTokenOptions.ssn})`); + const url = `http://altinn-testtools-token-generator.azurewebsites.net/api/GetPersonalToken?env=${tokenGeneratorEnv}&scopes=${encodeURIComponent(fullTokenOptions.scopes)}&pid=${fullTokenOptions.ssn}&ttl=${tokenTtl}`; + return fetchToken(url, fullTokenOptions, `end user (ssn:${fullTokenOptions.ssn}, tokenGeneratorEnv:${tokenGeneratorEnv})`); } export function getDefaultEnduserOrgNo() {