Skip to content

Commit

Permalink
Force replace when changing display_name of `databricks_service_pri…
Browse files Browse the repository at this point in the history
…ncipal` (databricks#1783)
  • Loading branch information
nkvuong committed Nov 21, 2022
1 parent 59e5883 commit fb0583f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 16 deletions.
2 changes: 1 addition & 1 deletion scim/resource_service_principal.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (a ServicePrincipalsAPI) Delete(servicePrincipalID string) error {
func ResourceServicePrincipal() *schema.Resource {
type entity struct {
ApplicationID string `json:"application_id,omitempty" tf:"computed,force_new"`
DisplayName string `json:"display_name,omitempty" tf:"computed"`
DisplayName string `json:"display_name,omitempty" tf:"computed,force_new"`
Active bool `json:"active,omitempty"`
ExternalID string `json:"external_id,omitempty" tf:"suppress_diff"`
}
Expand Down
50 changes: 35 additions & 15 deletions scim/resource_service_principal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func TestResourceServicePrincipalUpdateOnAWS(t *testing.T) {
// application ID is not allowed to be modified by client side on AWS

Schemas: []URN{ServicePrincipalSchema},
DisplayName: "Changed Name",
DisplayName: "Example Service Principal",
Active: true,
Entitlements: entitlements{
{
Expand All @@ -249,7 +249,7 @@ func TestResourceServicePrincipalUpdateOnAWS(t *testing.T) {
Response: User{
Schemas: []URN{ServicePrincipalSchema},
ApplicationID: "existing-application-id",
DisplayName: "Changed Name",
DisplayName: "Example Service Principal",
Active: true,
Entitlements: entitlements{
{
Expand All @@ -270,15 +270,18 @@ func TestResourceServicePrincipalUpdateOnAWS(t *testing.T) {
},
},
Resource: ResourceServicePrincipal(),
Update: true,
ID: "abc",
InstanceState: map[string]string{
"display_name": "Example Service Principal",
},
Update: true,
ID: "abc",
HCL: `
display_name = "Changed Name"
display_name = "Example Service Principal"
allow_cluster_create = false
allow_instance_pool_create = true
`,
}.ApplyAndExpectData(t, map[string]any{
"display_name": "Changed Name",
"display_name": "Example Service Principal",
"allow_cluster_create": false,
"allow_instance_pool_create": true,
})
Expand Down Expand Up @@ -309,8 +312,13 @@ func TestResourceServicePrincipalUpdateOnAzure(t *testing.T) {
ApplicationID: "existing-application-id",

Schemas: []URN{ServicePrincipalSchema},
DisplayName: "Changed Name",
Active: true,
DisplayName: "Example Service Principal",
Entitlements: entitlements{
{
Value: "allow-cluster-create",
},
},
Active: true,
},
},
{
Expand All @@ -319,8 +327,13 @@ func TestResourceServicePrincipalUpdateOnAzure(t *testing.T) {
Response: User{
Schemas: []URN{ServicePrincipalSchema},
ApplicationID: "existing-application-id",
DisplayName: "Changed Name",
Active: true,
DisplayName: "Example Service Principal",
Entitlements: entitlements{
{
Value: "allow-cluster-create",
},
},
Active: true,
},
},
},
Expand All @@ -333,7 +346,8 @@ func TestResourceServicePrincipalUpdateOnAzure(t *testing.T) {
},
HCL: `
application_id = "existing-application-id"
display_name = "Changed Name"
display_name = "Example Service Principal"
allow_cluster_create = true
`,
}.ApplyNoError(t)
}
Expand All @@ -342,8 +356,11 @@ func TestResourceServicePrincipalUpdate_Error(t *testing.T) {
qa.ResourceFixture{
Fixtures: qa.HTTPFailures,
Resource: ResourceServicePrincipal(),
Update: true,
ID: "abc",
InstanceState: map[string]string{
"display_name": "Changed Name",
},
Update: true,
ID: "abc",
HCL: `
display_name = "Changed Name"
allow_cluster_create = false
Expand Down Expand Up @@ -372,8 +389,11 @@ func TestResourceServicePrincipalUpdate_ErrorPut(t *testing.T) {
qa.HTTPFailures[0],
},
Resource: ResourceServicePrincipal(),
Update: true,
ID: "abc",
InstanceState: map[string]string{
"display_name": "Changed Name",
},
Update: true,
ID: "abc",
HCL: `
display_name = "Changed Name"
allow_cluster_create = false
Expand Down

0 comments on commit fb0583f

Please sign in to comment.