@@ -256,6 +256,55 @@ func TestAccLogAnalyticsWorkspace_ToggleAllowOnlyResourcePermission(t *testing.T
256256 })
257257}
258258
259+ func TestAccLogAnalyticsWorkspace_ToggleEnableLocalAuthDeprecated (t * testing.T ) {
260+ data := acceptance .BuildTestData (t , "azurerm_log_analytics_workspace" , "test" )
261+ r := LogAnalyticsWorkspaceResource {}
262+
263+ if features .FivePointOh () {
264+ t .Skip ("Skipping since local_authentication_disabled is deprecated in 5.0" )
265+ }
266+
267+ data .ResourceTest (t , r , []acceptance.TestStep {
268+ {
269+ Config : r .localAuthEnabledDeprecated (data , true ),
270+ Check : acceptance .ComposeTestCheckFunc (
271+ check .That (data .ResourceName ).ExistsInAzure (r ),
272+ check .That (data .ResourceName ).Key ("local_authentication_enabled" ).HasValue ("true" ),
273+ check .That (data .ResourceName ).Key ("local_authentication_disabled" ).HasValue ("false" ),
274+ ),
275+ },
276+ data .ImportStep (),
277+ {
278+ Config : r .localAuthEnabledDeprecated (data , false ),
279+ Check : acceptance .ComposeTestCheckFunc (
280+ check .That (data .ResourceName ).ExistsInAzure (r ),
281+ check .That (data .ResourceName ).Key ("local_authentication_enabled" ).HasValue ("false" ),
282+ check .That (data .ResourceName ).Key ("local_authentication_disabled" ).HasValue ("true" ),
283+ ),
284+ },
285+ data .ImportStep (),
286+
287+ {
288+ Config : r .localAuthEnabledDeprecated (data , true ),
289+ Check : acceptance .ComposeTestCheckFunc (
290+ check .That (data .ResourceName ).ExistsInAzure (r ),
291+ check .That (data .ResourceName ).Key ("local_authentication_enabled" ).HasValue ("true" ),
292+ check .That (data .ResourceName ).Key ("local_authentication_disabled" ).HasValue ("false" ),
293+ ),
294+ },
295+ data .ImportStep (),
296+ {
297+ Config : r .basic (data ),
298+ Check : acceptance .ComposeTestCheckFunc (
299+ check .That (data .ResourceName ).ExistsInAzure (r ),
300+ check .That (data .ResourceName ).Key ("local_authentication_enabled" ).HasValue ("true" ),
301+ check .That (data .ResourceName ).Key ("local_authentication_disabled" ).HasValue ("false" ),
302+ ),
303+ },
304+ data .ImportStep (),
305+ })
306+ }
307+
259308func TestAccLogAnalyticsWorkspace_ToggleEnableLocalAuth (t * testing.T ) {
260309 data := acceptance .BuildTestData (t , "azurerm_log_analytics_workspace" , "test" )
261310 r := LogAnalyticsWorkspaceResource {}
@@ -265,20 +314,31 @@ func TestAccLogAnalyticsWorkspace_ToggleEnableLocalAuth(t *testing.T) {
265314 Config : r .localAuthEnabled (data , false ),
266315 Check : acceptance .ComposeTestCheckFunc (
267316 check .That (data .ResourceName ).ExistsInAzure (r ),
317+ check .That (data .ResourceName ).Key ("local_authentication_enabled" ).HasValue ("false" ),
268318 ),
269319 },
270320 data .ImportStep (),
271321 {
272322 Config : r .localAuthEnabled (data , true ),
273323 Check : acceptance .ComposeTestCheckFunc (
274324 check .That (data .ResourceName ).ExistsInAzure (r ),
325+ check .That (data .ResourceName ).Key ("local_authentication_enabled" ).HasValue ("true" ),
275326 ),
276327 },
277328 data .ImportStep (),
278329 {
279330 Config : r .localAuthEnabled (data , false ),
280331 Check : acceptance .ComposeTestCheckFunc (
281332 check .That (data .ResourceName ).ExistsInAzure (r ),
333+ check .That (data .ResourceName ).Key ("local_authentication_enabled" ).HasValue ("false" ),
334+ ),
335+ },
336+ data .ImportStep (),
337+ {
338+ Config : r .basic (data ),
339+ Check : acceptance .ComposeTestCheckFunc (
340+ check .That (data .ResourceName ).ExistsInAzure (r ),
341+ check .That (data .ResourceName ).Key ("local_authentication_enabled" ).HasValue ("true" ),
282342 ),
283343 },
284344 data .ImportStep (),
@@ -800,9 +860,8 @@ resource "azurerm_log_analytics_workspace" "test" {
800860` , data .RandomInteger , data .Locations .Primary , data .RandomInteger , useResourceOnlyPermission )
801861}
802862
803- func (LogAnalyticsWorkspaceResource ) localAuthEnabled (data acceptance.TestData , localAuthEnabled bool ) string {
804- if ! features .FivePointOh () {
805- return fmt .Sprintf (`
863+ func (LogAnalyticsWorkspaceResource ) localAuthEnabledDeprecated (data acceptance.TestData , localAuthEnabled bool ) string {
864+ return fmt .Sprintf (`
806865provider "azurerm" {
807866 features {}
808867}
@@ -821,7 +880,9 @@ resource "azurerm_log_analytics_workspace" "test" {
821880 local_authentication_disabled = %[4]t
822881}
823882` , data .RandomInteger , data .Locations .Primary , data .RandomInteger , ! localAuthEnabled )
824- }
883+ }
884+
885+ func (LogAnalyticsWorkspaceResource ) localAuthEnabled (data acceptance.TestData , localAuthEnabled bool ) string {
825886 return fmt .Sprintf (`
826887provider "azurerm" {
827888 features {}
@@ -833,11 +894,11 @@ resource "azurerm_resource_group" "test" {
833894}
834895
835896resource "azurerm_log_analytics_workspace" "test" {
836- name = "acctestLAW-%d"
837- location = azurerm_resource_group.test.location
838- resource_group_name = azurerm_resource_group.test.name
839- sku = "PerGB2018"
840- retention_in_days = 30
897+ name = "acctestLAW-%d"
898+ location = azurerm_resource_group.test.location
899+ resource_group_name = azurerm_resource_group.test.name
900+ sku = "PerGB2018"
901+ retention_in_days = 30
841902 local_authentication_enabled = %[4]t
842903}
843904` , data .RandomInteger , data .Locations .Primary , data .RandomInteger , localAuthEnabled )
0 commit comments