add frontend-filtered config loading tests in integrations
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@backstage/cli": "^0.6.1",
|
||||
"@backstage/config-loader": "^0.5.1",
|
||||
"@backstage/test-utils": "^0.1.7",
|
||||
"@types/jest": "^26.0.7",
|
||||
"@types/luxon": "^1.25.0",
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
import { Config, ConfigReader } from '@backstage/config';
|
||||
import { loadConfigSchema } from '@backstage/config-loader';
|
||||
import {
|
||||
AzureIntegrationConfig,
|
||||
readAzureIntegrationConfig,
|
||||
@@ -26,6 +27,19 @@ describe('readAzureIntegrationConfig', () => {
|
||||
return new ConfigReader(data);
|
||||
}
|
||||
|
||||
async function buildFrontendConfig(
|
||||
data: Partial<AzureIntegrationConfig>,
|
||||
): Promise<Config> {
|
||||
const schema = await loadConfigSchema({
|
||||
dependencies: [require('../../package.json').name],
|
||||
});
|
||||
const processed = schema.process(
|
||||
[{ data: { integrations: { azure: [data] } }, context: 'app' }],
|
||||
{ visibility: ['frontend'] },
|
||||
);
|
||||
return new ConfigReader((processed[0].data as any).integrations.azure[0]);
|
||||
}
|
||||
|
||||
it('reads all values', () => {
|
||||
const output = readAzureIntegrationConfig(
|
||||
buildConfig({
|
||||
@@ -56,6 +70,19 @@ describe('readAzureIntegrationConfig', () => {
|
||||
readAzureIntegrationConfig(buildConfig({ ...valid, token: 7 })),
|
||||
).toThrow(/token/);
|
||||
});
|
||||
|
||||
it('works on the frontend', async () => {
|
||||
expect(
|
||||
readAzureIntegrationConfig(
|
||||
await buildFrontendConfig({
|
||||
host: 'a.com',
|
||||
token: 't',
|
||||
}),
|
||||
),
|
||||
).toEqual({
|
||||
host: 'a.com',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('readAzureIntegrationConfigs', () => {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
import { Config, ConfigReader } from '@backstage/config';
|
||||
import { loadConfigSchema } from '@backstage/config-loader';
|
||||
import {
|
||||
BitbucketIntegrationConfig,
|
||||
readBitbucketIntegrationConfig,
|
||||
@@ -26,6 +27,21 @@ describe('readBitbucketIntegrationConfig', () => {
|
||||
return new ConfigReader(data);
|
||||
}
|
||||
|
||||
async function buildFrontendConfig(
|
||||
data: Partial<BitbucketIntegrationConfig>,
|
||||
): Promise<Config> {
|
||||
const schema = await loadConfigSchema({
|
||||
dependencies: [require('../../package.json').name],
|
||||
});
|
||||
const processed = schema.process(
|
||||
[{ data: { integrations: { bitbucket: [data] } }, context: 'app' }],
|
||||
{ visibility: ['frontend'] },
|
||||
);
|
||||
return new ConfigReader(
|
||||
(processed[0].data as any).integrations.bitbucket[0],
|
||||
);
|
||||
}
|
||||
|
||||
it('reads all values', () => {
|
||||
const output = readBitbucketIntegrationConfig(
|
||||
buildConfig({
|
||||
@@ -79,6 +95,23 @@ describe('readBitbucketIntegrationConfig', () => {
|
||||
readBitbucketIntegrationConfig(buildConfig({ ...valid, appPassword: 7 })),
|
||||
).toThrow(/appPassword/);
|
||||
});
|
||||
|
||||
it('works on the frontend', async () => {
|
||||
expect(
|
||||
readBitbucketIntegrationConfig(
|
||||
await buildFrontendConfig({
|
||||
host: 'a.com',
|
||||
apiBaseUrl: 'https://a.com/api',
|
||||
token: 't',
|
||||
username: 'u',
|
||||
appPassword: 'p',
|
||||
}),
|
||||
),
|
||||
).toEqual({
|
||||
host: 'a.com',
|
||||
apiBaseUrl: 'https://a.com/api',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('readBitbucketIntegrationConfigs', () => {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
import { Config, ConfigReader } from '@backstage/config';
|
||||
import { loadConfigSchema } from '@backstage/config-loader';
|
||||
import {
|
||||
GitHubIntegrationConfig,
|
||||
readGitHubIntegrationConfig,
|
||||
@@ -26,6 +27,19 @@ describe('readGitHubIntegrationConfig', () => {
|
||||
return new ConfigReader(provider);
|
||||
}
|
||||
|
||||
async function buildFrontendConfig(
|
||||
data: Partial<GitHubIntegrationConfig>,
|
||||
): Promise<Config> {
|
||||
const schema = await loadConfigSchema({
|
||||
dependencies: [require('../../package.json').name],
|
||||
});
|
||||
const processed = schema.process(
|
||||
[{ data: { integrations: { github: [data] } }, context: 'app' }],
|
||||
{ visibility: ['frontend'] },
|
||||
);
|
||||
return new ConfigReader((processed[0].data as any).integrations.github[0]);
|
||||
}
|
||||
|
||||
it('reads all values', () => {
|
||||
const output = readGitHubIntegrationConfig(
|
||||
buildConfig({
|
||||
@@ -74,6 +88,23 @@ describe('readGitHubIntegrationConfig', () => {
|
||||
readGitHubIntegrationConfig(buildConfig({ ...valid, token: 7 })),
|
||||
).toThrow(/token/);
|
||||
});
|
||||
|
||||
it('works on the frontend', async () => {
|
||||
expect(
|
||||
readGitHubIntegrationConfig(
|
||||
await buildFrontendConfig({
|
||||
host: 'a.com',
|
||||
apiBaseUrl: 'https://a.com/api',
|
||||
rawBaseUrl: 'https://a.com/raw',
|
||||
token: 't',
|
||||
}),
|
||||
),
|
||||
).toEqual({
|
||||
host: 'a.com',
|
||||
apiBaseUrl: 'https://a.com/api',
|
||||
rawBaseUrl: 'https://a.com/raw',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('readGitHubIntegrationConfigs', () => {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
import { Config, ConfigReader } from '@backstage/config';
|
||||
import { loadConfigSchema } from '@backstage/config-loader';
|
||||
import {
|
||||
GitLabIntegrationConfig,
|
||||
readGitLabIntegrationConfig,
|
||||
@@ -26,6 +27,19 @@ describe('readGitLabIntegrationConfig', () => {
|
||||
return new ConfigReader(data);
|
||||
}
|
||||
|
||||
async function buildFrontendConfig(
|
||||
data: Partial<GitLabIntegrationConfig>,
|
||||
): Promise<Config> {
|
||||
const schema = await loadConfigSchema({
|
||||
dependencies: [require('../../package.json').name],
|
||||
});
|
||||
const processed = schema.process(
|
||||
[{ data: { integrations: { gitlab: [data] } }, context: 'app' }],
|
||||
{ visibility: ['frontend'] },
|
||||
);
|
||||
return new ConfigReader((processed[0].data as any).integrations.gitlab[0]);
|
||||
}
|
||||
|
||||
it('reads all values', () => {
|
||||
const output = readGitLabIntegrationConfig(
|
||||
buildConfig({
|
||||
@@ -79,6 +93,23 @@ describe('readGitLabIntegrationConfig', () => {
|
||||
readGitLabIntegrationConfig(buildConfig({ ...valid, token: 7 })),
|
||||
).toThrow(/token/);
|
||||
});
|
||||
|
||||
it('works on the frontend', async () => {
|
||||
expect(
|
||||
readGitLabIntegrationConfig(
|
||||
await buildFrontendConfig({
|
||||
host: 'a.com',
|
||||
apiBaseUrl: 'https://a.com/api',
|
||||
token: 't',
|
||||
baseUrl: 'https://a.com',
|
||||
}),
|
||||
),
|
||||
).toEqual({
|
||||
host: 'a.com',
|
||||
apiBaseUrl: 'https://a.com/api',
|
||||
baseUrl: 'https://a.com',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('readGitLabIntegrationConfigs', () => {
|
||||
|
||||
Reference in New Issue
Block a user