Skip to content

Commit

Permalink
[17/X] DXCDT-441: Reintroduce support for springcm client addon (#673)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught authored Jun 29, 2023
1 parent c5136d9 commit 3a46223
Show file tree
Hide file tree
Showing 9 changed files with 464 additions and 222 deletions.
9 changes: 9 additions & 0 deletions docs/data-sources/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Read-Only:
- `sentry` (List of Object) (see [below for nested schema](#nestedobjatt--addons--sentry))
- `sharepoint` (List of Object) (see [below for nested schema](#nestedobjatt--addons--sharepoint))
- `slack` (List of Object) (see [below for nested schema](#nestedobjatt--addons--slack))
- `springcm` (List of Object) (see [below for nested schema](#nestedobjatt--addons--springcm))

<a id="nestedobjatt--addons--aws"></a>
### Nested Schema for `addons.aws`
Expand Down Expand Up @@ -276,6 +277,14 @@ Read-Only:
- `team` (String)


<a id="nestedobjatt--addons--springcm"></a>
### Nested Schema for `addons.springcm`

Read-Only:

- `acs_url` (String)



<a id="nestedatt--jwt_configuration"></a>
### Nested Schema for `jwt_configuration`
Expand Down
9 changes: 9 additions & 0 deletions docs/data-sources/global_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Read-Only:
- `sentry` (List of Object) (see [below for nested schema](#nestedobjatt--addons--sentry))
- `sharepoint` (List of Object) (see [below for nested schema](#nestedobjatt--addons--sharepoint))
- `slack` (List of Object) (see [below for nested schema](#nestedobjatt--addons--slack))
- `springcm` (List of Object) (see [below for nested schema](#nestedobjatt--addons--springcm))

<a id="nestedobjatt--addons--aws"></a>
### Nested Schema for `addons.aws`
Expand Down Expand Up @@ -265,6 +266,14 @@ Read-Only:
- `team` (String)


<a id="nestedobjatt--addons--springcm"></a>
### Nested Schema for `addons.springcm`

Read-Only:

- `acs_url` (String)



<a id="nestedatt--jwt_configuration"></a>
### Nested Schema for `jwt_configuration`
Expand Down
9 changes: 9 additions & 0 deletions docs/resources/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ Optional:
- `sentry` (Block List, Max: 1) Sentry SSO configuration. (see [below for nested schema](#nestedblock--addons--sentry))
- `sharepoint` (Block List, Max: 1) SharePoint SSO configuration. (see [below for nested schema](#nestedblock--addons--sharepoint))
- `slack` (Block List, Max: 1) Slack team or workspace name usually first segment in your Slack URL, for example `https://acme-org.slack.com` would be `acme-org`. (see [below for nested schema](#nestedblock--addons--slack))
- `springcm` (Block List, Max: 1) SpringCM SSO configuration. (see [below for nested schema](#nestedblock--addons--springcm))

<a id="nestedblock--addons--aws"></a>
### Nested Schema for `addons.aws`
Expand Down Expand Up @@ -341,6 +342,14 @@ Optional:
- `team` (String) Slack team name.


<a id="nestedblock--addons--springcm"></a>
### Nested Schema for `addons.springcm`

Optional:

- `acs_url` (String) SpringCM ACS URL, for example `https://na11.springcm.com/atlas/sso/SSOEndpoint.ashx`.



<a id="nestedblock--jwt_configuration"></a>
### Nested Schema for `jwt_configuration`
Expand Down
9 changes: 9 additions & 0 deletions docs/resources/global_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Optional:
- `sentry` (Block List, Max: 1) Sentry SSO configuration. (see [below for nested schema](#nestedblock--addons--sentry))
- `sharepoint` (Block List, Max: 1) SharePoint SSO configuration. (see [below for nested schema](#nestedblock--addons--sharepoint))
- `slack` (Block List, Max: 1) Slack team or workspace name usually first segment in your Slack URL, for example `https://acme-org.slack.com` would be `acme-org`. (see [below for nested schema](#nestedblock--addons--slack))
- `springcm` (Block List, Max: 1) SpringCM SSO configuration. (see [below for nested schema](#nestedblock--addons--springcm))

<a id="nestedblock--addons--aws"></a>
### Nested Schema for `addons.aws`
Expand Down Expand Up @@ -284,6 +285,14 @@ Optional:
- `team` (String) Slack team name.


<a id="nestedblock--addons--springcm"></a>
### Nested Schema for `addons.springcm`

Optional:

- `acs_url` (String) SpringCM ACS URL, for example `https://na11.springcm.com/atlas/sso/SSOEndpoint.ashx`.



<a id="nestedblock--jwt_configuration"></a>
### Nested Schema for `jwt_configuration`
Expand Down
15 changes: 15 additions & 0 deletions internal/auth0/client/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ func expandClientAddons(d *schema.ResourceData) *management.ClientAddons {
addons.Layer = expandClientAddonLayer(addonsCfg.GetAttr("layer"))
addons.SAPAPI = expandClientAddonSAPAPI(addonsCfg.GetAttr("sap_api"))
addons.SharePoint = expandClientAddonSharepoint(addonsCfg.GetAttr("sharepoint"))
addons.SpringCM = expandClientAddonSpringCM(addonsCfg.GetAttr("springcm"))
return stop
})

Expand Down Expand Up @@ -580,6 +581,20 @@ func expandClientAddonSharepoint(sharepointCfg cty.Value) *management.SharePoint
return &sharepointAddon
}

func expandClientAddonSpringCM(springCMCfg cty.Value) *management.SpringCMClientAddon {
var springCMAddon management.SpringCMClientAddon

springCMCfg.ForEachElement(func(_ cty.Value, springCMCfg cty.Value) (stop bool) {
springCMAddon = management.SpringCMClientAddon{
ACSURL: value.String(springCMCfg.GetAttr("acs_url")),
}

return stop
})

return &springCMAddon
}

func clientHasChange(c *management.Client) bool {
return c.String() != "{}"
}
9 changes: 9 additions & 0 deletions internal/auth0/client/flatten.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func flattenClientAddons(addons *management.ClientAddons) []interface{} {
"layer": nil,
"sap_api": nil,
"sharepoint": nil,
"springcm": nil,
}

if addons.GetAWS() != nil {
Expand Down Expand Up @@ -298,5 +299,13 @@ func flattenClientAddons(addons *management.ClientAddons) []interface{} {
}
}

if addons.GetSpringCM() != nil {
m["springcm"] = []interface{}{
map[string]interface{}{
"acs_url": addons.GetSpringCM().GetACSURL(),
},
}
}

return []interface{}{m}
}
16 changes: 16 additions & 0 deletions internal/auth0/client/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,22 @@ func NewResource() *schema.Resource {
},
},
},
"springcm": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: "SpringCM SSO configuration.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"acs_url": {
Description: "SpringCM ACS URL, for example `https://na11.springcm.com/atlas/sso/SSOEndpoint.ashx`.",
Type: schema.TypeString,
Optional: true,
},
},
},
},
},
},
},
Expand Down
22 changes: 22 additions & 0 deletions internal/auth0/client/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,19 @@ resource "auth0_client" "my_client" {
}
`

const testAccUpdateClientWithAddonsSpringCM = `
resource "auth0_client" "my_client" {
name = "Acceptance Test - SSO Integration - {{.testName}}"
app_type = "sso_integration"
addons {
springcm {
acs_url = "https://example.com"
}
}
}
`

func TestAccClientAddons(t *testing.T) {
acctest.Test(t, resource.TestCase{
Steps: []resource.TestStep{
Expand Down Expand Up @@ -1184,6 +1197,15 @@ func TestAccClientAddons(t *testing.T) {
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.sharepoint.0.external_url.0", "https://example.com/v2"),
),
},
{
Config: acctest.ParseTestName(testAccUpdateClientWithAddonsSpringCM, t.Name()),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_client.my_client", "name", fmt.Sprintf("Acceptance Test - SSO Integration - %s", t.Name())),
resource.TestCheckResourceAttr("auth0_client.my_client", "app_type", "sso_integration"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.#", "1"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.springcm.0.acs_url", "https://example.com"),
),
},
},
})
}
Expand Down
Loading

0 comments on commit 3a46223

Please sign in to comment.