From db2eb7e44c89a1946f4d87db25d1ab8b6aadfd82 Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Mon, 8 Jan 2024 16:22:31 +0800 Subject: [PATCH] fix #24402 --- .../services/authorization/role_definition_data_source.go | 5 ++--- .../authorization/role_definition_data_source_test.go | 7 ------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/internal/services/authorization/role_definition_data_source.go b/internal/services/authorization/role_definition_data_source.go index 3e1770c3822a..9c2421635157 100644 --- a/internal/services/authorization/role_definition_data_source.go +++ b/internal/services/authorization/role_definition_data_source.go @@ -193,9 +193,8 @@ func (a RoleDefinitionDataSource) Read() sdk.ResourceFunc { } state := RoleDefinitionDataSourceModel{ - Scope: config.Scope, - // Though the property is called "Name", it's UUID in fact. - RoleDefinitionId: pointer.From(role.Name), + Scope: config.Scope, + RoleDefinitionId: defId, } state.Name = pointer.From(role.RoleName) diff --git a/internal/services/authorization/role_definition_data_source_test.go b/internal/services/authorization/role_definition_data_source_test.go index 0488ecc8ae01..0b27906f196b 100644 --- a/internal/services/authorization/role_definition_data_source_test.go +++ b/internal/services/authorization/role_definition_data_source_test.go @@ -23,7 +23,6 @@ func TestAccRoleDefinitionDataSource_basic(t *testing.T) { Config: RoleDefinitionDataSource{}.basic(id, data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).Key("name").Exists(), - check.That(data.ResourceName).Key("role_definition_id").IsUUID(), check.That(data.ResourceName).Key("description").Exists(), check.That(data.ResourceName).Key("type").Exists(), check.That(data.ResourceName).Key("permissions.#").HasValue("1"), @@ -47,7 +46,6 @@ func TestAccRoleDefinitionDataSource_basicByName(t *testing.T) { Config: RoleDefinitionDataSource{}.byName(id, data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).Key("name").Exists(), - check.That(data.ResourceName).Key("role_definition_id").IsUUID(), check.That(data.ResourceName).Key("description").Exists(), check.That(data.ResourceName).Key("type").Exists(), check.That(data.ResourceName).Key("permissions.#").HasValue("1"), @@ -70,7 +68,6 @@ func TestAccRoleDefinitionDataSource_builtIn_contributor(t *testing.T) { Config: RoleDefinitionDataSource{}.builtIn("Contributor"), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).Key("id").HasValue("/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"), - check.That(data.ResourceName).Key("role_definition_id").IsUUID(), check.That(data.ResourceName).Key("description").Exists(), check.That(data.ResourceName).Key("type").Exists(), check.That(data.ResourceName).Key("permissions.#").HasValue("1"), @@ -98,8 +95,6 @@ func TestAccRoleDefinitionDataSource_builtIn_owner(t *testing.T) { Config: RoleDefinitionDataSource{}.builtIn("Owner"), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).Key("id").HasValue("/providers/Microsoft.Authorization/roleDefinitions/8e3af657-a8ff-443c-a75c-2fe8c4bcb635"), - check.That(data.ResourceName).Key("role_definition_id").IsUUID(), - check.That(data.ResourceName).Key("role_definition_id").IsUUID(), check.That(data.ResourceName).Key("description").Exists(), check.That(data.ResourceName).Key("type").Exists(), check.That(data.ResourceName).Key("permissions.#").HasValue("1"), @@ -119,7 +114,6 @@ func TestAccRoleDefinitionDataSource_builtIn_reader(t *testing.T) { Config: RoleDefinitionDataSource{}.builtIn("Reader"), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).Key("id").HasValue("/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7"), - check.That(data.ResourceName).Key("role_definition_id").IsUUID(), check.That(data.ResourceName).Key("description").Exists(), check.That(data.ResourceName).Key("type").Exists(), check.That(data.ResourceName).Key("permissions.#").HasValue("1"), @@ -139,7 +133,6 @@ func TestAccRoleDefinitionDataSource_builtIn_virtualMachineContributor(t *testin Config: RoleDefinitionDataSource{}.builtIn("Virtual Machine Contributor"), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).Key("id").HasValue("/providers/Microsoft.Authorization/roleDefinitions/9980e02c-c2be-4d73-94e8-173b1dc7cf3c"), - check.That(data.ResourceName).Key("role_definition_id").IsUUID(), check.That(data.ResourceName).Key("description").Exists(), check.That(data.ResourceName).Key("type").Exists(), check.That(data.ResourceName).Key("permissions.#").HasValue("1"),