Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix [gitlab] auth #8145

Merged
merged 2 commits into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion services/gitlab/gitlab-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions services/gitlab/gitlab-license.tester.js
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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}`,
})
2 changes: 1 addition & 1 deletion services/gitlab/gitlab-tag.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down