@@ -6,7 +6,7 @@ import { AppConfigurationClient, ConfigurationSetting, featureFlagContentType, s
66import { ClientSecretCredential } from "@azure/identity" ;
77import { KeyVaultSecret , SecretClient } from "@azure/keyvault-secrets" ;
88import * as uuid from "uuid" ;
9- import { RestError } from "@azure/core-rest-pipeline" ;
9+ import { RestError , PipelineRequest , PipelineResponse , SendRequest } from "@azure/core-rest-pipeline" ;
1010import { ConfigurationClientManager } from "../../src/configurationClientManager.js" ;
1111import { ConfigurationClientWrapper } from "../../src/configurationClientWrapper.js" ;
1212
@@ -51,7 +51,7 @@ function _filterKVs(unfilteredKvs: ConfigurationSetting[], listOptions: any) {
5151 }
5252 let tagsMatched = true ;
5353 if ( tagsFilter . length > 0 ) {
54- tagsMatched = tagsFilter . every ( tag => {
54+ tagsMatched = tagsFilter . every ( ( tag : string ) => {
5555 const [ tagName , tagValue ] = tag . split ( "=" ) ;
5656 if ( tagValue === "\0" ) {
5757 return kv . tags && kv . tags [ tagName ] === null ;
@@ -63,7 +63,7 @@ function _filterKVs(unfilteredKvs: ConfigurationSetting[], listOptions: any) {
6363 } ) ;
6464}
6565
66- function getMockedIterator ( pages : ConfigurationSetting [ ] [ ] , kvs : ConfigurationSetting [ ] , listOptions : any ) {
66+ function getMockedIterator ( pages : ConfigurationSetting [ ] [ ] , kvs : ConfigurationSetting [ ] , listOptions : any , useStringStatus : boolean = false ) {
6767 const mockIterator : AsyncIterableIterator < any > & { byPage ( ) : AsyncIterableIterator < any > } = {
6868 [ Symbol . asyncIterator ] ( ) : AsyncIterableIterator < any > {
6969 kvs = _filterKVs ( pages . flat ( ) , listOptions ) ;
@@ -74,7 +74,7 @@ function getMockedIterator(pages: ConfigurationSetting[][], kvs: ConfigurationSe
7474 return Promise . resolve ( { done : ! value , value } ) ;
7575 } ,
7676 byPage ( ) : AsyncIterableIterator < any > {
77- let remainingPages ;
77+ let remainingPages : ConfigurationSetting [ ] [ ] ;
7878 const pageEtags = listOptions ?. pageEtags ? [ ...listOptions . pageEtags ] : undefined ; // a copy of the original list
7979 return {
8080 [ Symbol . asyncIterator ] ( ) : AsyncIterableIterator < any > {
@@ -95,7 +95,7 @@ function getMockedIterator(pages: ConfigurationSetting[][], kvs: ConfigurationSe
9595 value : {
9696 items,
9797 etag,
98- _response : { status : statusCode }
98+ _response : { status : useStringStatus ? ` ${ statusCode } ` : statusCode }
9999 }
100100 } ;
101101 }
@@ -114,7 +114,7 @@ function getMockedIterator(pages: ConfigurationSetting[][], kvs: ConfigurationSe
114114 *
115115 * @param pages List of pages, each page is a list of ConfigurationSetting
116116 */
117- function mockAppConfigurationClientListConfigurationSettings ( pages : ConfigurationSetting [ ] [ ] , customCallback ?: ( listOptions ) => any ) {
117+ function mockAppConfigurationClientListConfigurationSettings ( pages : ConfigurationSetting [ ] [ ] , customCallback ?: ( listOptions : any ) => any ) {
118118
119119 sinon . stub ( AppConfigurationClient . prototype , "listConfigurationSettings" ) . callsFake ( ( listOptions ) => {
120120 if ( customCallback ) {
@@ -126,6 +126,18 @@ function mockAppConfigurationClientListConfigurationSettings(pages: Configuratio
126126 } ) ;
127127}
128128
129+ function mockAppConfigurationClientListConfigurationSettingsWithStringStatus ( pages : ConfigurationSetting [ ] [ ] , customCallback ?: ( listOptions : any ) => any ) {
130+
131+ sinon . stub ( AppConfigurationClient . prototype , "listConfigurationSettings" ) . callsFake ( ( listOptions ) => {
132+ if ( customCallback ) {
133+ customCallback ( listOptions ) ;
134+ }
135+
136+ const kvs = _filterKVs ( pages . flat ( ) , listOptions ) ;
137+ return getMockedIterator ( pages , kvs , listOptions , true ) ;
138+ } ) ;
139+ }
140+
129141function mockAppConfigurationClientLoadBalanceMode ( pages : ConfigurationSetting [ ] [ ] , clientWrapper : ConfigurationClientWrapper , countObject : { count : number } ) {
130142 sinon . stub ( clientWrapper . client , "listConfigurationSettings" ) . callsFake ( ( listOptions ) => {
131143 countObject . count += 1 ;
@@ -163,7 +175,7 @@ function mockConfigurationManagerGetClients(fakeClientWrappers: ConfigurationCli
163175 } ) ;
164176}
165177
166- function mockAppConfigurationClientGetConfigurationSetting ( kvList : any [ ] , customCallback ?: ( options ) => any ) {
178+ function mockAppConfigurationClientGetConfigurationSetting ( kvList : any [ ] , customCallback ?: ( options : any ) => any ) {
167179 sinon . stub ( AppConfigurationClient . prototype , "getConfigurationSetting" ) . callsFake ( ( settingId , options ) => {
168180 if ( customCallback ) {
169181 customCallback ( options ) ;
@@ -182,7 +194,7 @@ function mockAppConfigurationClientGetConfigurationSetting(kvList: any[], custom
182194 } ) ;
183195}
184196
185- function mockAppConfigurationClientGetSnapshot ( snapshotResponses : Map < string , any > , customCallback ?: ( options ) => any ) {
197+ function mockAppConfigurationClientGetSnapshot ( snapshotResponses : Map < string , any > , customCallback ?: ( options : any ) => any ) {
186198 sinon . stub ( AppConfigurationClient . prototype , "getSnapshot" ) . callsFake ( ( name , options ) => {
187199 if ( customCallback ) {
188200 customCallback ( options ) ;
@@ -196,7 +208,7 @@ function mockAppConfigurationClientGetSnapshot(snapshotResponses: Map<string, an
196208 } ) ;
197209}
198210
199- function mockAppConfigurationClientListConfigurationSettingsForSnapshot ( snapshotResponses : Map < string , ConfigurationSetting [ ] [ ] > , customCallback ?: ( options ) => any ) {
211+ function mockAppConfigurationClientListConfigurationSettingsForSnapshot ( snapshotResponses : Map < string , ConfigurationSetting [ ] [ ] > , customCallback ?: ( options : any ) => any ) {
200212 sinon . stub ( AppConfigurationClient . prototype , "listConfigurationSettingsForSnapshot" ) . callsFake ( ( name , listOptions ) => {
201213 if ( customCallback ) {
202214 customCallback ( listOptions ) ;
@@ -218,7 +230,7 @@ function mockSecretClientGetSecret(uriValueList: [string, string][]) {
218230 dict . set ( uri , value ) ;
219231 }
220232
221- sinon . stub ( SecretClient . prototype , "getSecret" ) . callsFake ( async function ( secretName , options ) {
233+ sinon . stub ( SecretClient . prototype , "getSecret" ) . callsFake ( async function ( this : SecretClient , secretName , options ) {
222234 const url = new URL ( this . vaultUrl ) ;
223235 url . pathname = `/secrets/${ secretName } ` ;
224236 if ( options ?. version ) {
@@ -314,7 +326,7 @@ class HttpRequestHeadersPolicy {
314326 this . headers = { } ;
315327 this . name = "HttpRequestHeadersPolicy" ;
316328 }
317- sendRequest ( req , next ) {
329+ sendRequest ( req : PipelineRequest , next : SendRequest ) : Promise < PipelineResponse > {
318330 this . headers = req . headers ;
319331 return next ( req ) . then ( resp => resp ) ;
320332 }
@@ -323,6 +335,7 @@ class HttpRequestHeadersPolicy {
323335export {
324336 sinon ,
325337 mockAppConfigurationClientListConfigurationSettings ,
338+ mockAppConfigurationClientListConfigurationSettingsWithStringStatus ,
326339 mockAppConfigurationClientGetConfigurationSetting ,
327340 mockAppConfigurationClientGetSnapshot ,
328341 mockAppConfigurationClientListConfigurationSettingsForSnapshot ,
0 commit comments