@@ -55,18 +55,19 @@ public void TestNoUpdateOnGraphQLDepthLimitInRuntimeSettings(object? depthLimit,
5555
5656 // Arrange
5757 _fileSystem ! . AddFile ( TEST_RUNTIME_CONFIG_FILE , initialConfig ) ;
58+ Assert . IsTrue ( _fileSystem ! . File . Exists ( TEST_RUNTIME_CONFIG_FILE ) ) ;
5859
5960 // Act: Run Configure with no options
6061 ConfigureOptions options = new (
6162 config : TEST_RUNTIME_CONFIG_FILE
6263 ) ;
64+ bool isSuccess = TryConfigureSettings ( options , _runtimeConfigLoader ! , _fileSystem ! ) ;
6365
64- Assert . IsTrue ( _fileSystem ! . File . Exists ( TEST_RUNTIME_CONFIG_FILE ) ) ;
65- Assert . IsTrue ( TryConfigureSettings ( options , _runtimeConfigLoader ! , _fileSystem ! ) ) ;
66-
67- string updatedConfig = _fileSystem ! . File . ReadAllText ( TEST_RUNTIME_CONFIG_FILE ) ;
66+ // Assert
67+ Assert . IsTrue ( isSuccess ) ;
6868
6969 // Assert that INITIAL_CONFIG is same as the updated config
70+ string updatedConfig = _fileSystem ! . File . ReadAllText ( TEST_RUNTIME_CONFIG_FILE ) ;
7071 if ( isDepthLimitProvidedInConfig )
7172 {
7273 Assert . IsTrue ( updatedConfig . Contains ( depthLimitSection ) ) ;
@@ -100,9 +101,10 @@ public void TestAddDepthLimitForGraphQL()
100101 depthLimit : maxDepthLimit ,
101102 config : TEST_RUNTIME_CONFIG_FILE
102103 ) ;
103- Assert . IsTrue ( TryConfigureSettings ( options , _runtimeConfigLoader ! , _fileSystem ! ) ) ;
104+ bool isSuccess = TryConfigureSettings ( options , _runtimeConfigLoader ! , _fileSystem ! ) ;
104105
105106 // Assert: Validate the Depth Limit is added
107+ Assert . IsTrue ( isSuccess ) ;
106108 string updatedConfig = _fileSystem ! . File . ReadAllText ( TEST_RUNTIME_CONFIG_FILE ) ;
107109 Assert . IsTrue ( RuntimeConfigLoader . TryParseConfig ( updatedConfig , out config ) ) ;
108110 Assert . IsNotNull ( config . Runtime ? . GraphQL ? . DepthLimit ) ;
@@ -114,8 +116,8 @@ public void TestAddDepthLimitForGraphQL()
114116 /// in runtime. Takes in updated value for graphql.enabled and
115117 /// validates whether the runtime config reflects those updated values
116118 [ DataTestMethod ]
117- [ DataRow ( false , DisplayName = "Update enabled to be false for GraphQL ." ) ]
118- [ DataRow ( true , DisplayName = "Update enabled to be true for GraphQL ." ) ]
119+ [ DataRow ( false , DisplayName = "Update GraphQL.Enabled to false." ) ]
120+ [ DataRow ( true , DisplayName = "Validate GraphQL.Enabled to remain true." ) ]
119121 public void TestUpdateEnabledForGraphQLSettings ( bool updatedEnabledValue )
120122 {
121123 // Arrange -> all the setup which includes creating options.
@@ -126,9 +128,10 @@ public void TestUpdateEnabledForGraphQLSettings(bool updatedEnabledValue)
126128 runtimeGraphQLEnabled : updatedEnabledValue ,
127129 config : TEST_RUNTIME_CONFIG_FILE
128130 ) ;
129- Assert . IsTrue ( TryConfigureSettings ( options , _runtimeConfigLoader ! , _fileSystem ! ) ) ;
131+ bool isSuccess = TryConfigureSettings ( options , _runtimeConfigLoader ! , _fileSystem ! ) ;
130132
131133 // Assert: Validate the Enabled Flag is updated
134+ Assert . IsTrue ( isSuccess ) ;
132135 string updatedConfig = _fileSystem ! . File . ReadAllText ( TEST_RUNTIME_CONFIG_FILE ) ;
133136 Assert . IsTrue ( RuntimeConfigLoader . TryParseConfig ( updatedConfig , out RuntimeConfig ? runtimeConfig ) ) ;
134137 Assert . IsNotNull ( runtimeConfig . Runtime ? . GraphQL ? . Enabled ) ;
@@ -153,9 +156,10 @@ public void TestUpdatePathForGraphQLSettings(string updatedPathValue)
153156 runtimeGraphQLPath : updatedPathValue ,
154157 config : TEST_RUNTIME_CONFIG_FILE
155158 ) ;
156- Assert . IsTrue ( TryConfigureSettings ( options , _runtimeConfigLoader ! , _fileSystem ! ) ) ;
159+ bool isSuccess = TryConfigureSettings ( options , _runtimeConfigLoader ! , _fileSystem ! ) ;
157160
158161 // Assert: Validate the Path update is updated
162+ Assert . IsTrue ( isSuccess ) ;
159163 string updatedConfig = _fileSystem ! . File . ReadAllText ( TEST_RUNTIME_CONFIG_FILE ) ;
160164 Assert . IsTrue ( RuntimeConfigLoader . TryParseConfig ( updatedConfig , out RuntimeConfig ? runtimeConfig ) ) ;
161165 Assert . IsNotNull ( runtimeConfig . Runtime ? . GraphQL ? . Path ) ;
@@ -168,8 +172,8 @@ public void TestUpdatePathForGraphQLSettings(string updatedPathValue)
168172 /// Takes in updated value for graphql.allow-introspection and
169173 /// validates whether the runtime config reflects those updated values
170174 [ DataTestMethod ]
171- [ DataRow ( false , DisplayName = "Update AllowIntrospection to be false for GraphQL ." ) ]
172- [ DataRow ( true , DisplayName = "Update AllowIntrospection to be true for GraphQL ." ) ]
175+ [ DataRow ( false , DisplayName = "Update GraphQL. AllowIntrospection to be false." ) ]
176+ [ DataRow ( true , DisplayName = "Validate GraphQL. AllowIntrospection to remain true." ) ]
173177 public void TestUpdateAllowIntrospectionForGraphQLSettings ( bool updatedAllowIntrospectionValue )
174178 {
175179 // Arrange -> all the setup which includes creating options.
@@ -180,9 +184,10 @@ public void TestUpdateAllowIntrospectionForGraphQLSettings(bool updatedAllowIntr
180184 runtimeGraphQLAllowIntrospection : updatedAllowIntrospectionValue ,
181185 config : TEST_RUNTIME_CONFIG_FILE
182186 ) ;
183- Assert . IsTrue ( TryConfigureSettings ( options , _runtimeConfigLoader ! , _fileSystem ! ) ) ;
187+ bool isSuccess = TryConfigureSettings ( options , _runtimeConfigLoader ! , _fileSystem ! ) ;
184188
185189 // Assert: Validate the Allow-Introspection value is updated
190+ Assert . IsTrue ( isSuccess ) ;
186191 string updatedConfig = _fileSystem ! . File . ReadAllText ( TEST_RUNTIME_CONFIG_FILE ) ;
187192 Assert . IsTrue ( RuntimeConfigLoader . TryParseConfig ( updatedConfig , out RuntimeConfig ? runtimeConfig ) ) ;
188193 Assert . IsNotNull ( runtimeConfig . Runtime ? . GraphQL ? . AllowIntrospection ) ;
@@ -195,8 +200,8 @@ public void TestUpdateAllowIntrospectionForGraphQLSettings(bool updatedAllowIntr
195200 /// Takes in updated value for multiple mutations.create.enabled and
196201 /// validates whether the runtime config reflects those updated values
197202 [ DataTestMethod ]
198- [ DataRow ( false , DisplayName = "Update MultipleMutation.Create.Enabled to be false for GraphQL ." ) ]
199- [ DataRow ( true , DisplayName = "Update MultipleMutation.Create.Enabled to be true for GraphQL ." ) ]
203+ [ DataRow ( false , DisplayName = "Update GraphQL. MultipleMutation.Create.Enabled to be false." ) ]
204+ [ DataRow ( true , DisplayName = "Validate GraphQL. MultipleMutation.Create.Enabled to remain true." ) ]
200205 public void TestUpdateMultipleMutationCreateEnabledForGraphQLSettings ( bool updatedMultipleMutationsCreateEnabledValue )
201206 {
202207 // Arrange -> all the setup which includes creating options.
@@ -207,9 +212,10 @@ public void TestUpdateMultipleMutationCreateEnabledForGraphQLSettings(bool updat
207212 runtimeGraphQLMultipleMutationsCreateEnabled : updatedMultipleMutationsCreateEnabledValue ,
208213 config : TEST_RUNTIME_CONFIG_FILE
209214 ) ;
210- Assert . IsTrue ( TryConfigureSettings ( options , _runtimeConfigLoader ! , _fileSystem ! ) ) ;
215+ bool isSuccess = TryConfigureSettings ( options , _runtimeConfigLoader ! , _fileSystem ! ) ;
211216
212217 // Assert: Validate the Multiple-Mutation.Create.Enabled is updated
218+ Assert . IsTrue ( isSuccess ) ;
213219 string updatedConfig = _fileSystem ! . File . ReadAllText ( TEST_RUNTIME_CONFIG_FILE ) ;
214220 Assert . IsTrue ( RuntimeConfigLoader . TryParseConfig ( updatedConfig , out RuntimeConfig ? runtimeConfig ) ) ;
215221 Assert . IsNotNull ( runtimeConfig . Runtime ? . GraphQL ? . MultipleMutationOptions ? . MultipleCreateOptions ? . Enabled ) ;
@@ -235,9 +241,10 @@ public void TestUpdateMultipleParametersForGraphQLSettings()
235241 runtimeGraphQLAllowIntrospection : updatedAllowIntrospectionValue ,
236242 config : TEST_RUNTIME_CONFIG_FILE
237243 ) ;
238- Assert . IsTrue ( TryConfigureSettings ( options , _runtimeConfigLoader ! , _fileSystem ! ) ) ;
244+ bool isSuccess = TryConfigureSettings ( options , _runtimeConfigLoader ! , _fileSystem ! ) ;
239245
240246 // Assert: Validate the path is updated and allow introspection is updated
247+ Assert . IsTrue ( isSuccess ) ;
241248 string updatedConfig = _fileSystem ! . File . ReadAllText ( TEST_RUNTIME_CONFIG_FILE ) ;
242249 Assert . IsTrue ( RuntimeConfigLoader . TryParseConfig ( updatedConfig , out RuntimeConfig ? runtimeConfig ) ) ;
243250 Assert . IsNotNull ( runtimeConfig . Runtime ? . GraphQL ? . Path ) ;
@@ -246,6 +253,171 @@ public void TestUpdateMultipleParametersForGraphQLSettings()
246253 Assert . AreEqual ( updatedAllowIntrospectionValue , runtimeConfig . Runtime . GraphQL . AllowIntrospection ) ;
247254 }
248255
256+ /// <summary>
257+ /// Tests that running "dab configure --runtime.rest.enabled {value}" on a config with various values results
258+ /// in runtime config update. Takes in updated value for rest.enabled and
259+ /// validates whether the runtime config reflects those updated values
260+ [ DataTestMethod ]
261+ [ DataRow ( false , DisplayName = "Update Rest.Enabled to false." ) ]
262+ [ DataRow ( true , DisplayName = "Validate if Rest.Enabled remains true." ) ]
263+ public void TestUpdateEnabledForRestSettings ( bool updatedEnabledValue )
264+ {
265+ // Arrange -> all the setup which includes creating options.
266+ SetupFileSystemWithInitialConfig ( INITIAL_CONFIG ) ;
267+
268+ // Act: Attempts to update enabled flag
269+ ConfigureOptions options = new (
270+ runtimeRestEnabled : updatedEnabledValue ,
271+ config : TEST_RUNTIME_CONFIG_FILE
272+ ) ;
273+ bool isSuccess = TryConfigureSettings ( options , _runtimeConfigLoader ! , _fileSystem ! ) ;
274+
275+ // Assert: Validate the Enabled Flag is updated
276+ Assert . IsTrue ( isSuccess ) ;
277+ string updatedConfig = _fileSystem ! . File . ReadAllText ( TEST_RUNTIME_CONFIG_FILE ) ;
278+ Assert . IsTrue ( RuntimeConfigLoader . TryParseConfig ( updatedConfig , out RuntimeConfig ? runtimeConfig ) ) ;
279+ Assert . IsNotNull ( runtimeConfig . Runtime ? . Rest ? . Enabled ) ;
280+ Assert . AreEqual ( updatedEnabledValue , runtimeConfig . Runtime . Rest . Enabled ) ;
281+ }
282+
283+ /// <summary>
284+ /// Tests that running "dab configure --runtime.rest.path {value}" on a config with various values results
285+ /// in runtime config update. Takes in updated value for rest.path and
286+ /// validates whether the runtime config reflects those updated values
287+ [ DataTestMethod ]
288+ [ DataRow ( "/updatedPath" , DisplayName = "Update REST path to /updatedPath." ) ]
289+ [ DataRow ( "/updated_Path" , DisplayName = "Ensure underscore is allowed in REST path." ) ]
290+ [ DataRow ( "/updated-Path" , DisplayName = "Ensure hyphen is allowed in REST path." ) ]
291+ public void TestUpdatePathForRestSettings ( string updatedPathValue )
292+ {
293+ // Arrange -> all the setup which includes creating options.
294+ SetupFileSystemWithInitialConfig ( INITIAL_CONFIG ) ;
295+
296+ // Act: Attempts to update path value
297+ ConfigureOptions options = new (
298+ runtimeRestPath : updatedPathValue ,
299+ config : TEST_RUNTIME_CONFIG_FILE
300+ ) ;
301+ bool isSuccess = TryConfigureSettings ( options , _runtimeConfigLoader ! , _fileSystem ! ) ;
302+
303+ // Assert: Validate the Path update is updated
304+ Assert . IsTrue ( isSuccess ) ;
305+ string updatedConfig = _fileSystem ! . File . ReadAllText ( TEST_RUNTIME_CONFIG_FILE ) ;
306+ Assert . IsTrue ( RuntimeConfigLoader . TryParseConfig ( updatedConfig , out RuntimeConfig ? runtimeConfig ) ) ;
307+ Assert . IsNotNull ( runtimeConfig . Runtime ? . Rest ? . Path ) ;
308+ Assert . AreEqual ( updatedPathValue , runtimeConfig . Runtime . Rest . Path ) ;
309+ }
310+
311+ /// <summary>
312+ /// Tests that running "dab configure --runtime.rest.request-body-strict" on a config with various values results
313+ /// in runtime config update. Takes in updated value for rest.request-body-strict and
314+ /// validates whether the runtime config reflects those updated values
315+ [ DataTestMethod ]
316+ [ DataRow ( false , DisplayName = "Update Rest.Request-Body-Strict to false." ) ]
317+ [ DataRow ( true , DisplayName = "Validate if Rest.Request-body-Strict remains true." ) ]
318+ public void TestUpdateRequestBodyStrictForRestSettings ( bool updatedRequestBodyStrictValue )
319+ {
320+ // Arrange -> all the setup which includes creating options.
321+ SetupFileSystemWithInitialConfig ( INITIAL_CONFIG ) ;
322+
323+ // Act: Attempts to update request-body-strict value
324+ ConfigureOptions options = new (
325+ runtimeRestRequestBodyStrict : updatedRequestBodyStrictValue ,
326+ config : TEST_RUNTIME_CONFIG_FILE
327+ ) ;
328+ bool isSuccess = TryConfigureSettings ( options , _runtimeConfigLoader ! , _fileSystem ! ) ;
329+
330+ // Assert: Validate the RequestBodyStrict Value is updated
331+ Assert . IsTrue ( isSuccess ) ;
332+ string updatedConfig = _fileSystem ! . File . ReadAllText ( TEST_RUNTIME_CONFIG_FILE ) ;
333+ Assert . IsTrue ( RuntimeConfigLoader . TryParseConfig ( updatedConfig , out RuntimeConfig ? runtimeConfig ) ) ;
334+ Assert . IsNotNull ( runtimeConfig . Runtime ? . Rest ? . RequestBodyStrict ) ;
335+ Assert . AreEqual ( updatedRequestBodyStrictValue , runtimeConfig . Runtime . Rest . RequestBodyStrict ) ;
336+ }
337+
338+ /// <summary>
339+ /// Tests that running "dab configure --runtime.rest.enabled {value} --runtime.rest.path {value}"
340+ /// on a config with various values results in runtime config update.
341+ /// Takes in updated value for enabled and path and further
342+ /// validates whether the runtime config reflects those updated values
343+ [ DataTestMethod ]
344+ [ DataRow ( false , "/updatedPath" , DisplayName = "Update enabled flag and path in Rest runtime settings." ) ]
345+ public void TestUpdateMultipleParametersRestSettings ( bool updatedEnabledValue , string updatedPathValue )
346+ {
347+ // Arrange -> all the setup which includes creating options.
348+ SetupFileSystemWithInitialConfig ( INITIAL_CONFIG ) ;
349+
350+ // Act: Attempts to update the path value and enabled flag
351+ ConfigureOptions options = new (
352+ runtimeRestPath : updatedPathValue ,
353+ runtimeRestEnabled : updatedEnabledValue ,
354+ config : TEST_RUNTIME_CONFIG_FILE
355+ ) ;
356+ bool isSuccess = TryConfigureSettings ( options , _runtimeConfigLoader ! , _fileSystem ! ) ;
357+
358+ // Assert: Validate the path is updated and enabled is updated
359+ Assert . IsTrue ( isSuccess ) ;
360+ string updatedConfig = _fileSystem ! . File . ReadAllText ( TEST_RUNTIME_CONFIG_FILE ) ;
361+ Assert . IsTrue ( RuntimeConfigLoader . TryParseConfig ( updatedConfig , out RuntimeConfig ? runtimeConfig ) ) ;
362+ Assert . IsNotNull ( runtimeConfig . Runtime ? . Rest ? . Path ) ;
363+ Assert . IsNotNull ( runtimeConfig . Runtime ? . Rest ? . Enabled ) ;
364+ Assert . AreEqual ( updatedPathValue , runtimeConfig . Runtime . Rest . Path ) ;
365+ Assert . AreEqual ( updatedEnabledValue , runtimeConfig . Runtime . Rest . Enabled ) ;
366+ }
367+
368+ /// <summary>
369+ /// Validates that running "dab configure --runtime.cache.enabled" on a config with various values results
370+ /// in runtime config update. Takes in updated value for cache.enabled and
371+ /// validates whether the runtime config reflects those updated values.
372+ [ DataTestMethod ]
373+ [ DataRow ( false , DisplayName = "Update Cache.Enabled to false." ) ]
374+ [ DataRow ( true , DisplayName = "Validate if Cache.Enabled remains true." ) ]
375+ public void TestUpdateEnabledForCacheSettings ( bool updatedEnabledValue )
376+ {
377+ // Arrange -> all the setup which includes creating options.
378+ SetupFileSystemWithInitialConfig ( INITIAL_CONFIG ) ;
379+
380+ // Act: Attempts to update cache enabled flag
381+ ConfigureOptions options = new (
382+ runtimeCacheEnabled : updatedEnabledValue ,
383+ config : TEST_RUNTIME_CONFIG_FILE
384+ ) ;
385+ bool isSuccess = TryConfigureSettings ( options , _runtimeConfigLoader ! , _fileSystem ! ) ;
386+
387+ // Assert: Validate the cache Enabled Flag is updated
388+ Assert . IsTrue ( isSuccess ) ;
389+ string updatedConfig = _fileSystem ! . File . ReadAllText ( TEST_RUNTIME_CONFIG_FILE ) ;
390+ Assert . IsTrue ( RuntimeConfigLoader . TryParseConfig ( updatedConfig , out RuntimeConfig ? runtimeConfig ) ) ;
391+ Assert . IsNotNull ( runtimeConfig . Runtime ? . Cache ? . Enabled ) ;
392+ Assert . AreEqual ( updatedEnabledValue , runtimeConfig . Runtime . Cache . Enabled ) ;
393+ }
394+
395+ /// <summary>
396+ /// Tests that running "dab configure --runtime.cache.ttl-seconds" on a config with various values results
397+ /// in runtime config update. Takes in updated value for cache.ttl-seconds and
398+ /// validates whether the runtime config reflects those updated values
399+ [ DataTestMethod ]
400+ [ DataRow ( 4 , DisplayName = "Update global cache TTL to 4." ) ]
401+ public void TestUpdateTTLForCacheSettings ( int updatedTtlValue )
402+ {
403+ // Arrange -> all the setup which includes creating options.
404+ SetupFileSystemWithInitialConfig ( INITIAL_CONFIG ) ;
405+
406+ // Act: Attempts to update TTL Value
407+ ConfigureOptions options = new (
408+ runtimeCacheTtl : updatedTtlValue ,
409+ config : TEST_RUNTIME_CONFIG_FILE
410+ ) ;
411+ bool isSuccess = TryConfigureSettings ( options , _runtimeConfigLoader ! , _fileSystem ! ) ;
412+
413+ // Assert: Validate the TTL Value is updated
414+ Assert . IsTrue ( isSuccess ) ;
415+ string updatedConfig = _fileSystem ! . File . ReadAllText ( TEST_RUNTIME_CONFIG_FILE ) ;
416+ Assert . IsTrue ( RuntimeConfigLoader . TryParseConfig ( updatedConfig , out RuntimeConfig ? runtimeConfig ) ) ;
417+ Assert . IsNotNull ( runtimeConfig . Runtime ? . Cache ? . TtlSeconds ) ;
418+ Assert . AreEqual ( updatedTtlValue , runtimeConfig . Runtime . Cache . TtlSeconds ) ;
419+ }
420+
249421 /// <summary>
250422 /// Test to update the current depth limit for GraphQL and removal the depth limit using -1.
251423 /// When runtime.graphql.depth-limit has an initial value of 8.
@@ -279,9 +451,10 @@ public void TestUpdateDepthLimitForGraphQL(int? newDepthLimit)
279451 ) ;
280452
281453 // Act: Update Depth Limit
282- Assert . IsTrue ( TryConfigureSettings ( options , _runtimeConfigLoader ! , _fileSystem ! ) ) ;
454+ bool isSuccess = TryConfigureSettings ( options , _runtimeConfigLoader ! , _fileSystem ! ) ;
283455
284456 // Assert: Validate the Depth Limit is updated
457+ Assert . IsTrue ( isSuccess ) ;
285458 string updatedConfig = _fileSystem ! . File . ReadAllText ( TEST_RUNTIME_CONFIG_FILE ) ;
286459 Assert . IsTrue ( RuntimeConfigLoader . TryParseConfig ( updatedConfig , out config ) ) ;
287460
0 commit comments