remove suspended [github] tokens from the pool (#7654)
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
@@ -126,14 +126,35 @@ describe('Github API provider', function () {
|
||||
})
|
||||
})
|
||||
|
||||
context('an unauthorized response', function () {
|
||||
it('should invoke the callback and update the token with the expected values', async function () {
|
||||
context('unauthorized API responses', function () {
|
||||
it('should invoke the callback and update the token with the expected values (unauthorized, v3)', async function () {
|
||||
const mockResponse = { res: { statusCode: 401, headers: {} } }
|
||||
const mockRequest = sinon.stub().resolves(mockResponse)
|
||||
await provider.fetch(mockRequest, '/foo', {})
|
||||
expect(mockStandardToken.invalidate).to.have.been.calledOnce
|
||||
expect(mockStandardToken.update).not.to.have.been.called
|
||||
})
|
||||
|
||||
it('should invoke the callback and update the token with the expected values (unauthorized, v4)', async function () {
|
||||
const mockResponse = { res: { statusCode: 401, body: {} } }
|
||||
const mockRequest = sinon.stub().resolves(mockResponse)
|
||||
await provider.fetch(mockRequest, '/graphql', {})
|
||||
expect(mockGraphqlToken.invalidate).to.have.been.calledOnce
|
||||
expect(mockGraphqlToken.update).not.to.have.been.called
|
||||
})
|
||||
|
||||
it('should invoke the callback and update the token with the expected values (suspended, v4)', async function () {
|
||||
const mockResponse = {
|
||||
res: {
|
||||
statusCode: 200,
|
||||
body: '{ "message": "Sorry. Your account was suspended." }',
|
||||
},
|
||||
}
|
||||
const mockRequest = sinon.stub().resolves(mockResponse)
|
||||
await provider.fetch(mockRequest, '/graphql', {})
|
||||
expect(mockGraphqlToken.invalidate).to.have.been.calledOnce
|
||||
expect(mockGraphqlToken.update).not.to.have.been.called
|
||||
})
|
||||
})
|
||||
|
||||
context('a connection error', function () {
|
||||
|
||||
Reference in New Issue
Block a user