Merge pull request #4929 from OscarDHdz/scaffolderRepoUrlPicker/FixAllowedHosts
Scaffolder: Fix allowed host field from RepoUrlPicker
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2020 Spotify AB
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { ConfigReader } from '@backstage/core';
|
||||
import { ScaffolderClient } from './api';
|
||||
|
||||
describe('api', () => {
|
||||
const discoveryApi = {} as any;
|
||||
const identityApi = {} as any;
|
||||
const configApi = new ConfigReader({
|
||||
integrations: {
|
||||
github: [
|
||||
{
|
||||
host: 'hello.com',
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
const apiClient = new ScaffolderClient({
|
||||
configApi,
|
||||
discoveryApi,
|
||||
identityApi,
|
||||
});
|
||||
|
||||
it('should return default and custom integrations', async () => {
|
||||
const allowedHosts = [
|
||||
'hello.com',
|
||||
'gitlab.com',
|
||||
'github.com',
|
||||
'dev.azure.com',
|
||||
'bitbucket.org',
|
||||
];
|
||||
const integrations = await apiClient.getIntegrationsList({ allowedHosts });
|
||||
integrations.forEach(integration =>
|
||||
expect(allowedHosts).toContain(integration.host),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -99,9 +99,7 @@ export class ScaffolderClient implements ScaffolderApi {
|
||||
}
|
||||
|
||||
async getIntegrationsList(options: { allowedHosts: string[] }) {
|
||||
const integrations = ScmIntegrations.fromConfig(
|
||||
this.configApi.getConfig('integrations'),
|
||||
);
|
||||
const integrations = ScmIntegrations.fromConfig(this.configApi);
|
||||
|
||||
return [
|
||||
...integrations.azure.list(),
|
||||
|
||||
Reference in New Issue
Block a user