Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.

Commit 96bf94e

Browse files
authored
Fallback introspection access token to azure devops access token (#105)
1 parent 7190967 commit 96bf94e

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/commands/deployment/dashboard.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
logger
88
} from "../../logger";
99
import { validatePrereqs } from "../infra/validate";
10-
import { launchDashboard } from "./dashboard";
10+
import { getEnvVars, launchDashboard } from "./dashboard";
1111

1212
beforeAll(() => {
1313
process.env.test_name = "my_storage_account";
@@ -72,3 +72,20 @@ describe("Validate dashboard clean up", () => {
7272
}
7373
}, 30000);
7474
});
75+
76+
describe("Fallback to azure devops access token", () => {
77+
test("Has repo_access_token specified", () => {
78+
Config().introspection!.azure!.source_repo_access_token = "test_token";
79+
const envVars = getEnvVars().toString();
80+
const expectedEnvVars =
81+
"-e,REACT_APP_PIPELINE_ORG=https://dev.azure.com/bhnook,-e,REACT_APP_PIPELINE_PROJECT=fabrikam,-e,REACT_APP_STORAGE_ACCOUNT_NAME=my_storage_account,-e,REACT_APP_STORAGE_PARTITION_KEY=partition-key,-e,REACT_APP_STORAGE_TABLE_NAME=table-name,-e,REACT_APP_STORAGE_ACCESS_KEY=my_storage_key,-e,REACT_APP_PIPELINE_ACCESS_TOKEN=hpe3a9oiswgcodtfdpzfiek3saxbrh5if1fp673xihgc5ap467a,-e,REACT_APP_SOURCE_REPO_ACCESS_TOKEN=test_token";
82+
expect(envVars).toBe(expectedEnvVars);
83+
});
84+
test("No repo_access_token was specified", () => {
85+
Config().introspection!.azure!.source_repo_access_token = undefined;
86+
const envVars = getEnvVars().toString();
87+
const expectedEnvVars =
88+
"-e,REACT_APP_PIPELINE_ORG=https://dev.azure.com/bhnook,-e,REACT_APP_PIPELINE_PROJECT=fabrikam,-e,REACT_APP_STORAGE_ACCOUNT_NAME=my_storage_account,-e,REACT_APP_STORAGE_PARTITION_KEY=partition-key,-e,REACT_APP_STORAGE_TABLE_NAME=table-name,-e,REACT_APP_STORAGE_ACCESS_KEY=my_storage_key,-e,REACT_APP_PIPELINE_ACCESS_TOKEN=hpe3a9oiswgcodtfdpzfiek3saxbrh5if1fp673xihgc5ap467a,-e,REACT_APP_SOURCE_REPO_ACCESS_TOKEN=hpe3a9oiswgcodtfdpzfiek3saxbrh5if1fp673xihgc5ap467a";
89+
expect(envVars).toBe(expectedEnvVars);
90+
});
91+
});

src/commands/deployment/dashboard.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export const launchDashboard = async (
106106
}
107107
};
108108

109-
const getEnvVars = (): string[] => {
109+
export const getEnvVars = (): string[] => {
110110
const config = Config();
111111
const envVars = [];
112112
envVars.push("-e");
@@ -136,6 +136,14 @@ const getEnvVars = (): string[] => {
136136
envVars.push(
137137
"REACT_APP_PIPELINE_ACCESS_TOKEN=" + config.azure_devops!.access_token
138138
);
139+
140+
if (!config.introspection!.azure!.source_repo_access_token) {
141+
envVars.push("-e");
142+
envVars.push(
143+
"REACT_APP_SOURCE_REPO_ACCESS_TOKEN=" +
144+
config.azure_devops!.access_token
145+
);
146+
}
139147
}
140148
if (config.introspection!.azure!.source_repo_access_token) {
141149
envVars.push("-e");

0 commit comments

Comments
 (0)