Skip to content

Commit

Permalink
mssql - fix tests for 4.0 (hashicorp#26764)
Browse files Browse the repository at this point in the history
* fix tests for 4.0

* update code
  • Loading branch information
sinbai authored and lonegunmanb committed Aug 5, 2024
1 parent e089ed0 commit e636cfb
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -423,15 +423,19 @@ resource "azurerm_virtual_network" "test" {
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
lifecycle {
ignore_changes = [subnet]
}
}
resource "azurerm_subnet" "test" {
name = "acctestsubnet%[1]d"
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefixes = ["10.0.2.0/24"]
service_endpoints = ["Microsoft.Storage", "Microsoft.Sql"]
enforce_private_link_endpoint_network_policies = true
name = "acctestsubnet%[1]d"
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefixes = ["10.0.2.0/24"]
service_endpoints = ["Microsoft.Storage", "Microsoft.Sql"]
private_endpoint_network_policies = "Disabled"
}
resource "azurerm_storage_account" "test" {
Expand Down Expand Up @@ -557,9 +561,8 @@ resource "azurerm_monitor_diagnostic_setting" "test" {
target_resource_id = azurerm_mssql_database.test.id
log_analytics_workspace_id = azurerm_log_analytics_workspace.test.id
log {
enabled_log {
category = "SQLSecurityAuditEvents"
enabled = true
retention_policy {
enabled = false
Expand All @@ -574,9 +577,9 @@ resource "azurerm_monitor_diagnostic_setting" "test" {
}
}
// log, metric will return all disabled categories
// enabled_log, metric will return all disabled categories
lifecycle {
ignore_changes = [log, metric]
ignore_changes = [enabled_log, metric]
}
}
Expand All @@ -596,9 +599,8 @@ resource "azurerm_monitor_diagnostic_setting" "test" {
target_resource_id = azurerm_mssql_database.test.id
log_analytics_workspace_id = azurerm_log_analytics_workspace.test.id
log {
enabled_log {
category = "SQLSecurityAuditEvents"
enabled = true
retention_policy {
enabled = false
Expand All @@ -613,9 +615,9 @@ resource "azurerm_monitor_diagnostic_setting" "test" {
}
}
// log, metric will return all disabled categories
// enabled_log, metric will return all disabled categories
lifecycle {
ignore_changes = [log, metric]
ignore_changes = [enabled_log, metric]
}
}
Expand All @@ -639,9 +641,8 @@ resource "azurerm_monitor_diagnostic_setting" "test" {
eventhub_name = azurerm_eventhub.test.name
log {
enabled_log {
category = "SQLSecurityAuditEvents"
enabled = true
retention_policy {
enabled = false
Expand All @@ -656,9 +657,9 @@ resource "azurerm_monitor_diagnostic_setting" "test" {
}
}
// log, metric will return all disabled categories
// enabled_log, metric will return all disabled categories
lifecycle {
ignore_changes = [log, metric]
ignore_changes = [enabled_log, metric]
}
}
Expand All @@ -681,9 +682,8 @@ resource "azurerm_monitor_diagnostic_setting" "test" {
eventhub_name = azurerm_eventhub.test.name
log {
enabled_log {
category = "SQLSecurityAuditEvents"
enabled = true
retention_policy {
enabled = false
Expand All @@ -698,9 +698,9 @@ resource "azurerm_monitor_diagnostic_setting" "test" {
}
}
// log, metric will return all disabled categories
// enabled_log, metric will return all disabled categories
lifecycle {
ignore_changes = [log, metric]
ignore_changes = [enabled_log, metric]
}
}
Expand Down
11 changes: 5 additions & 6 deletions internal/services/mssql/mssql_database_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2024,12 +2024,11 @@ resource "azurerm_storage_blob" "test" {
source = "testdata/sql_import.bacpac"
}
resource "azurerm_sql_firewall_rule" "test" {
name = "allowazure"
resource_group_name = azurerm_resource_group.test.name
server_name = azurerm_mssql_server.test.name
start_ip_address = "0.0.0.0"
end_ip_address = "0.0.0.0"
resource "azurerm_mssql_firewall_rule" "test" {
name = "allowazure"
server_id = azurerm_mssql_server.test.id
start_ip_address = "0.0.0.0"
end_ip_address = "0.0.0.0"
}
resource "azurerm_mssql_database" "test" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ resource "azurerm_virtual_network" "test" {
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
lifecycle {
ignore_changes = [subnet]
}
}
resource "azurerm_subnet" "test" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ resource "azurerm_virtual_network" "test" {
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
lifecycle {
ignore_changes = [subnet]
}
}
resource "azurerm_subnet" "test" {
Expand Down
16 changes: 12 additions & 4 deletions internal/services/mssql/mssql_server_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ resource "azurerm_virtual_network" "test" {
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
address_space = ["10.5.0.0/16"]
lifecycle {
ignore_changes = [subnet]
}
}
resource "azurerm_subnet" "service" {
Expand All @@ -437,7 +441,7 @@ resource "azurerm_subnet" "service" {
virtual_network_name = azurerm_virtual_network.test.name
address_prefixes = ["10.5.1.0/24"]
enforce_private_link_service_network_policies = true
private_link_service_network_policies_enabled = true
}
resource "azurerm_subnet" "endpoint" {
Expand All @@ -446,7 +450,7 @@ resource "azurerm_subnet" "endpoint" {
virtual_network_name = azurerm_virtual_network.test.name
address_prefixes = ["10.5.2.0/24"]
enforce_private_link_endpoint_network_policies = true
private_endpoint_network_policies = "Disabled"
}
resource "azurerm_storage_account" "test" {
Expand Down Expand Up @@ -523,6 +527,10 @@ resource "azurerm_virtual_network" "test" {
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
address_space = ["10.5.0.0/16"]
lifecycle {
ignore_changes = [subnet]
}
}
resource "azurerm_subnet" "service" {
Expand All @@ -531,7 +539,7 @@ resource "azurerm_subnet" "service" {
virtual_network_name = azurerm_virtual_network.test.name
address_prefixes = ["10.5.1.0/24"]
enforce_private_link_service_network_policies = true
private_link_service_network_policies_enabled = true
}
resource "azurerm_subnet" "endpoint" {
Expand All @@ -540,7 +548,7 @@ resource "azurerm_subnet" "endpoint" {
virtual_network_name = azurerm_virtual_network.test.name
address_prefixes = ["10.5.2.0/24"]
enforce_private_link_endpoint_network_policies = true
private_endpoint_network_policies = "Disabled"
}
resource "azurerm_storage_account" "testb" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,23 +371,23 @@ resource "azurerm_user_assigned_identity" "test" {
}
resource "azurerm_key_vault_managed_hardware_security_module_role_assignment" "test" {
vault_base_url = azurerm_key_vault_managed_hardware_security_module.test.hsm_uri
managed_hsm_id = azurerm_key_vault_managed_hardware_security_module.test.id
name = "1e243909-064c-6ac3-84e9-1c8bf8d6ad22"
scope = "/keys"
role_definition_id = "/Microsoft.KeyVault/providers/Microsoft.Authorization/roleDefinitions/21dbd100-6940-42c2-9190-5d6cb909625b"
principal_id = data.azurerm_client_config.current.object_id
}
resource "azurerm_key_vault_managed_hardware_security_module_role_assignment" "test1" {
vault_base_url = azurerm_key_vault_managed_hardware_security_module.test.hsm_uri
managed_hsm_id = azurerm_key_vault_managed_hardware_security_module.test.id
name = "1e243909-064c-6ac3-84e9-1c8bf8d6ad23"
scope = "/keys"
role_definition_id = "/Microsoft.KeyVault/providers/Microsoft.Authorization/roleDefinitions/515eb02d-2335-4d2d-92f2-b1cbdf9c3778"
principal_id = data.azurerm_client_config.current.object_id
}
resource "azurerm_key_vault_managed_hardware_security_module_role_assignment" "user" {
vault_base_url = azurerm_key_vault_managed_hardware_security_module.test.hsm_uri
managed_hsm_id = azurerm_key_vault_managed_hardware_security_module.test.id
name = "1e243909-064c-6ac3-84e9-1c8bf8d6ad20"
scope = "/keys"
role_definition_id = "/Microsoft.KeyVault/providers/Microsoft.Authorization/roleDefinitions/21dbd100-6940-42c2-9190-5d6cb909625b"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,10 @@ resource "azurerm_virtual_network" "test" {
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
dns_servers = ["10.0.1.4", "8.8.8.8"]
lifecycle {
ignore_changes = [subnet]
}
}
resource "azurerm_subnet" "domain_controllers" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ resource "azurerm_virtual_network" "test" {
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
lifecycle {
ignore_changes = [subnet]
}
}
resource "azurerm_subnet" "test" {
Expand All @@ -409,13 +413,18 @@ resource "azurerm_public_ip" "vm" {
name = "acctest-PIP-%[1]d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku = "Basic"
allocation_method = "Dynamic"
}
resource "azurerm_network_security_group" "test" {
name = "acctest-NSG-%[1]d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
lifecycle {
ignore_changes = [security_rule]
}
}
resource "azurerm_network_security_rule" "MSSQLRule" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ resource "azurerm_virtual_network" "test" {
address_space = ["10.7.28.0/23"]
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
lifecycle {
ignore_changes = [subnet]
}
}
resource "azurerm_subnet" "test1" {
Expand Down

0 comments on commit e636cfb

Please sign in to comment.