@@ -48,6 +48,8 @@ describe('interceptor', function() {
48
48
$q . all ( [
49
49
$http ( { url : 'http://Example.com/hello' } ) ,
50
50
$http ( { url : 'http://www.example.com/hello' } ) ,
51
+ $http ( { url : 'http://wwwXexample.com/hello' } ) ,
52
+ $http ( { url : 'http://whitelisted.example.com.evil.com/hello' } ) ,
51
53
$http ( { url : 'http://whitelisted.example.com/hello' } )
52
54
] ) . then ( function ( ) {
53
55
done ( ) ;
@@ -59,6 +61,12 @@ describe('interceptor', function() {
59
61
$httpBackend . expectGET ( 'http://www.example.com/hello' , function ( headers ) {
60
62
return headers . Authorization === undefined ;
61
63
} ) . respond ( 200 ) ;
64
+ $httpBackend . expectGET ( 'http://wwwXexample.com/hello' , function ( headers ) {
65
+ return headers . Authorization === undefined ;
66
+ } ) . respond ( 200 ) ;
67
+ $httpBackend . expectGET ( 'http://whitelisted.example.com.evil.com/hello' , function ( headers ) {
68
+ return headers . Authorization === undefined ;
69
+ } ) . respond ( 200 ) ;
62
70
$httpBackend . expectGET ( 'http://whitelisted.example.com/hello' , function ( headers ) {
63
71
return headers . Authorization === 'Bearer 123' ;
64
72
} ) . respond ( 200 ) ;
@@ -69,7 +77,7 @@ describe('interceptor', function() {
69
77
70
78
it ( 'should not add Authr headers to Cross Origin requests unless whitelisted with regexp' , function ( done ) {
71
79
module ( function ( $httpProvider , jwtOptionsProvider , jwtInterceptorProvider ) {
72
- jwtInterceptorProvider . whiteListedDomains = [ / w h i t e l i s t e d ( - p r - \d + ) ? \. E x a m p l e \. c o m $ / i]
80
+ jwtInterceptorProvider . whiteListedDomains = [ / ^ w h i t e l i s t e d ( - p r - \d + ) ? \. E x a m p l e \. c o m $ / i]
73
81
jwtInterceptorProvider . tokenGetter = function ( ) {
74
82
return 123 ;
75
83
}
@@ -80,6 +88,8 @@ describe('interceptor', function() {
80
88
$q . all ( [
81
89
$http ( { url : 'http://Example.com/hello' } ) ,
82
90
$http ( { url : 'http://www.example.com/hello' } ) ,
91
+ $http ( { url : 'http://whitelisted-pr-123.example.com.evil.com/hello' } ) ,
92
+ $http ( { url : 'http://extrawhitelisted-pr-123.example.com.evil.com/hello' } ) ,
83
93
$http ( { url : 'http://whitelisted-pr-123.example.com/hello' } )
84
94
] ) . then ( function ( ) {
85
95
done ( ) ;
@@ -91,6 +101,12 @@ describe('interceptor', function() {
91
101
$httpBackend . expectGET ( 'http://www.example.com/hello' , function ( headers ) {
92
102
return headers . Authorization === undefined ;
93
103
} ) . respond ( 200 ) ;
104
+ $httpBackend . expectGET ( 'http://whitelisted-pr-123.example.com.evil.com/hello' , function ( headers ) {
105
+ return headers . Authorization === undefined ;
106
+ } ) . respond ( 200 ) ;
107
+ $httpBackend . expectGET ( 'http://extrawhitelisted-pr-123.example.com.evil.com/hello' , function ( headers ) {
108
+ return headers . Authorization === undefined ;
109
+ } ) . respond ( 200 ) ;
94
110
$httpBackend . expectGET ( 'http://whitelisted-pr-123.example.com/hello' , function ( headers ) {
95
111
return headers . Authorization === 'Bearer 123' ;
96
112
} ) . respond ( 200 ) ;
0 commit comments