Files
shields/services/docker/docker-cloud-common-fetch.spec.js
chris48s 880c1fb49c call [docker] with auth (#9803)
* allow user to set dockerhub credentials

* add withJwtAuth function to AuthHelper

* use withJwtAuth in DockerHub badges

* add unit tests for JWT auth

* use auth when calling docker cloud

* refactor and assert fetch helpers call withJwtAuth

* store token for a max duration (defaults to 1 hour)

* tangent: update test example
2023-12-31 14:55:18 +00:00

24 lines
651 B
JavaScript

import sinon from 'sinon'
import { expect } from 'chai'
import { fetchBuild } from './docker-cloud-common-fetch.js'
describe('fetchBuild', function () {
it('invokes withJwtAuth', async function () {
const serviceInstance = {
_requestJson: sinon.stub().resolves('fake-response'),
authHelper: {
withJwtAuth: sinon.stub(),
},
}
const resp = await fetchBuild(serviceInstance, {
user: 'user',
repo: 'repo',
})
expect(serviceInstance.authHelper.withJwtAuth.calledOnce).to.be.true
expect(serviceInstance._requestJson.calledOnce).to.be.true
expect(resp).to.equal('fake-response')
})
})