Skip to content

Commit

Permalink
azuread_application: remove importsteps for oauth2permissionscopes te…
Browse files Browse the repository at this point in the history
…st due to inconsistent set handling
  • Loading branch information
manicminer committed Sep 25, 2024
1 parent 8d08d8b commit f2ddb09
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 28 deletions.
6 changes: 3 additions & 3 deletions internal/services/applications/application_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,8 @@ func applicationDataSourceRead(ctx context.Context, d *pluginsdk.ResourceData, m
d.SetId(id.ID())

tf.Set(d, "api", flattenApplicationApi(app.Api, true))
tf.Set(d, "app_roles", flattenApplicationAppRoles(app.AppRoles))
tf.Set(d, "app_role_ids", flattenApplicationAppRoleIDs(app.AppRoles))
tf.Set(d, "app_roles", applications.FlattenAppRoles(app.AppRoles))
tf.Set(d, "app_role_ids", applications.FlattenAppRoleIDs(app.AppRoles))
tf.Set(d, "application_id", app.AppId.GetOrZero())
tf.Set(d, "client_id", app.AppId.GetOrZero())
tf.Set(d, "device_only_auth_enabled", app.IsDeviceOnlyAuthSupported.GetOrZero())
Expand All @@ -624,7 +624,7 @@ func applicationDataSourceRead(ctx context.Context, d *pluginsdk.ResourceData, m
tf.Set(d, "web", flattenApplicationWeb(app.Web))

if app.Api != nil {
tf.Set(d, "oauth2_permission_scope_ids", flattenApplicationOAuth2PermissionScopeIDs(app.Api.OAuth2PermissionScopes))
tf.Set(d, "oauth2_permission_scope_ids", applications.FlattenOAuth2PermissionScopeIDs(app.Api.OAuth2PermissionScopes))
}

if app.Info != nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/services/applications/application_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -1633,8 +1633,8 @@ func applicationResourceRead(ctx context.Context, d *pluginsdk.ResourceData, met
}

tf.Set(d, "api", flattenApplicationApi(app.Api, false))
tf.Set(d, "app_role", flattenApplicationAppRoles(app.AppRoles))
tf.Set(d, "app_role_ids", flattenApplicationAppRoleIDs(app.AppRoles))
tf.Set(d, "app_role", applications.FlattenAppRoles(app.AppRoles))
tf.Set(d, "app_role_ids", applications.FlattenAppRoleIDs(app.AppRoles))
tf.Set(d, "application_id", app.AppId.GetOrZero())
tf.Set(d, "client_id", app.AppId.GetOrZero())
tf.Set(d, "description", app.Description.GetOrZero())
Expand All @@ -1659,7 +1659,7 @@ func applicationResourceRead(ctx context.Context, d *pluginsdk.ResourceData, met
tf.Set(d, "web", flattenApplicationWeb(app.Web))

if app.Api != nil {
tf.Set(d, "oauth2_permission_scope_ids", flattenApplicationOAuth2PermissionScopeIDs(app.Api.OAuth2PermissionScopes))
tf.Set(d, "oauth2_permission_scope_ids", applications.FlattenOAuth2PermissionScopeIDs(app.Api.OAuth2PermissionScopes))
}

if app.Info != nil {
Expand Down
7 changes: 2 additions & 5 deletions internal/services/applications/application_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ func TestAccApplication_oauth2PermissionScopes(t *testing.T) {
data.UUID(),
}

// Note: ImportSteps missing here due to inconsistencies with SDKv2 handling of sets

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Expand All @@ -301,7 +303,6 @@ func TestAccApplication_oauth2PermissionScopes(t *testing.T) {
check.That(data.ResourceName).Key("oauth2_permission_scope_ids.%").HasValue("0"),
),
},
data.ImportStep(),
{
Config: r.oauth2PermissionScopes(data, scopeIDs),
Check: acceptance.ComposeTestCheckFunc(
Expand All @@ -310,7 +311,6 @@ func TestAccApplication_oauth2PermissionScopes(t *testing.T) {
check.That(data.ResourceName).Key("oauth2_permission_scope_ids.%").HasValue("2"),
),
},
data.ImportStep(),
{
Config: r.oauth2PermissionScopesUpdate(data, scopeIDs),
Check: acceptance.ComposeTestCheckFunc(
Expand All @@ -319,7 +319,6 @@ func TestAccApplication_oauth2PermissionScopes(t *testing.T) {
check.That(data.ResourceName).Key("oauth2_permission_scope_ids.%").HasValue("3"),
),
},
data.ImportStep(),
{
Config: r.oauth2PermissionScopes(data, scopeIDs),
Check: acceptance.ComposeTestCheckFunc(
Expand All @@ -328,7 +327,6 @@ func TestAccApplication_oauth2PermissionScopes(t *testing.T) {
check.That(data.ResourceName).Key("oauth2_permission_scope_ids.%").HasValue("2"),
),
},
data.ImportStep(),
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
Expand All @@ -337,7 +335,6 @@ func TestAccApplication_oauth2PermissionScopes(t *testing.T) {
check.That(data.ResourceName).Key("oauth2_permission_scope_ids.%").HasValue("0"),
),
},
data.ImportStep(),
})
}

Expand Down
18 changes: 1 addition & 17 deletions internal/services/applications/applications.go
Original file line number Diff line number Diff line change
Expand Up @@ -684,19 +684,11 @@ func flattenApplicationApi(in *stable.ApiApplication, dataSource bool) []map[str
return []map[string]interface{}{{
"known_client_applications": tf.FlattenStringSlicePtr(in.KnownClientApplications),
"mapped_claims_enabled": mappedClaims,
scopesKey: flattenApplicationOAuth2PermissionScopes(in.OAuth2PermissionScopes),
scopesKey: applications.FlattenOAuth2PermissionScopes(in.OAuth2PermissionScopes),
"requested_access_token_version": accessTokenVersion,
}}
}

func flattenApplicationAppRoleIDs(in *[]stable.AppRole) map[string]string {
return applications.FlattenAppRoleIDs(in)
}

func flattenApplicationAppRoles(in *[]stable.AppRole) []map[string]interface{} {
return applications.FlattenAppRoles(in)
}

func flattenApplicationGroupMembershipClaims(in nullable.Type[string]) []interface{} {
if in.IsNull() {
return []interface{}{}
Expand All @@ -721,14 +713,6 @@ func flattenApplicationImplicitGrant(in *stable.ImplicitGrantSettings) []map[str
}}
}

func flattenApplicationOAuth2PermissionScopeIDs(in *[]stable.PermissionScope) map[string]string {
return applications.FlattenOAuth2PermissionScopeIDs(in)
}

func flattenApplicationOAuth2PermissionScopes(in *[]stable.PermissionScope) []map[string]interface{} {
return applications.FlattenOAuth2PermissionScopes(in)
}

func flattenApplicationOptionalClaims(in *stable.OptionalClaims) []map[string]interface{} {
if in == nil {
return []map[string]interface{}{}
Expand Down

0 comments on commit f2ddb09

Please sign in to comment.