Skip to content

Commit

Permalink
Requested review changes
Browse files Browse the repository at this point in the history
- Remove unnecessary ${}
- Use `versionless_id` proeprty instead of manual key URL construction
- Use numbered string formats
- Applied these fixes to the prior "versioned key" test cases as well
  • Loading branch information
alfpark committed May 11, 2023
1 parent 6882862 commit 74d276d
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 74 deletions.
74 changes: 37 additions & 37 deletions internal/services/batch/batch_account_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,26 +245,26 @@ data "azurerm_client_config" "current" {
}
resource "azurerm_resource_group" "test" {
name = "testaccRG-batch-%d"
location = "%s"
name = "testaccRG-batch-%[1]d"
location = "%[2]s"
}
resource "azurerm_storage_account" "test" {
name = "testaccsa%s"
name = "testaccsa%[3]s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
account_tier = "Standard"
account_replication_type = "LRS"
}
resource "azurerm_user_assigned_identity" "test" {
name = "acctest%s"
name = "acctest%[3]s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
}
resource "azurerm_batch_account" "test" {
name = "testaccbatch%s"
name = "testaccbatch%[3]s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
pool_allocation_mode = "BatchService"
Expand All @@ -281,20 +281,20 @@ resource "azurerm_batch_account" "test" {
}
resource "azurerm_key_vault" "test" {
name = "batchkv%s"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
name = "batchkv%[3]s"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
enabled_for_disk_encryption = true
enabled_for_deployment = true
enabled_for_template_deployment = true
purge_protection_enabled = true
tenant_id = "%s"
tenant_id = "%[4]s"
sku_name = "standard"
access_policy {
tenant_id = "%s"
object_id = "${data.azurerm_client_config.current.object_id}"
tenant_id = "%[4]s"
object_id = data.azurerm_client_config.current.object_id
key_permissions = [
"Get",
Expand All @@ -308,8 +308,8 @@ resource "azurerm_key_vault" "test" {
}
access_policy {
tenant_id = "%s"
object_id = "${azurerm_user_assigned_identity.test.principal_id}"
tenant_id = "%[4]s"
object_id = azurerm_user_assigned_identity.test.principal_id
key_permissions = [
"Get",
Expand All @@ -320,8 +320,8 @@ resource "azurerm_key_vault" "test" {
}
resource "azurerm_key_vault_key" "test" {
name = "enckey%d"
key_vault_id = "${azurerm_key_vault.test.id}"
name = "enckey%[1]d"
key_vault_id = azurerm_key_vault.test.id
key_type = "RSA"
key_size = 2048
Expand All @@ -336,11 +336,11 @@ resource "azurerm_key_vault_key" "test" {
}
data "azurerm_batch_account" "test" {
name = "${azurerm_batch_account.test.name}"
resource_group_name = "${azurerm_resource_group.test.name}"
name = azurerm_batch_account.test.name
resource_group_name = azurerm_resource_group.test.name
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomString, data.RandomString, data.RandomString, tenantID, tenantID, tenantID, data.RandomInteger)
`, data.RandomInteger, data.Locations.Primary, data.RandomString, tenantID)
}

func (BatchAccountDataSource) cmkVersionlessKeyData(data acceptance.TestData, tenantID string) string {
Expand All @@ -358,26 +358,26 @@ data "azurerm_client_config" "current" {
}
resource "azurerm_resource_group" "test" {
name = "testaccRG-batch-%d"
location = "%s"
name = "testaccRG-batch-%[1]d"
location = "%[2]s"
}
resource "azurerm_storage_account" "test" {
name = "testaccsa%s"
name = "testaccsa%[3]s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
account_tier = "Standard"
account_replication_type = "LRS"
}
resource "azurerm_user_assigned_identity" "test" {
name = "acctest%s"
name = "acctest%[3]s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
}
resource "azurerm_batch_account" "test" {
name = "testaccbatch%s"
name = "testaccbatch%[3]s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
pool_allocation_mode = "BatchService"
Expand All @@ -389,25 +389,25 @@ resource "azurerm_batch_account" "test" {
}
encryption {
key_vault_key_id = "${azurerm_key_vault.test.vault_uri}keys/${azurerm_key_vault_key.test.name}"
key_vault_key_id = azurerm_key_vault_key.test.versionless_id
}
}
resource "azurerm_key_vault" "test" {
name = "batchkv%s"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
name = "batchkv%[3]s"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
enabled_for_disk_encryption = true
enabled_for_deployment = true
enabled_for_template_deployment = true
purge_protection_enabled = true
tenant_id = "%s"
tenant_id = "%[4]s"
sku_name = "standard"
access_policy {
tenant_id = "%s"
object_id = "${data.azurerm_client_config.current.object_id}"
tenant_id = "%[4]s"
object_id = data.azurerm_client_config.current.object_id
key_permissions = [
"Get",
Expand All @@ -421,8 +421,8 @@ resource "azurerm_key_vault" "test" {
}
access_policy {
tenant_id = "%s"
object_id = "${azurerm_user_assigned_identity.test.principal_id}"
tenant_id = "%[4]s"
object_id = azurerm_user_assigned_identity.test.principal_id
key_permissions = [
"Get",
Expand All @@ -433,8 +433,8 @@ resource "azurerm_key_vault" "test" {
}
resource "azurerm_key_vault_key" "test" {
name = "enckey%d"
key_vault_id = "${azurerm_key_vault.test.id}"
name = "enckey%[1]d"
key_vault_id = azurerm_key_vault.test.id
key_type = "RSA"
key_size = 2048
Expand All @@ -449,9 +449,9 @@ resource "azurerm_key_vault_key" "test" {
}
data "azurerm_batch_account" "test" {
name = "${azurerm_batch_account.test.name}"
resource_group_name = "${azurerm_resource_group.test.name}"
name = azurerm_batch_account.test.name
resource_group_name = azurerm_resource_group.test.name
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomString, data.RandomString, data.RandomString, tenantID, tenantID, tenantID, data.RandomInteger)
`, data.RandomInteger, data.Locations.Primary, data.RandomString, tenantID)
}
66 changes: 33 additions & 33 deletions internal/services/batch/batch_account_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,26 +574,26 @@ data "azurerm_client_config" "current" {
}
resource "azurerm_resource_group" "test" {
name = "testaccRG-batch-%d"
location = "%s"
name = "testaccRG-batch-%[1]d"
location = "%[2]s"
}
resource "azurerm_storage_account" "test" {
name = "testaccsa%s"
name = "testaccsa%[3]s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
account_tier = "Standard"
account_replication_type = "LRS"
}
resource "azurerm_user_assigned_identity" "test" {
name = "acctest%s"
name = "acctest%[3]s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
}
resource "azurerm_batch_account" "test" {
name = "testaccbatch%s"
name = "testaccbatch%[3]s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
pool_allocation_mode = "BatchService"
Expand All @@ -610,20 +610,20 @@ resource "azurerm_batch_account" "test" {
}
resource "azurerm_key_vault" "test" {
name = "batchkv%s"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
name = "batchkv%[3]s"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
enabled_for_disk_encryption = true
enabled_for_deployment = true
enabled_for_template_deployment = true
purge_protection_enabled = true
tenant_id = "%s"
tenant_id = "%[4]s"
sku_name = "standard"
access_policy {
tenant_id = "%s"
object_id = "${data.azurerm_client_config.current.object_id}"
tenant_id = "%[4]s"
object_id = data.azurerm_client_config.current.object_id
key_permissions = [
"Get",
Expand All @@ -637,8 +637,8 @@ resource "azurerm_key_vault" "test" {
}
access_policy {
tenant_id = "%s"
object_id = "${azurerm_user_assigned_identity.test.principal_id}"
tenant_id = "%[4]s"
object_id = azurerm_user_assigned_identity.test.principal_id
key_permissions = [
"Get",
Expand All @@ -649,8 +649,8 @@ resource "azurerm_key_vault" "test" {
}
resource "azurerm_key_vault_key" "test" {
name = "enckey%d"
key_vault_id = "${azurerm_key_vault.test.id}"
name = "enckey%[1]d"
key_vault_id = azurerm_key_vault.test.id
key_type = "RSA"
key_size = 2048
Expand All @@ -664,7 +664,7 @@ resource "azurerm_key_vault_key" "test" {
]
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomString, data.RandomString, data.RandomString, tenantID, tenantID, tenantID, data.RandomInteger)
`, data.RandomInteger, data.Locations.Primary, data.RandomString, tenantID)
}

func (BatchAccountResource) cmkVersionlessKey(data acceptance.TestData, tenantID string) string {
Expand All @@ -682,26 +682,26 @@ data "azurerm_client_config" "current" {
}
resource "azurerm_resource_group" "test" {
name = "testaccRG-batch-%d"
location = "%s"
name = "testaccRG-batch-%[1]d"
location = "%[2]s"
}
resource "azurerm_storage_account" "test" {
name = "testaccsa%s"
name = "testaccsa%[3]s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
account_tier = "Standard"
account_replication_type = "LRS"
}
resource "azurerm_user_assigned_identity" "test" {
name = "acctest%s"
name = "acctest%[3]s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
}
resource "azurerm_batch_account" "test" {
name = "testaccbatch%s"
name = "testaccbatch%[3]s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
pool_allocation_mode = "BatchService"
Expand All @@ -713,25 +713,25 @@ resource "azurerm_batch_account" "test" {
}
encryption {
key_vault_key_id = "${azurerm_key_vault.test.vault_uri}keys/${azurerm_key_vault_key.test.name}"
key_vault_key_id = azurerm_key_vault_key.test.versionless_id
}
}
resource "azurerm_key_vault" "test" {
name = "batchkv%s"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
name = "batchkv%[3]s"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
enabled_for_disk_encryption = true
enabled_for_deployment = true
enabled_for_template_deployment = true
purge_protection_enabled = true
tenant_id = "%s"
tenant_id = "%[4]s"
sku_name = "standard"
access_policy {
tenant_id = "%s"
object_id = "${data.azurerm_client_config.current.object_id}"
tenant_id = "%[4]s"
object_id = data.azurerm_client_config.current.object_id
key_permissions = [
"Get",
Expand All @@ -745,8 +745,8 @@ resource "azurerm_key_vault" "test" {
}
access_policy {
tenant_id = "%s"
object_id = "${azurerm_user_assigned_identity.test.principal_id}"
tenant_id = "%[4]s"
object_id = azurerm_user_assigned_identity.test.principal_id
key_permissions = [
"Get",
Expand All @@ -757,8 +757,8 @@ resource "azurerm_key_vault" "test" {
}
resource "azurerm_key_vault_key" "test" {
name = "enckey%d"
key_vault_id = "${azurerm_key_vault.test.id}"
name = "enckey%[1]d"
key_vault_id = azurerm_key_vault.test.id
key_type = "RSA"
key_size = 2048
Expand All @@ -772,7 +772,7 @@ resource "azurerm_key_vault_key" "test" {
]
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomString, data.RandomString, data.RandomString, tenantID, tenantID, tenantID, data.RandomInteger)
`, data.RandomInteger, data.Locations.Primary, data.RandomString, tenantID)
}

func (BatchAccountResource) removeStorageAccount(data acceptance.TestData) string {
Expand Down
Loading

0 comments on commit 74d276d

Please sign in to comment.