Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Angamanga committed Jan 27, 2020
2 parents ba6ae04 + c094f03 commit edd689c
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions test/unit/common/auth/authentication-interceptor.config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ describe('authentication interceptor', function () {
it('should add the authorization token header', function () {

$httpBackend.expectGET(CONST.API_URL + '/test-endpoint',
{'Accept': 'application/json, text/plain, */*', 'Authorization': 'Bearer fooBarToken'}
{
'Accept': 'application/json, text/plain, */*',
'Authorization': 'Bearer fooBarToken',
'Accept-Language': 'en-US'
}
).respond(200);

$http.get(CONST.API_URL + '/test-endpoint');
Expand Down Expand Up @@ -121,7 +125,10 @@ describe('authentication interceptor', function () {

it('should send the request without an authorization header', function () {
$httpBackend.expectGET(CONST.API_URL + '/test-endpoint',
{'Accept': 'application/json, text/plain, */*'}
{
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'en-US'
}
).respond(200);

$http.get(CONST.API_URL + '/test-endpoint');
Expand All @@ -134,7 +141,10 @@ describe('authentication interceptor', function () {
'via client_credentials flow and then ' +
'add the authorization token header', function () {
$httpBackend.expectGET(CONST.API_URL + '/test-endpoint',
{'Accept': 'application/json, text/plain, */*'}
{
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'en-US'
}
).respond(401);

$httpBackend.expectPOST(CONST.BACKEND_URL + '/oauth/token',
Expand All @@ -144,8 +154,11 @@ describe('authentication interceptor', function () {
});

$httpBackend.expectGET(CONST.API_URL + '/test-endpoint',
{'Accept': 'application/json, text/plain, */*',
'Authorization': 'Bearer someOtherFooBarToken'}
{
'Accept': 'application/json, text/plain, */*',
'Authorization': 'Bearer someOtherFooBarToken',
'Accept-Language': 'en-US'
}
).respond(200);

$http.get(CONST.API_URL + '/test-endpoint');
Expand All @@ -156,7 +169,10 @@ describe('authentication interceptor', function () {
it('should send the request without an authorization header ' +
'and ignore failures if ignore403 is set', function () {
$httpBackend.expectGET(CONST.API_URL + '/test-endpoint',
{'Accept': 'application/json, text/plain, */*'}
{
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'en-US'
}
).respond(401);

$http.get(CONST.API_URL + '/test-endpoint', { params: { ignore403: true} }).then(angular.noop, angular.noop);
Expand All @@ -169,7 +185,10 @@ describe('authentication interceptor', function () {
describe('for non-API requests', function () {
it('should not add the authorization token header', function () {
$httpBackend.expectGET(CONST.BACKEND_URL + '/non-api-url',
{'Accept': 'application/json, text/plain, */*'}
{
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'en-US'
}
).respond(200);

$http.get(CONST.BACKEND_URL + '/non-api-url');
Expand Down Expand Up @@ -245,8 +264,11 @@ describe('authentication interceptor', function () {

// Then use that to load the original user
$httpBackend.expectGET(CONST.API_URL + '/some-url',
{'Accept': 'application/json, text/plain, */*',
'Authorization': 'Bearer anotherNewToken'}
{
'Accept': 'application/json, text/plain, */*',
'Authorization': 'Bearer anotherNewToken',
'Accept-Language': 'en-US'
}
).respond(200);

$httpBackend.flush();
Expand Down

0 comments on commit edd689c

Please sign in to comment.