@@ -133,14 +133,16 @@ describe('GoFeatureFlagProvider', () => {
133133 ) ;
134134 } ) ;
135135 } ) ;
136- it ( 'should throw an error if invalid api key is propvided ' , async ( ) => {
136+ it ( 'should throw an error if invalid api key is provided ' , async ( ) => {
137137 const flagName = 'unauthorized' ;
138138 const targetingKey = 'user-key' ;
139139 const dns = `${ endpoint } v1/feature/${ flagName } /eval` ;
140+ const apiKey = 'invalid-api-key' ;
140141
141142 axiosMock . onPost ( dns ) . reply ( 401 , { } as GoFeatureFlagProxyResponse < string > ) ;
142143
143- await goff
144+ const authenticatedGoff = new GoFeatureFlagProvider ( { endpoint, apiKey } ) ;
145+ await authenticatedGoff
144146 . resolveStringEvaluation ( flagName , 'sdk-default' , { targetingKey } )
145147 . catch ( ( err ) => {
146148 expect ( err ) . toBeInstanceOf ( Unauthorized ) ;
@@ -149,6 +151,33 @@ describe('GoFeatureFlagProvider', () => {
149151 ) ;
150152 } ) ;
151153 } ) ;
154+
155+ it ( 'should be valid with an API key provided' , async ( ) => {
156+ const flagName = 'random-flag' ;
157+ const targetingKey = 'user-key' ;
158+ const dns = `${ endpoint } v1/feature/${ flagName } /eval` ;
159+ const apiKey = 'valid-api-key' ;
160+
161+ axiosMock . onPost ( dns ) . reply ( 200 , {
162+ value : true ,
163+ variationType : 'trueVariation' ,
164+ reason : StandardResolutionReasons . TARGETING_MATCH ,
165+ failed : false ,
166+ trackEvents : true ,
167+ version : '1.0.0' ,
168+ } as GoFeatureFlagProxyResponse < boolean > ) ;
169+
170+ const authenticatedGoff = new GoFeatureFlagProvider ( { endpoint, apiKey } ) ;
171+ await authenticatedGoff
172+ . resolveBooleanEvaluation ( flagName , false , { targetingKey } )
173+ . then ( ( res ) => {
174+ expect ( res ) . toEqual ( {
175+ reason : StandardResolutionReasons . TARGETING_MATCH ,
176+ value : true ,
177+ variant : 'trueVariation' ,
178+ } as ResolutionDetails < boolean > ) ;
179+ } ) ;
180+ } ) ;
152181 } ) ;
153182
154183 describe ( 'resolveBooleanEvaluation' , ( ) => {
0 commit comments