@@ -149,10 +149,6 @@ describe('OpenFeature SDK', () => {
149
149
} ) ;
150
150
151
151
it ( 'should throw a custom exception if the flag is disabled with context' , async ( ) => {
152
- jest . spyOn ( defaultProvider , 'resolveBooleanEvaluation' ) . mockResolvedValueOnce ( {
153
- value : false ,
154
- reason : 'DISABLED' ,
155
- } ) ;
156
152
await supertest ( app . getHttpServer ( ) )
157
153
. get ( '/flags-enabled-custom-exception-with-context' )
158
154
. set ( 'x-user-id' , '123' )
@@ -161,21 +157,24 @@ describe('OpenFeature SDK', () => {
161
157
} ) ;
162
158
163
159
describe ( 'OpenFeatureControllerRequireFlagsEnabled' , ( ) => {
164
- it ( 'should allow access to the RequireFlagsEnabled controller' , async ( ) => {
165
- // Only mock the first flag evaluation for Flag with key `testBooleanFlag2`, the second flag evaluation will use the default variation for flag with key `testBooleanFlag`
166
- jest . spyOn ( defaultProvider , 'resolveBooleanEvaluation' ) . mockResolvedValueOnce ( {
167
- value : true ,
168
- reason : 'TARGETING_MATCH' ,
169
- } ) ;
170
- await supertest ( app . getHttpServer ( ) ) . get ( '/require-flags-enabled' ) . expect ( 200 ) . expect ( 'Hello, world!' ) ;
160
+ it ( 'should allow access to the RequireFlagsEnabled controller with global context interceptor' , async ( ) => {
161
+ await supertest ( app . getHttpServer ( ) )
162
+ . get ( '/require-flags-enabled' )
163
+ . set ( 'x-user-id' , '123' )
164
+ . expect ( 200 )
165
+ . expect ( 'Hello, world!' ) ;
166
+ } ) ;
167
+
168
+ it ( 'should throw a 403 - Forbidden exception if user does not match targeting requirements' , async ( ) => {
169
+ await supertest ( app . getHttpServer ( ) ) . get ( '/require-flags-enabled' ) . set ( 'x-user-id' , 'not-123' ) . expect ( 403 ) ;
171
170
} ) ;
172
171
173
- it ( 'should throw a 403 - Forbidden exception if the flag is disabled' , async ( ) => {
172
+ it ( 'should throw a 403 - Forbidden exception if one of the flags is disabled' , async ( ) => {
174
173
jest . spyOn ( defaultProvider , 'resolveBooleanEvaluation' ) . mockResolvedValueOnce ( {
175
174
value : false ,
176
175
reason : 'DISABLED' ,
177
176
} ) ;
178
- await supertest ( app . getHttpServer ( ) ) . get ( '/require-flags-enabled' ) . expect ( 403 ) ;
177
+ await supertest ( app . getHttpServer ( ) ) . get ( '/require-flags-enabled' ) . set ( 'x-user-id' , '123' ) . expect ( 403 ) ;
179
178
} ) ;
180
179
} ) ;
181
180
} ) ;
0 commit comments