Files
shields/services/docker/docker-hub-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

21 lines
589 B
JavaScript

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