mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-05-31 14:11:58 +05:30
Disable bearer header for refresh-token request
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import expect from 'unexpected';
|
||||
import sinon from 'sinon';
|
||||
|
||||
import request from 'services/request';
|
||||
import authentication from 'services/api/authentication';
|
||||
@@ -121,4 +122,52 @@ describe('authentication api', () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#requestToken', () => {
|
||||
const refreshToken = 'refresh-token';
|
||||
|
||||
beforeEach(() => {
|
||||
sinon.stub(request, 'post').named('request.post');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
request.post.restore();
|
||||
});
|
||||
|
||||
it('should request refresh-token api', () => {
|
||||
request.post.returns(Promise.resolve({}));
|
||||
|
||||
authentication.requestToken(refreshToken);
|
||||
|
||||
expect(request.post, 'to have a call satisfying', [
|
||||
'/api/authentication/refresh-token', {
|
||||
refresh_token: refreshToken // eslint-disable-line
|
||||
}, {}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should disable bearer auth for request', () => {
|
||||
request.post.returns(Promise.resolve({}));
|
||||
|
||||
authentication.requestToken(refreshToken);
|
||||
|
||||
expect(request.post, 'to have a call satisfying', [
|
||||
'/api/authentication/refresh-token', {
|
||||
refresh_token: refreshToken // eslint-disable-line
|
||||
}, {token: null}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should resolve with token', () => {
|
||||
const token = 'token';
|
||||
|
||||
request.post.returns(Promise.resolve({
|
||||
access_token: token // eslint-disable-line
|
||||
}));
|
||||
|
||||
return expect(authentication.requestToken(refreshToken),
|
||||
'to be fulfilled with', {token}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user