@@ -16,10 +16,17 @@ describe('OpenFeature configuration source', () => {
1616 beforeEach ( ( ) => {
1717 config = {
1818 DD_API_KEY : 'test-api-key' ,
19+ DD_FEATURE_FLAGS_ENABLED : true ,
1920 DD_FEATURE_FLAGS_CONFIGURATION_SOURCE : 'agentless' ,
2021 DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_BASE_URL : undefined ,
2122 DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_POLL_INTERVAL_SECONDS : 30 ,
2223 DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_REQUEST_TIMEOUT_SECONDS : 2 ,
24+ experimental : {
25+ flaggingProvider : {
26+ enabled : false ,
27+ } ,
28+ } ,
29+ getOrigin : sinon . stub ( ) . returns ( 'default' ) ,
2330 site : 'datadoghq.com' ,
2431 env : 'my env' ,
2532 }
@@ -43,6 +50,54 @@ describe('OpenFeature configuration source', () => {
4350 } )
4451 }
4552
53+ it ( 'grandfathers the legacy enabled setting onto Remote Config when the source is defaulted' , ( ) => {
54+ config . experimental . flaggingProvider . enabled = true
55+ config . getOrigin . withArgs ( 'experimental.flaggingProvider.enabled' ) . returns ( 'env_var' )
56+
57+ assert . deepStrictEqual ( configurationSource . resolve ( config ) , { mode : 'remote_config' } )
58+ assert . strictEqual ( configurationSource . isRemoteConfig ( config ) , true )
59+ assert . strictEqual ( configurationSource . isEnabled ( config ) , true )
60+ } )
61+
62+ it ( 'keeps the provider disabled for the legacy false setting when the source is defaulted' , ( ) => {
63+ config . experimental . flaggingProvider . enabled = false
64+ config . getOrigin . withArgs ( 'experimental.flaggingProvider.enabled' ) . returns ( 'env_var' )
65+
66+ assert . deepStrictEqual ( configurationSource . resolve ( config ) , { mode : 'disabled' } )
67+ assert . strictEqual ( configurationSource . isRemoteConfig ( config ) , false )
68+ assert . strictEqual ( configurationSource . isEnabled ( config ) , false )
69+ } )
70+
71+ it ( 'lets an explicit agentless source override legacy enablement' , ( ) => {
72+ config . experimental . flaggingProvider . enabled = true
73+ config . getOrigin . returns ( 'env_var' )
74+
75+ assert . strictEqual ( configurationSource . resolve ( config ) . mode , 'agentless' )
76+ assert . strictEqual ( configurationSource . isRemoteConfig ( config ) , false )
77+ assert . strictEqual ( configurationSource . isEnabled ( config ) , true )
78+ } )
79+
80+ it ( 'lets an explicit Remote Config source override legacy disablement' , ( ) => {
81+ config . DD_FEATURE_FLAGS_CONFIGURATION_SOURCE = 'remote_config'
82+ config . experimental . flaggingProvider . enabled = false
83+ config . getOrigin . returns ( 'env_var' )
84+
85+ assert . deepStrictEqual ( configurationSource . resolve ( config ) , { mode : 'remote_config' } )
86+ assert . strictEqual ( configurationSource . isRemoteConfig ( config ) , true )
87+ assert . strictEqual ( configurationSource . isEnabled ( config ) , true )
88+ } )
89+
90+ it ( 'lets the stable kill switch override every configuration source' , ( ) => {
91+ config . DD_FEATURE_FLAGS_ENABLED = false
92+ config . DD_FEATURE_FLAGS_CONFIGURATION_SOURCE = 'remote_config'
93+ config . experimental . flaggingProvider . enabled = true
94+ config . getOrigin . returns ( 'env_var' )
95+
96+ assert . deepStrictEqual ( configurationSource . resolve ( config ) , { mode : 'disabled' } )
97+ assert . strictEqual ( configurationSource . isRemoteConfig ( config ) , false )
98+ assert . strictEqual ( configurationSource . isEnabled ( config ) , false )
99+ } )
100+
46101 it ( 'defaults to the Datadog UFC CDN endpoint and includes the environment' , ( ) => {
47102 config . DD_SITE = 'raw-env-key.invalid'
48103 const resolved = configurationSource . resolve ( config )
0 commit comments