mirror of
https://github.com/badges/shields.git
synced 2026-11-21 16:06:35 +03:00
fix [gitlab] auth (#8145)
* fix(gitlab): use oauth header, add private repo test * tests(gitlab): fix nock header match on unit test
This commit is contained in:
1 parent
0ceb558bb4
commit
3c6ca5d59c
3 files changed
+14
-2
No files matched your search
@@ -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,
|
||||
|
||||
@@ -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}`,
|
||||
})
|
||||
@@ -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(
|
||||
|
||||
Reference in new issue
Block a user