From 1a287b1fbc10bd70f442edcd886d23d8ad44b8bd Mon Sep 17 00:00:00 2001 From: Frenkel Date: Tue, 19 Jan 2021 17:13:29 +0200 Subject: [PATCH 1/3] feat: retrieving the sub via the tenant name env var --- README.md | 4 +- src/appstudio_context.ts | 56 +++++---- test/context_manager.spec.ts | 234 +++++++++++++++++------------------ 3 files changed, 149 insertions(+), 145 deletions(-) diff --git a/README.md b/README.md index 083b0c1..4cbb0b9 100644 --- a/README.md +++ b/README.md @@ -49,9 +49,11 @@ Environment variables example: ``` "FT_SERVER_ENDPOINT": "http://unleash.herokuapp.com", -"WS_BASE_URL": "https://cfsubaccount-workspaces-ws-id.region.applicationstudio.cloud.sap", +"WS_BASE_URL": "https://workspaces-ws-id.region.applicationstudio.cloud.sap", "USER_NAME": "user@hotmail.com", "FT_CLIENT_REFRESH_INTERVAL": "6s", +"TENANT_ID" : "b5c05535-9495-4050-9d68-4356d0d34136", +"TENANT_NAME": "cfsubaccount" // subaccount "SHOW_LOG": "true", ``` diff --git a/src/appstudio_context.ts b/src/appstudio_context.ts index 1c66fc7..1fe14c3 100644 --- a/src/appstudio_context.ts +++ b/src/appstudio_context.ts @@ -1,3 +1,4 @@ +import { parse } from "url"; import { Context as appstudioContext } from "unleash-client/lib/context"; import { getEnv } from "./utils"; @@ -6,8 +7,9 @@ const WS_BASE_URL = "WS_BASE_URL"; const LANDSCAPE_ENVIRONMENT = "LANDSCAPE_ENVIRONMENT"; const LANDSCAPE_NAME = "LANDSCAPE_NAME"; const TENANT_ID = "TENANT_ID"; +const SUB_ACCOUNT = "TENANT_NAME"; -const fullFormatWsBaseUrl = "Expected format: https://-workspaces-ws-../"; +const fullFormatWsBaseUrl = "Expected format: https://workspaces-ws-../"; export interface AppStudioMultiContext extends appstudioContext { currentEnvironment: string; //app @@ -19,52 +21,56 @@ export interface AppStudioMultiContext extends appstudioContext { currentTenantId: string; } -function extractCfSubAccountAndWs(wsBaseUrlString: string, context: AppStudioMultiContext): void { - // Example - sub account with hyphen - // https://consumer-trial-workspaces-ws-9gzgq.eu10.trial.applicationstudio.cloud.sap/ - // consumer-trial: the cf sub account - // ws-9gzgq: the WS +function extractWs(wsBaseUrl: string): string { + // Example: + // https://workspaces-ws-9gzgq.eu10.trial.applicationstudio.cloud.sap/ - const regex = new RegExp("^(https:)\\S*(-workspaces-ws-)\\S*", "g"); - if (!regex.test(wsBaseUrlString)) { + const regex = new RegExp("^(https:)\\S*(workspaces-ws-)\\S*", "g"); + if (!regex.test(wsBaseUrl)) { throw new Error(`Feature toggle env WS_BASE_URL is NOT in the correct format. ${fullFormatWsBaseUrl}`); } - // make wsBaseUrlString: [consumer-trial, ws-9gzgq.eu10.trial.applicationstudio.cloud.sap/] - const splitByWorkspaces = wsBaseUrlString.substr(8).split("-workspaces-"); - context.currentCfSubAccount = splitByWorkspaces[0]; // sub account: "consumer-trial" + // strip the "https" + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const wsBaseUrlNormalize = parse(wsBaseUrl).host!; // ! because it is tested in the regex - // turn ws-9gzgq.eu10.trial.applicationstudio.cloud.sap/ to [ws-9gzgq, eu10,trial, ...] - const splitDotArray = splitByWorkspaces[1].split("."); + // remove "workspaces-" to get: "ws-9gzgq.eu10.trial.applicationstudio.cloud.sap/"" + const wsBaseUrlWorkspaces = wsBaseUrlNormalize.replace("workspaces-", ""); - context.currentWs = splitDotArray[0]; // workspace: ws-n8vmz + // convert ws-9gzgq.eu10.trial.applicationstudio.cloud.sap/ to [ws-9gzgq, eu10,trial, ...] + const splitByDotArray = wsBaseUrlWorkspaces.split("."); + + const currentWs = splitByDotArray[0]; // workspace: "ws-9gzgq" + return currentWs; } export function createContextObject(): AppStudioMultiContext { // get the user name from the env - const userName = getEnv(USER_NAME, "Feature toggle env USER_NAME was NOT found in the environment variables"); + const userName = getEnv(USER_NAME, `Feature toggle env ${USER_NAME} was NOT found in the environment variables`); // get the environment from the env - const environment = getEnv(LANDSCAPE_ENVIRONMENT, "Feature toggle env LANDSCAPE_ENVIRONMENT was NOT found in the environment variables"); + const environment = getEnv(LANDSCAPE_ENVIRONMENT, `Feature toggle env ${LANDSCAPE_ENVIRONMENT} was NOT found in the environment variables`); // get the landscape from the env - const landscape = getEnv(LANDSCAPE_NAME, "Feature toggle env LANDSCAPE_NAME was NOT found in the environment variables"); + const landscape = getEnv(LANDSCAPE_NAME, `Feature toggle env ${LANDSCAPE_NAME} was NOT found in the environment variables`); + // get the tenant id from the env + const tenantId = getEnv(TENANT_ID, `Feature toggle env ${TENANT_ID} was NOT found in the environment variables`); // get the tenant id from the env - const tenantId = getEnv(TENANT_ID, "Feature toggle env TENANT_ID was NOT found in the environment variables"); + const subAccount = getEnv(SUB_ACCOUNT, `Feature toggle env ${SUB_ACCOUNT} was NOT found in the environment variables`); + // get WS_BASE_URL env + const wsBaseUrlString = getEnv(WS_BASE_URL, "Feature toggle env WS_BASE_URL was NOT found in the environment variables"); + + // Extract the WS and cluster and save in the context + const ws = extractWs(wsBaseUrlString); // Create the context const context: AppStudioMultiContext = { currentEnvironment: environment, currentInfrastructure: "", currentLandscape: landscape, - currentCfSubAccount: "", // will be added in the next function + currentCfSubAccount: subAccount, currentUser: userName, - currentWs: "", // will be added in the next function + currentWs: ws, currentTenantId: tenantId, }; - // get the WS and SubAccount from WS_BASE_URL env - const wsBaseUrlString = getEnv(WS_BASE_URL, "Feature toggle env WS_BASE_URL was NOT found in the environment variables"); - // Extract the WS and cluster and save in the context - extractCfSubAccountAndWs(wsBaseUrlString, context); - return context; } diff --git a/test/context_manager.spec.ts b/test/context_manager.spec.ts index 7e92024..6bbec90 100644 --- a/test/context_manager.spec.ts +++ b/test/context_manager.spec.ts @@ -8,10 +8,12 @@ describe("Test context manager", () => { const extensionNameA = "aaa"; const extensionNameB = "bbb"; - const USER = "koko@sap.com"; - const ENVIRONMENT = "prod"; - const LANDSCAPE = "eu10"; - const TENANTID = "111-a11-111"; + const user = "koko@sap.com"; + const env = "prod"; + const landscape = "eu10"; + const tenantId = "111-a11-111"; + const subAccount = "azureconseu"; + const ws = "ws-n8vmz"; let contextMap; afterEach(() => { @@ -20,151 +22,145 @@ describe("Test context manager", () => { beforeEach(() => { sinon.stub(process, "env").value({ - WS_BASE_URL: "https://azureconseu-workspaces-ws-n8vmz.eu20.applicationstudio.cloud.sap/", - USER_NAME: USER, - LANDSCAPE_ENVIRONMENT: ENVIRONMENT, - LANDSCAPE_NAME: LANDSCAPE, - TENANT_ID: TENANTID, + WS_BASE_URL: "https://workspaces-ws-n8vmz.eu20.applicationstudio.cloud.sap/", + USER_NAME: user, + LANDSCAPE_ENVIRONMENT: env, + LANDSCAPE_NAME: landscape, + TENANT_ID: tenantId, + TENANT_NAME: subAccount, }); contextMap = new Map(); }); - function testNoEnvError(extensionName: string, contextMap: Map, errorMessage: string): void { - expect(() => { - contextManager.getContextFromMap(extensionName, contextMap); - }).to.throw(errorMessage); - } + describe("getContext cache", () => { + it("return the same instance from cache", () => { + // create context - NOT in cache -> create a new one + const contextACreated = contextManager.getContext(extensionNameA); + // create context - in cache -> only get from cache + const contextAFromCache = contextManager.getContext(extensionNameA); - it("Test getContext - positive flow", () => { - // create context - NOT in cache -> create a new one - const contextACreated = contextManager.getContext(extensionNameA); - // create context - in cache -> only get from cache - const contextAFromCache = contextManager.getContext(extensionNameA); - - // same instance, ref compare - expect(contextACreated === contextAFromCache).to.be.true; - }); - - it("Test getContext - not fetching from cache when when using different extensions names", () => { - // create context - NOT in cache -> create a new one - const contextACreated = contextManager.getContextFromMap(extensionNameA, contextMap); - // create context - NOT in cache -> create a new one - const contextBCreated = contextManager.getContextFromMap(extensionNameB, contextMap); - - // NOT same instance, ref compare - expect(contextACreated === contextBCreated).to.be.false; - }); - - it("Test context - getContext - getting the expected context values - positive flow", () => { - //WS_BASE_URL: "https://azureconseu-workspaces-ws-n8vmz.eu20.applicationstudio.cloud.sap/", - - const expectedContext: AppStudioMultiContext = { - currentEnvironment: ENVIRONMENT, - currentInfrastructure: "", - currentLandscape: LANDSCAPE, - currentCfSubAccount: "azureconseu", - currentUser: USER, - currentWs: "ws-n8vmz", - currentTenantId: TENANTID, - }; + // same instance, ref compare + expect(contextACreated === contextAFromCache).to.be.true; + }); - // create context - NOT in cache -> create a new one - const contextA: AppStudioMultiContext = contextManager.getContextFromMap(extensionNameA, contextMap); + it("return different instances from cache when when using different extensions names", () => { + // create context - NOT in cache -> create a new one + const contextACreated = contextManager.getContextFromMap(extensionNameA, contextMap); + // create context - NOT in cache -> create a new one + const contextBCreated = contextManager.getContextFromMap(extensionNameB, contextMap); - expect(contextA).to.deep.equal(expectedContext); + // NOT same instance, ref compare + expect(contextACreated === contextBCreated).to.be.false; + }); }); - it("Test context - getContext - getting the expected context values - positive flow", () => { - sinon.stub(process, "env").value({ - WS_BASE_URL: "https://consumer-trial-workspaces-ws-9gzgq.eu10.trial.applicationstudio.cloud.sap/", - USER_NAME: USER, - LANDSCAPE_ENVIRONMENT: ENVIRONMENT, - LANDSCAPE_NAME: LANDSCAPE, - TENANT_ID: TENANTID, + describe("getContextFromMap", () => { + function testNoEnvError(extensionName: string, contextMap: Map, errorMessage: string): void { + expect(() => { + contextManager.getContextFromMap(extensionName, contextMap); + }).to.throw(errorMessage); + } + + it("getting the expected context values", () => { + //WS_BASE_URL: "https://workspaces-ws-n8vmz.eu20.applicationstudio.cloud.sap/", + + const expectedContext: AppStudioMultiContext = { + currentEnvironment: env, + currentInfrastructure: "", + currentLandscape: landscape, + currentCfSubAccount: subAccount, + currentUser: user, + currentWs: ws, + currentTenantId: tenantId, + }; + + // create context - NOT in cache -> create a new one + const contextA: AppStudioMultiContext = contextManager.getContextFromMap(extensionNameA, contextMap); + + expect(contextA).to.deep.equal(expectedContext); }); - const expectedContext: AppStudioMultiContext = { - currentEnvironment: ENVIRONMENT, - currentInfrastructure: "", - currentLandscape: LANDSCAPE, - currentCfSubAccount: "consumer-trial", - currentUser: USER, - currentWs: "ws-9gzgq", - currentTenantId: TENANTID, - }; - - // create context - NOT in cache -> create a new one - const contextA = contextManager.getContextFromMap(extensionNameA, contextMap); - - expect(contextA).to.deep.equal(expectedContext); - }); + it("getting error for lack of 'workspaces-ws-' in WS_BASE_URL", () => { + sinon.stub(process, "env").value({ + WS_BASE_URL: "https://azureconseun8vmz.eu20", + USER_NAME: user, + LANDSCAPE_ENVIRONMENT: env, + LANDSCAPE_NAME: landscape, + TENANT_ID: tenantId, + TENANT_NAME: subAccount, + }); + + testNoEnvError(extensionNameA, contextMap, `Feature toggle env WS_BASE_URL is NOT in the correct format. Expected format: https://workspaces-ws-../`); + }); - it("Test context - getContext - getting error for lack of '-workspaces-ws-' in WS_BASE_URL - negative flow", () => { - sinon.stub(process, "env").value({ - WS_BASE_URL: "https://azureconseun8vmz.eu20", - USER_NAME: USER, - LANDSCAPE_ENVIRONMENT: ENVIRONMENT, - LANDSCAPE_NAME: LANDSCAPE, - TENANT_ID: TENANTID, + it("getting error for when using http instead of https in WS_BASE_URL", () => { + sinon.stub(process, "env").value({ + WS_BASE_URL: "http://workspaces-ws-n8vmz.eu20.applicationstudio.cloud.sap/", + USER_NAME: user, + LANDSCAPE_ENVIRONMENT: env, + LANDSCAPE_NAME: landscape, + TENANT_ID: tenantId, + TENANT_NAME: subAccount, + }); + + testNoEnvError(extensionNameA, contextMap, `Feature toggle env WS_BASE_URL is NOT in the correct format. Expected format: https://workspaces-ws-../`); }); - testNoEnvError(extensionNameA, contextMap, `Feature toggle env WS_BASE_URL is NOT in the correct format. Expected format: https://-workspaces-ws-../`); - }); + it("getting error for no WS_BASE_URL env parameter", () => { + sinon.stub(process, "env").value({ + USER_NAME: user, + LANDSCAPE_ENVIRONMENT: env, + LANDSCAPE_NAME: landscape, + TENANT_ID: tenantId, + TENANT_NAME: subAccount, + }); - it("Test context - getContext - getting error for when using http instead of https in WS_BASE_URL - negative flow", () => { - sinon.stub(process, "env").value({ - WS_BASE_URL: "http://azureconseu-workspaces-ws-n8vmz.eu20.applicationstudio.cloud.sap/", - USER_NAME: USER, - LANDSCAPE_ENVIRONMENT: ENVIRONMENT, - LANDSCAPE_NAME: LANDSCAPE, - TENANT_ID: TENANTID, + testNoEnvError(extensionNameA, contextMap, "Feature toggle env WS_BASE_URL was NOT found in the environment variables"); }); - testNoEnvError(extensionNameA, contextMap, `Feature toggle env WS_BASE_URL is NOT in the correct format. Expected format: https://-workspaces-ws-../`); - }); + it("getting error for no TENANT_NAME env parameter", () => { + sinon.stub(process, "env").value({ + USER_NAME: user, + LANDSCAPE_ENVIRONMENT: env, + LANDSCAPE_NAME: landscape, + TENANT_ID: tenantId, + }); - it("Test context - getContext - getting error for no WS_BASE_URL env parameter - negative flow", () => { - sinon.stub(process, "env").value({ - USER_NAME: USER, - LANDSCAPE_ENVIRONMENT: ENVIRONMENT, - LANDSCAPE_NAME: LANDSCAPE, - TENANT_ID: TENANTID, + testNoEnvError(extensionNameA, contextMap, "Feature toggle env TENANT_NAME was NOT found in the environment variables"); }); - testNoEnvError(extensionNameA, contextMap, "Feature toggle env WS_BASE_URL was NOT found in the environment variables"); - }); + it("getting error for no USER_NAME env parameter", () => { + sinon.stub(process, "env").value({}); - it("Test context - getContext - getting error for no USER_NAME env parameter - negative flow", () => { - sinon.stub(process, "env").value({}); + testNoEnvError(extensionNameA, contextMap, "Feature toggle env USER_NAME was NOT found in the environment variables"); + }); - testNoEnvError(extensionNameA, contextMap, "Feature toggle env USER_NAME was NOT found in the environment variables"); - }); + it("getting error for no LANDSCAPE_ENVIRONMENT env parameter", () => { + sinon.stub(process, "env").value({ + USER_NAME: user, + }); - it("Test context - getContext - getting error for no LANDSCAPE_ENVIRONMENT env parameter - negative flow", () => { - sinon.stub(process, "env").value({ - USER_NAME: USER, + testNoEnvError(extensionNameA, contextMap, "Feature toggle env LANDSCAPE_ENVIRONMENT was NOT found in the environment variables"); }); - testNoEnvError(extensionNameA, contextMap, "Feature toggle env LANDSCAPE_ENVIRONMENT was NOT found in the environment variables"); - }); + it("getting error for no TENANT_ID env parameter", () => { + sinon.stub(process, "env").value({ + USER_NAME: user, + LANDSCAPE_ENVIRONMENT: env, + LANDSCAPE_NAME: landscape, + }); - it("Test context - getContext - getting error for no LANDSCAPE_NAME env parameter - negative flow", () => { - sinon.stub(process, "env").value({ - USER_NAME: USER, - LANDSCAPE_ENVIRONMENT: ENVIRONMENT, + testNoEnvError(extensionNameA, contextMap, "Feature toggle env TENANT_ID was NOT found in the environment variables"); }); - testNoEnvError(extensionNameA, contextMap, "Feature toggle env LANDSCAPE_NAME was NOT found in the environment variables"); - }); + it("getting error for no LANDSCAPE_NAME env parameter", () => { + sinon.stub(process, "env").value({ + USER_NAME: user, + LANDSCAPE_ENVIRONMENT: env, + }); - it("Test context - getContext - getting error for no TENANT_ID env parameter - negative flow", () => { - sinon.stub(process, "env").value({ - USER_NAME: USER, - LANDSCAPE_ENVIRONMENT: ENVIRONMENT, - LANDSCAPE_NAME: LANDSCAPE, + testNoEnvError(extensionNameA, contextMap, "Feature toggle env LANDSCAPE_NAME was NOT found in the environment variables"); }); - - testNoEnvError(extensionNameA, contextMap, "Feature toggle env TENANT_ID was NOT found in the environment variables"); }); }); From 24fbac48ea304e3d4ee8ae583f85bc2ce182cdf3 Mon Sep 17 00:00:00 2001 From: Frenkel Date: Wed, 20 Jan 2021 11:32:15 +0200 Subject: [PATCH 2/3] chore: added WORKSPACE_ID instead of WS_BASE_URL --- src/appstudio_context.ts | 45 ++++++++--------------------------- test/context_manager.spec.ts | 46 +++++++----------------------------- 2 files changed, 19 insertions(+), 72 deletions(-) diff --git a/src/appstudio_context.ts b/src/appstudio_context.ts index 1fe14c3..62129b8 100644 --- a/src/appstudio_context.ts +++ b/src/appstudio_context.ts @@ -1,15 +1,12 @@ -import { parse } from "url"; import { Context as appstudioContext } from "unleash-client/lib/context"; import { getEnv } from "./utils"; const USER_NAME = "USER_NAME"; -const WS_BASE_URL = "WS_BASE_URL"; const LANDSCAPE_ENVIRONMENT = "LANDSCAPE_ENVIRONMENT"; const LANDSCAPE_NAME = "LANDSCAPE_NAME"; const TENANT_ID = "TENANT_ID"; const SUB_ACCOUNT = "TENANT_NAME"; - -const fullFormatWsBaseUrl = "Expected format: https://workspaces-ws-../"; +const WORKSPACE_ID = "WORKSPACE_ID"; export interface AppStudioMultiContext extends appstudioContext { currentEnvironment: string; //app @@ -21,45 +18,23 @@ export interface AppStudioMultiContext extends appstudioContext { currentTenantId: string; } -function extractWs(wsBaseUrl: string): string { - // Example: - // https://workspaces-ws-9gzgq.eu10.trial.applicationstudio.cloud.sap/ - - const regex = new RegExp("^(https:)\\S*(workspaces-ws-)\\S*", "g"); - if (!regex.test(wsBaseUrl)) { - throw new Error(`Feature toggle env WS_BASE_URL is NOT in the correct format. ${fullFormatWsBaseUrl}`); - } - - // strip the "https" - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const wsBaseUrlNormalize = parse(wsBaseUrl).host!; // ! because it is tested in the regex - - // remove "workspaces-" to get: "ws-9gzgq.eu10.trial.applicationstudio.cloud.sap/"" - const wsBaseUrlWorkspaces = wsBaseUrlNormalize.replace("workspaces-", ""); - - // convert ws-9gzgq.eu10.trial.applicationstudio.cloud.sap/ to [ws-9gzgq, eu10,trial, ...] - const splitByDotArray = wsBaseUrlWorkspaces.split("."); - - const currentWs = splitByDotArray[0]; // workspace: "ws-9gzgq" - return currentWs; +function getEnvWithNotFoundError(envVar: string): string { + return getEnv(envVar, `Feature toggle env ${envVar} was NOT found in the environment variables`); } export function createContextObject(): AppStudioMultiContext { // get the user name from the env - const userName = getEnv(USER_NAME, `Feature toggle env ${USER_NAME} was NOT found in the environment variables`); + const userName = getEnvWithNotFoundError(USER_NAME); // get the environment from the env - const environment = getEnv(LANDSCAPE_ENVIRONMENT, `Feature toggle env ${LANDSCAPE_ENVIRONMENT} was NOT found in the environment variables`); + const environment = getEnvWithNotFoundError(LANDSCAPE_ENVIRONMENT); // get the landscape from the env - const landscape = getEnv(LANDSCAPE_NAME, `Feature toggle env ${LANDSCAPE_NAME} was NOT found in the environment variables`); + const landscape = getEnvWithNotFoundError(LANDSCAPE_NAME); // get the tenant id from the env - const tenantId = getEnv(TENANT_ID, `Feature toggle env ${TENANT_ID} was NOT found in the environment variables`); + const tenantId = getEnvWithNotFoundError(TENANT_ID); // get the tenant id from the env - const subAccount = getEnv(SUB_ACCOUNT, `Feature toggle env ${SUB_ACCOUNT} was NOT found in the environment variables`); - // get WS_BASE_URL env - const wsBaseUrlString = getEnv(WS_BASE_URL, "Feature toggle env WS_BASE_URL was NOT found in the environment variables"); - - // Extract the WS and cluster and save in the context - const ws = extractWs(wsBaseUrlString); + const subAccount = getEnvWithNotFoundError(SUB_ACCOUNT); + // get WORKSPACE_ID env + const ws = getEnvWithNotFoundError(WORKSPACE_ID); // Create the context const context: AppStudioMultiContext = { diff --git a/test/context_manager.spec.ts b/test/context_manager.spec.ts index 6bbec90..9869c98 100644 --- a/test/context_manager.spec.ts +++ b/test/context_manager.spec.ts @@ -13,7 +13,7 @@ describe("Test context manager", () => { const landscape = "eu10"; const tenantId = "111-a11-111"; const subAccount = "azureconseu"; - const ws = "ws-n8vmz"; + const ws = "workspaces-ws-n8vmz"; let contextMap; afterEach(() => { @@ -22,12 +22,12 @@ describe("Test context manager", () => { beforeEach(() => { sinon.stub(process, "env").value({ - WS_BASE_URL: "https://workspaces-ws-n8vmz.eu20.applicationstudio.cloud.sap/", USER_NAME: user, LANDSCAPE_ENVIRONMENT: env, LANDSCAPE_NAME: landscape, TENANT_ID: tenantId, TENANT_NAME: subAccount, + WORKSPACE_ID: ws, }); contextMap = new Map(); @@ -63,8 +63,6 @@ describe("Test context manager", () => { } it("getting the expected context values", () => { - //WS_BASE_URL: "https://workspaces-ws-n8vmz.eu20.applicationstudio.cloud.sap/", - const expectedContext: AppStudioMultiContext = { currentEnvironment: env, currentInfrastructure: "", @@ -81,33 +79,7 @@ describe("Test context manager", () => { expect(contextA).to.deep.equal(expectedContext); }); - it("getting error for lack of 'workspaces-ws-' in WS_BASE_URL", () => { - sinon.stub(process, "env").value({ - WS_BASE_URL: "https://azureconseun8vmz.eu20", - USER_NAME: user, - LANDSCAPE_ENVIRONMENT: env, - LANDSCAPE_NAME: landscape, - TENANT_ID: tenantId, - TENANT_NAME: subAccount, - }); - - testNoEnvError(extensionNameA, contextMap, `Feature toggle env WS_BASE_URL is NOT in the correct format. Expected format: https://workspaces-ws-../`); - }); - - it("getting error for when using http instead of https in WS_BASE_URL", () => { - sinon.stub(process, "env").value({ - WS_BASE_URL: "http://workspaces-ws-n8vmz.eu20.applicationstudio.cloud.sap/", - USER_NAME: user, - LANDSCAPE_ENVIRONMENT: env, - LANDSCAPE_NAME: landscape, - TENANT_ID: tenantId, - TENANT_NAME: subAccount, - }); - - testNoEnvError(extensionNameA, contextMap, `Feature toggle env WS_BASE_URL is NOT in the correct format. Expected format: https://workspaces-ws-../`); - }); - - it("getting error for no WS_BASE_URL env parameter", () => { + it("getting error for no WORKSPACE_ID environment variable", () => { sinon.stub(process, "env").value({ USER_NAME: user, LANDSCAPE_ENVIRONMENT: env, @@ -116,10 +88,10 @@ describe("Test context manager", () => { TENANT_NAME: subAccount, }); - testNoEnvError(extensionNameA, contextMap, "Feature toggle env WS_BASE_URL was NOT found in the environment variables"); + testNoEnvError(extensionNameA, contextMap, "Feature toggle env WORKSPACE_ID was NOT found in the environment variables"); }); - it("getting error for no TENANT_NAME env parameter", () => { + it("getting error for no TENANT_NAME environment variable", () => { sinon.stub(process, "env").value({ USER_NAME: user, LANDSCAPE_ENVIRONMENT: env, @@ -130,13 +102,13 @@ describe("Test context manager", () => { testNoEnvError(extensionNameA, contextMap, "Feature toggle env TENANT_NAME was NOT found in the environment variables"); }); - it("getting error for no USER_NAME env parameter", () => { + it("getting error for no USER_NAME environment variable", () => { sinon.stub(process, "env").value({}); testNoEnvError(extensionNameA, contextMap, "Feature toggle env USER_NAME was NOT found in the environment variables"); }); - it("getting error for no LANDSCAPE_ENVIRONMENT env parameter", () => { + it("getting error for no LANDSCAPE_ENVIRONMENT environment variable", () => { sinon.stub(process, "env").value({ USER_NAME: user, }); @@ -144,7 +116,7 @@ describe("Test context manager", () => { testNoEnvError(extensionNameA, contextMap, "Feature toggle env LANDSCAPE_ENVIRONMENT was NOT found in the environment variables"); }); - it("getting error for no TENANT_ID env parameter", () => { + it("getting error for no TENANT_ID environment variable", () => { sinon.stub(process, "env").value({ USER_NAME: user, LANDSCAPE_ENVIRONMENT: env, @@ -154,7 +126,7 @@ describe("Test context manager", () => { testNoEnvError(extensionNameA, contextMap, "Feature toggle env TENANT_ID was NOT found in the environment variables"); }); - it("getting error for no LANDSCAPE_NAME env parameter", () => { + it("getting error for no LANDSCAPE_NAME environment variable", () => { sinon.stub(process, "env").value({ USER_NAME: user, LANDSCAPE_ENVIRONMENT: env, From 6dd7ddf90284f9c38190f6a0c0dfa874adefab0b Mon Sep 17 00:00:00 2001 From: Frenkel Date: Wed, 20 Jan 2021 11:43:11 +0200 Subject: [PATCH 3/3] chore: readme update --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4cbb0b9..a3a68c2 100644 --- a/README.md +++ b/README.md @@ -48,12 +48,12 @@ To run the feature-toggle-node **locally**, you need to provide the following en Environment variables example: ``` -"FT_SERVER_ENDPOINT": "http://unleash.herokuapp.com", -"WS_BASE_URL": "https://workspaces-ws-id.region.applicationstudio.cloud.sap", +"FT_SERVER_ENDPOINT": "http://unleash.herokuapp.com", "USER_NAME": "user@hotmail.com", "FT_CLIENT_REFRESH_INTERVAL": "6s", "TENANT_ID" : "b5c05535-9495-4050-9d68-4356d0d34136", -"TENANT_NAME": "cfsubaccount" // subaccount +"TENANT_NAME": "cfsubaccount" // subaccount, +"WORKSPACE_ID": "workspaces-ws-x66m6", "SHOW_LOG": "true", ```