diff --git a/lib/datasource/gitlab-packages/index.ts b/lib/datasource/gitlab-packages/index.ts index 2d36c15733b0795efeb71d0726ee7ade0d619986..d767c595525daab704a68206054870a7aff4a56c 100644 --- a/lib/datasource/gitlab-packages/index.ts +++ b/lib/datasource/gitlab-packages/index.ts @@ -21,7 +21,7 @@ export class GitlabPackagesDatasource extends Datasource { constructor() { super(datasource); - this.http = new GitlabHttp(); + this.http = new GitlabHttp(datasource); } static getGitlabPackageApiUrl( diff --git a/lib/util/http/host-rules.spec.ts b/lib/util/http/host-rules.spec.ts index 00e04a386ee76c2640928d3cbad572c17ee645cc..cad61c7a493961e967739f3c0a6a4a27d7cca3dd 100644 --- a/lib/util/http/host-rules.spec.ts +++ b/lib/util/http/host-rules.spec.ts @@ -153,16 +153,75 @@ describe('util/http/host-rules', () => { `); }); + it('no fallback to gitlab', () => { + hostRules.add({ + hostType: 'gitlab-packages', + token: 'package-token', + }); + hostRules.add({ + hostType: 'gitlab-releases', + token: 'release-token', + }); + hostRules.add({ + hostType: 'gitlab-tags', + token: 'tags-token', + }); + expect( + applyHostRules(url, { ...options, hostType: 'gitlab-tags' }) + ).toEqual({ + context: { + authType: undefined, + }, + hostType: 'gitlab-tags', + token: 'tags-token', + }); + expect( + applyHostRules(url, { ...options, hostType: 'gitlab-releases' }) + ).toEqual({ + context: { + authType: undefined, + }, + hostType: 'gitlab-releases', + token: 'release-token', + }); + expect( + applyHostRules(url, { ...options, hostType: 'gitlab-packages' }) + ).toEqual({ + context: { + authType: undefined, + }, + hostType: 'gitlab-packages', + token: 'package-token', + }); + }); + it('fallback to gitlab', () => { - expect(applyHostRules(url, { ...options, hostType: 'gitlab-tags' })) - .toMatchInlineSnapshot(` - Object { - "context": Object { - "authType": undefined, - }, - "hostType": "gitlab-tags", - "token": "abc", - } - `); + expect( + applyHostRules(url, { ...options, hostType: 'gitlab-tags' }) + ).toEqual({ + context: { + authType: undefined, + }, + hostType: 'gitlab-tags', + token: 'abc', + }); + expect( + applyHostRules(url, { ...options, hostType: 'gitlab-releases' }) + ).toEqual({ + context: { + authType: undefined, + }, + hostType: 'gitlab-releases', + token: 'abc', + }); + expect( + applyHostRules(url, { ...options, hostType: 'gitlab-packages' }) + ).toEqual({ + context: { + authType: undefined, + }, + hostType: 'gitlab-packages', + token: 'abc', + }); }); });