diff --git a/plugins/scaffolder/src/api.test.ts b/plugins/scaffolder/src/api.test.ts new file mode 100644 index 0000000000..3e5e81bb2a --- /dev/null +++ b/plugins/scaffolder/src/api.test.ts @@ -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), + ); + }); +}); diff --git a/plugins/scaffolder/src/api.ts b/plugins/scaffolder/src/api.ts index 758cd555e3..6c94169b3d 100644 --- a/plugins/scaffolder/src/api.ts +++ b/plugins/scaffolder/src/api.ts @@ -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(),