@@ -9,7 +9,7 @@ const expect = chai.expect;
99
1010import { AppConfigurationClient } from "@azure/app-configuration" ;
1111import { loadFromAzureFrontDoor } from "../src/index.js" ;
12- import { createMockedKeyValue , createMockedFeatureFlag , getCachedIterator , sinon , restoreMocks , createMockedAzureFrontDoorEndpoint , sleepInMs , MAX_TIME_OUT } from "./utils/testHelper.js" ;
12+ import { createMockedKeyValue , createMockedFeatureFlag , HttpRequestHeadersPolicy , getCachedIterator , sinon , restoreMocks , createMockedAzureFrontDoorEndpoint , sleepInMs , MAX_TIME_OUT } from "./utils/testHelper.js" ;
1313import { TIMESTAMP_HEADER } from "../src/cdn/constants.js" ;
1414
1515function createTimestampHeaders ( timestamp : string | Date ) {
@@ -26,6 +26,35 @@ describe("loadFromAzureFrontDoor", function() {
2626 restoreMocks ( ) ;
2727 } ) ;
2828
29+ it ( "should not include authorization headers" , async ( ) => {
30+ const headerPolicy = new HttpRequestHeadersPolicy ( ) ;
31+ const position : "perCall" | "perRetry" = "perCall" ;
32+ const clientOptions = {
33+ retryOptions : {
34+ maxRetries : 0 // save time
35+ } ,
36+ additionalPolicies : [ {
37+ policy : headerPolicy ,
38+ position
39+ } ]
40+ } ;
41+
42+ const endpoint = createMockedAzureFrontDoorEndpoint ( ) ;
43+ try {
44+ await loadFromAzureFrontDoor ( endpoint , {
45+ clientOptions,
46+ startupOptions : {
47+ timeoutInMs : 1
48+ }
49+ } ) ;
50+ } catch { /* empty */ }
51+
52+ expect ( headerPolicy . headers ) . not . undefined ;
53+ expect ( headerPolicy . headers . get ( "User-Agent" ) ) . satisfy ( ( ua : string ) => ua . startsWith ( "javascript-appconfiguration-provider" ) ) ;
54+ expect ( headerPolicy . headers . get ( "authorization" ) ) . to . be . undefined ;
55+ expect ( headerPolicy . headers . get ( "Authorization" ) ) . to . be . undefined ;
56+ } ) ;
57+
2958 it ( "should load key-values and feature flags" , async ( ) => {
3059 const kv1 = createMockedKeyValue ( { key : "app.color" , value : "red" } ) ;
3160 const kv2 = createMockedKeyValue ( { key : "app.size" , value : "large" } ) ;
@@ -211,4 +240,4 @@ describe("loadFromAzureFrontDoor", function() {
211240 expect ( appConfig . get ( "app.key2" ) ) . to . equal ( "value2-updated" ) ;
212241 } ) ;
213242} ) ;
214- /* eslint-enable @typescript-eslint/no-unused-expressions */
243+ /* eslint-ensable @typescript-eslint/no-unused-expressions */
0 commit comments