diff --git a/services/gitlab/gitlab-base.js b/services/gitlab/gitlab-base.js index f0c73ed8f5..2818e715c1 100644 --- a/services/gitlab/gitlab-base.js +++ b/services/gitlab/gitlab-base.js @@ -8,7 +8,7 @@ export default class GitLabBase extends BaseJsonService { async fetch({ url, options, schema, errorMessages }) { return this._requestJson( - this.authHelper.withBasicAuth({ + this.authHelper.withBearerAuthHeader({ schema, url, options, diff --git a/services/gitlab/gitlab-license.tester.js b/services/gitlab/gitlab-license.tester.js index 7d848cc40b..10a4e07898 100644 --- a/services/gitlab/gitlab-license.tester.js +++ b/services/gitlab/gitlab-license.tester.js @@ -1,6 +1,9 @@ import { licenseToColor } from '../licenses.js' import { createServiceTester } from '../tester.js' +import { noToken } from '../test-helpers.js' +import _noGitLabToken from './gitlab-license.service.js' export const t = await createServiceTester() +const noGitLabToken = noToken(_noGitLabToken) const publicDomainLicenseColor = licenseToColor('MIT License') const unknownLicenseColor = licenseToColor() @@ -55,3 +58,12 @@ t.create('Mocking License') message: 'Apache License 2.0', color: unknownLicenseColor, }) + +t.create('License (private repo)') + .skipWhen(noGitLabToken) + .get('/shields-ops-group/test.json') + .expectBadge({ + label: 'license', + message: 'MIT License', + color: `${publicDomainLicenseColor}`, + }) diff --git a/services/gitlab/gitlab-tag.spec.js b/services/gitlab/gitlab-tag.spec.js index 7f978c5a2e..7565cbc4e8 100644 --- a/services/gitlab/gitlab-tag.spec.js +++ b/services/gitlab/gitlab-tag.spec.js @@ -26,7 +26,7 @@ describe('GitLabTag', function () { .get('/api/v4/projects/foo%2Fbar/repository/tags?order_by=updated') // This ensures that the expected credentials are actually being sent with the HTTP request. // Without this the request wouldn't match and the test would fail. - .basicAuth({ user: '', pass: fakeToken }) + .matchHeader('Authorization', `Bearer ${fakeToken}`) .reply(200, [{ name: '1.9' }]) expect(