Skip to content

Commit

Permalink
Reintroduce support for sso integration client addon
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught committed Jun 29, 2023
1 parent 4bd4346 commit 8ecb81c
Show file tree
Hide file tree
Showing 9 changed files with 533 additions and 278 deletions.
10 changes: 10 additions & 0 deletions docs/data-sources/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ Read-Only:
- `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))
- `sso_integration` (List of Object) (see [below for nested schema](#nestedobjatt--addons--sso_integration))
- `wams` (List of Object) (see [below for nested schema](#nestedobjatt--addons--wams))
- `zendesk` (List of Object) (see [below for nested schema](#nestedobjatt--addons--zendesk))
- `zoom` (List of Object) (see [below for nested schema](#nestedobjatt--addons--zoom))
Expand Down Expand Up @@ -288,6 +289,15 @@ Read-Only:
- `acs_url` (String)


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

Read-Only:

- `name` (String)
- `version` (String)


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

Expand Down
10 changes: 10 additions & 0 deletions docs/data-sources/global_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Read-Only:
- `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))
- `sso_integration` (List of Object) (see [below for nested schema](#nestedobjatt--addons--sso_integration))
- `wams` (List of Object) (see [below for nested schema](#nestedobjatt--addons--wams))
- `zendesk` (List of Object) (see [below for nested schema](#nestedobjatt--addons--zendesk))
- `zoom` (List of Object) (see [below for nested schema](#nestedobjatt--addons--zoom))
Expand Down Expand Up @@ -277,6 +278,15 @@ Read-Only:
- `acs_url` (String)


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

Read-Only:

- `name` (String)
- `version` (String)


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

Expand Down
10 changes: 10 additions & 0 deletions docs/resources/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ Optional:
- `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))
- `sso_integration` (Block List, Max: 1) Generic SSO configuration. (see [below for nested schema](#nestedblock--addons--sso_integration))
- `wams` (Block List, Max: 1) Windows Azure Mobile Services addon configuration. (see [below for nested schema](#nestedblock--addons--wams))
- `zendesk` (Block List, Max: 1) Zendesk SSO configuration. (see [below for nested schema](#nestedblock--addons--zendesk))
- `zoom` (Block List, Max: 1) Zoom SSO configuration. (see [below for nested schema](#nestedblock--addons--zoom))
Expand Down Expand Up @@ -353,6 +354,15 @@ Optional:
- `acs_url` (String) SpringCM ACS URL, for example `https://na11.springcm.com/atlas/sso/SSOEndpoint.ashx`.


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

Optional:

- `name` (String) SSO integration name.
- `version` (String) SSO integration version installed.


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

Expand Down
10 changes: 10 additions & 0 deletions docs/resources/global_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ Optional:
- `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))
- `sso_integration` (Block List, Max: 1) Generic SSO configuration. (see [below for nested schema](#nestedblock--addons--sso_integration))
- `wams` (Block List, Max: 1) Windows Azure Mobile Services addon configuration. (see [below for nested schema](#nestedblock--addons--wams))
- `zendesk` (Block List, Max: 1) Zendesk SSO configuration. (see [below for nested schema](#nestedblock--addons--zendesk))
- `zoom` (Block List, Max: 1) Zoom SSO configuration. (see [below for nested schema](#nestedblock--addons--zoom))
Expand Down Expand Up @@ -296,6 +297,15 @@ Optional:
- `acs_url` (String) SpringCM ACS URL, for example `https://na11.springcm.com/atlas/sso/SSOEndpoint.ashx`.


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

Optional:

- `name` (String) SSO integration name.
- `version` (String) SSO integration version installed.


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

Expand Down
16 changes: 16 additions & 0 deletions internal/auth0/client/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ func expandClientAddons(d *schema.ResourceData) *management.ClientAddons {
addons.WAMS = expandClientAddonWAMS(addonsCfg.GetAttr("wams"))
addons.Zendesk = expandClientAddonZendesk(addonsCfg.GetAttr("zendesk"))
addons.Zoom = expandClientAddonZoom(addonsCfg.GetAttr("zoom"))
addons.SSOIntegration = expandClientAddonSSOIntegration(addonsCfg.GetAttr("sso_integration"))
return stop
})

Expand Down Expand Up @@ -640,6 +641,21 @@ func expandClientAddonZoom(zoomCfg cty.Value) *management.ZoomClientAddon {
return &zoomAddon
}

func expandClientAddonSSOIntegration(ssoCfg cty.Value) *management.SSOIntegrationClientAddon {
var ssoAddon management.SSOIntegrationClientAddon

ssoCfg.ForEachElement(func(_ cty.Value, ssoCfg cty.Value) (stop bool) {
ssoAddon = management.SSOIntegrationClientAddon{
Name: value.String(ssoCfg.GetAttr("name")),
Version: value.String(ssoCfg.GetAttr("version")),
}

return stop
})

return &ssoAddon
}

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

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

if addons.GetSSOIntegration() != nil {
m["sso_integration"] = []interface{}{
map[string]interface{}{
"name": addons.GetSSOIntegration().GetName(),
"version": addons.GetSSOIntegration().GetVersion(),
},
}
}

return []interface{}{m}
}
21 changes: 21 additions & 0 deletions internal/auth0/client/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,27 @@ func NewResource() *schema.Resource {
},
},
},
"sso_integration": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: "Generic SSO configuration.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Description: "SSO integration name.",
Type: schema.TypeString,
Optional: true,
},
"version": {
Description: "SSO integration version installed.",
Type: schema.TypeString,
Optional: true,
},
},
},
},
},
},
},
Expand Down
24 changes: 24 additions & 0 deletions internal/auth0/client/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,20 @@ resource "auth0_client" "my_client" {
}
`

const testAccUpdateClientWithAddonsSSOIntegration = `
resource "auth0_client" "my_client" {
name = "Acceptance Test - SSO Integration - {{.testName}}"
app_type = "sso_integration"
addons {
sso_integration {
name = "my-sso"
version = "0.1.0"
}
}
}
`

func TestAccClientAddons(t *testing.T) {
acctest.Test(t, resource.TestCase{
Steps: []resource.TestStep{
Expand Down Expand Up @@ -1272,6 +1286,16 @@ func TestAccClientAddons(t *testing.T) {
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.zoom.0.account", "acmeorg"),
),
},
{
Config: acctest.ParseTestName(testAccUpdateClientWithAddonsSSOIntegration, 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.sso_integration.0.name", "my-sso"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.sso_integration.0.version", "0.1.0"),
),
},
},
})
}
Expand Down
Loading

0 comments on commit 8ecb81c

Please sign in to comment.