integration support for harness - fixed comments p2

Signed-off-by: Calvin Lee <cjlee@ualberta.ca>
This commit is contained in:
Calvin Lee
2024-04-30 13:20:34 -06:00
parent 84bb2ed37d
commit 84cdb92346
3 changed files with 8 additions and 13 deletions
-1
View File
@@ -50,7 +50,6 @@
"devDependencies": {
"@backstage/cli": "workspace:^",
"@backstage/config-loader": "workspace:^",
"@backstage/test-utils": "workspace:^",
"@types/luxon": "^3.0.0",
"msw": "^1.0.0"
},
@@ -15,7 +15,7 @@
*/
import { setupServer } from 'msw/node';
import { setupRequestMockHandlers } from '@backstage/test-utils';
import { setupRequestMockHandlers } from '../helpers';
import { HarnessIntegrationConfig } from './config';
import {
getHarnessEditContentsUrl,
@@ -59,26 +59,26 @@ describe('Harness code core', () => {
});
});
describe('getGerritRequestOptions', () => {
describe('getHarnessRequestOptions', () => {
it('adds token header when only a token is specified', () => {
const authRequest: HarnessIntegrationConfig = {
host: 'gerrit.com',
host: 'app.harness.io',
token: 'P',
};
const anonymousRequest: HarnessIntegrationConfig = {
host: 'gerrit.com',
host: 'app.harness.io',
};
expect(
(getHarnessRequestOptions(authRequest).headers as any).Authorization,
).toEqual('Bearer P');
expect(
getHarnessRequestOptions(anonymousRequest).headers,
).toBeUndefined();
expect(getHarnessRequestOptions(anonymousRequest).headers).toStrictEqual(
{},
);
});
it('adds basic auth when apikey and token are specified', () => {
const authRequest: HarnessIntegrationConfig = {
host: 'gerrit.com',
host: 'app.harness.io',
token: 'P',
apiKey: 'a',
};
-4
View File
@@ -120,10 +120,6 @@ export function getHarnessRequestOptions(config: HarnessIntegrationConfig): {
const headers: Record<string, string> = {};
const { token, apiKey } = config;
if (!token) {
return headers;
}
if (apiKey) {
headers['x-api-key'] = apiKey;
} else if (token) {