@@ -38,6 +38,9 @@ describe('SecurityRulesApiClient', () => {
38
38
status : 'NOT_FOUND' ,
39
39
} ,
40
40
} ;
41
+ const EXPECTED_HEADERS = {
42
+ 'X-Firebase-Client' : 'fire-admin-node/<XXX_SDK_VERSION_XXX>' ,
43
+ } ;
41
44
42
45
const apiClient : SecurityRulesApiClient = new SecurityRulesApiClient (
43
46
new HttpClient ( ) , 'test-project' ) ;
@@ -87,14 +90,15 @@ describe('SecurityRulesApiClient', () => {
87
90
it ( 'should resolve with the requested ruleset on success' , ( ) => {
88
91
const stub = sinon
89
92
. stub ( HttpClient . prototype , 'send' )
90
- . resolves ( utils . responseFrom ( { name : 'bar' } ) ) ;
93
+ . resolves ( utils . responseFrom ( { name : 'bar' } ) ) ;
91
94
stubs . push ( stub ) ;
92
95
return apiClient . getRuleset ( RULESET_NAME )
93
96
. then ( ( resp ) => {
94
97
expect ( resp . name ) . to . equal ( 'bar' ) ;
95
98
expect ( stub ) . to . have . been . calledOnce . and . calledWith ( {
96
99
method : 'GET' ,
97
100
url : 'https://firebaserules.googleapis.com/v1/projects/test-project/rulesets/ruleset-id' ,
101
+ headers : EXPECTED_HEADERS ,
98
102
} ) ;
99
103
} ) ;
100
104
} ) ;
@@ -153,7 +157,7 @@ describe('SecurityRulesApiClient', () => {
153
157
} ,
154
158
} ;
155
159
156
- const invalidContent : any [ ] = [ null , undefined , { } , { source : { } } ] ;
160
+ const invalidContent : any [ ] = [ null , undefined , { } , { source : { } } ] ;
157
161
invalidContent . forEach ( ( content ) => {
158
162
it ( `should reject when called with: ${ JSON . stringify ( content ) } ` , ( ) => {
159
163
return apiClient . createRuleset ( content )
@@ -162,7 +166,7 @@ describe('SecurityRulesApiClient', () => {
162
166
} ) ;
163
167
} ) ;
164
168
165
- const invalidFiles : any [ ] = [ null , undefined , 'test' , { } , { name : 'test' } , { content : 'test' } ] ;
169
+ const invalidFiles : any [ ] = [ null , undefined , 'test' , { } , { name : 'test' } , { content : 'test' } ] ;
166
170
invalidFiles . forEach ( ( file ) => {
167
171
it ( `should reject when called with: ${ JSON . stringify ( file ) } ` , ( ) => {
168
172
const ruleset : RulesetContent = {
@@ -190,7 +194,7 @@ describe('SecurityRulesApiClient', () => {
190
194
it ( 'should resolve with the created resource on success' , ( ) => {
191
195
const stub = sinon
192
196
. stub ( HttpClient . prototype , 'send' )
193
- . resolves ( utils . responseFrom ( { name : 'some-name' , ...RULES_CONTENT } ) ) ;
197
+ . resolves ( utils . responseFrom ( { name : 'some-name' , ...RULES_CONTENT } ) ) ;
194
198
stubs . push ( stub ) ;
195
199
return apiClient . createRuleset ( RULES_CONTENT )
196
200
. then ( ( resp ) => {
@@ -200,6 +204,7 @@ describe('SecurityRulesApiClient', () => {
200
204
method : 'POST' ,
201
205
url : 'https://firebaserules.googleapis.com/v1/projects/test-project/rulesets' ,
202
206
data : RULES_CONTENT ,
207
+ headers : EXPECTED_HEADERS ,
203
208
} ) ;
204
209
} ) ;
205
210
} ) ;
@@ -312,7 +317,8 @@ describe('SecurityRulesApiClient', () => {
312
317
expect ( stub ) . to . have . been . calledOnce . and . calledWith ( {
313
318
method : 'GET' ,
314
319
url : 'https://firebaserules.googleapis.com/v1/projects/test-project/rulesets' ,
315
- data : { pageSize : 100 } ,
320
+ data : { pageSize : 100 } ,
321
+ headers : EXPECTED_HEADERS ,
316
322
} ) ;
317
323
} ) ;
318
324
} ) ;
@@ -328,7 +334,8 @@ describe('SecurityRulesApiClient', () => {
328
334
expect ( stub ) . to . have . been . calledOnce . and . calledWith ( {
329
335
method : 'GET' ,
330
336
url : 'https://firebaserules.googleapis.com/v1/projects/test-project/rulesets' ,
331
- data : { pageSize : 50 } ,
337
+ data : { pageSize : 50 } ,
338
+ headers : EXPECTED_HEADERS ,
332
339
} ) ;
333
340
} ) ;
334
341
} ) ;
@@ -344,7 +351,8 @@ describe('SecurityRulesApiClient', () => {
344
351
expect ( stub ) . to . have . been . calledOnce . and . calledWith ( {
345
352
method : 'GET' ,
346
353
url : 'https://firebaserules.googleapis.com/v1/projects/test-project/rulesets' ,
347
- data : { pageSize : 50 , pageToken : 'next' } ,
354
+ data : { pageSize : 50 , pageToken : 'next' } ,
355
+ headers : EXPECTED_HEADERS ,
348
356
} ) ;
349
357
} ) ;
350
358
} ) ;
@@ -395,14 +403,15 @@ describe('SecurityRulesApiClient', () => {
395
403
it ( 'should resolve with the requested release on success' , ( ) => {
396
404
const stub = sinon
397
405
. stub ( HttpClient . prototype , 'send' )
398
- . resolves ( utils . responseFrom ( { name : 'bar' } ) ) ;
406
+ . resolves ( utils . responseFrom ( { name : 'bar' } ) ) ;
399
407
stubs . push ( stub ) ;
400
408
return apiClient . getRelease ( RELEASE_NAME )
401
409
. then ( ( resp ) => {
402
410
expect ( resp . name ) . to . equal ( 'bar' ) ;
403
411
expect ( stub ) . to . have . been . calledOnce . and . calledWith ( {
404
412
method : 'GET' ,
405
413
url : 'https://firebaserules.googleapis.com/v1/projects/test-project/releases/test.service' ,
414
+ headers : EXPECTED_HEADERS ,
406
415
} ) ;
407
416
} ) ;
408
417
} ) ;
@@ -453,7 +462,7 @@ describe('SecurityRulesApiClient', () => {
453
462
it ( 'should resolve with the updated release on success' , ( ) => {
454
463
const stub = sinon
455
464
. stub ( HttpClient . prototype , 'send' )
456
- . resolves ( utils . responseFrom ( { name : 'bar' } ) ) ;
465
+ . resolves ( utils . responseFrom ( { name : 'bar' } ) ) ;
457
466
stubs . push ( stub ) ;
458
467
return apiClient . updateRelease ( RELEASE_NAME , RULESET_NAME )
459
468
. then ( ( resp ) => {
@@ -467,6 +476,7 @@ describe('SecurityRulesApiClient', () => {
467
476
rulesetName : 'projects/test-project/rulesets/ruleset-id' ,
468
477
} ,
469
478
} ,
479
+ headers : EXPECTED_HEADERS ,
470
480
} ) ;
471
481
} ) ;
472
482
} ) ;
@@ -539,6 +549,7 @@ describe('SecurityRulesApiClient', () => {
539
549
expect ( stub ) . to . have . been . calledOnce . and . calledWith ( {
540
550
method : 'DELETE' ,
541
551
url : 'https://firebaserules.googleapis.com/v1/projects/test-project/rulesets/ruleset-id' ,
552
+ headers : EXPECTED_HEADERS ,
542
553
} ) ;
543
554
} ) ;
544
555
} ) ;
0 commit comments