Permalink
Browse files

fix(interceptor): set authorization header instead of appending

  • Loading branch information...
doktordirk committed Mar 31, 2016
1 parent 4a44425 commit 4e53457d66c08696ff802bc973ebcec0a31753c6
Showing with 5 additions and 4 deletions.
  1. +1 −1 src/app.fetch-httpClient.config.js
  2. +4 −3 test/app.fetch-httpClient.config.spec.js
@@ -42,7 +42,7 @@ export class FetchConfig {
token = `${config.authToken} ${token}`;
}
request.headers.append(config.authHeader, token);
request.headers.set(config.authHeader, token);
return request;
}
@@ -31,7 +31,8 @@ function getInterceptorStubs(isAuthenticated, httpInterceptor) {
let requestStub = {
headers: {
append: (header, value) => {}
append: (header, value) => {},
set: (header, value) => {}
}
};
@@ -47,13 +48,13 @@ describe('FetchConfig', function() {
it('Should intercept requests when authenticated.', function() {
let { authenticationStub, configStub, requestStub } = getInterceptorStubs(true, true);
spyOn(requestStub.headers, 'append');
spyOn(requestStub.headers, 'set');
let fetchConfig = new FetchConfig(null, null, authenticationStub, configStub);
let chain = fetchConfig.interceptor.request(requestStub);
expect(chain).toBe(requestStub);
expect(requestStub.headers.append).toHaveBeenCalledWith('AuthoriseHeader', 'AuthoriseToken someToken');
expect(requestStub.headers.set).toHaveBeenCalledWith('AuthoriseHeader', 'AuthoriseToken someToken');
});
it('Should not intercept requests when unauthenticated.', function() {

0 comments on commit 4e53457

Please sign in to comment.