Skip to content

Commit

Permalink
Reintroduce support for sharepoint client addon
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught committed Jun 28, 2023
1 parent ee8b434 commit 9272325
Show file tree
Hide file tree
Showing 9 changed files with 466 additions and 208 deletions.
10 changes: 10 additions & 0 deletions docs/data-sources/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Read-Only:
- `salesforce_sandbox_api` (List of Object) (see [below for nested schema](#nestedobjatt--addons--salesforce_sandbox_api))
- `sap_api` (List of Object) (see [below for nested schema](#nestedobjatt--addons--sap_api))
- `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))

<a id="nestedobjatt--addons--aws"></a>
Expand Down Expand Up @@ -258,6 +259,15 @@ Read-Only:
- `org_slug` (String)


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

Read-Only:

- `external_url` (List of String)
- `url` (String)


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

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 @@ -78,6 +78,7 @@ Read-Only:
- `salesforce_sandbox_api` (List of Object) (see [below for nested schema](#nestedobjatt--addons--salesforce_sandbox_api))
- `sap_api` (List of Object) (see [below for nested schema](#nestedobjatt--addons--sap_api))
- `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))

<a id="nestedobjatt--addons--aws"></a>
Expand Down Expand Up @@ -247,6 +248,15 @@ Read-Only:
- `org_slug` (String)


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

Read-Only:

- `external_url` (List of String)
- `url` (String)


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

Expand Down
10 changes: 10 additions & 0 deletions docs/resources/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ Optional:
- `salesforce_sandbox_api` (Block List, Max: 1) Salesforce Sandbox addon configuration. (see [below for nested schema](#nestedblock--addons--salesforce_sandbox_api))
- `sap_api` (Block List, Max: 1) SAP API addon configuration. (see [below for nested schema](#nestedblock--addons--sap_api))
- `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))

<a id="nestedblock--addons--aws"></a>
Expand Down Expand Up @@ -323,6 +324,15 @@ Optional:
- `org_slug` (String) Generated slug for your Sentry organization. Found in your Sentry URL, for example `https://sentry.acme.com/acme-org/` would be `acme-org`.


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

Optional:

- `external_url` (List of String) External SharePoint application URLs if exposed to the Internet.
- `url` (String) Internal SharePoint application URL.


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

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 @@ -94,6 +94,7 @@ Optional:
- `salesforce_sandbox_api` (Block List, Max: 1) Salesforce Sandbox addon configuration. (see [below for nested schema](#nestedblock--addons--salesforce_sandbox_api))
- `sap_api` (Block List, Max: 1) SAP API addon configuration. (see [below for nested schema](#nestedblock--addons--sap_api))
- `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))

<a id="nestedblock--addons--aws"></a>
Expand Down Expand Up @@ -266,6 +267,15 @@ Optional:
- `org_slug` (String) Generated slug for your Sentry organization. Found in your Sentry URL, for example `https://sentry.acme.com/acme-org/` would be `acme-org`.


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

Optional:

- `external_url` (List of String) External SharePoint application URLs if exposed to the Internet.
- `url` (String) Internal SharePoint application URL.


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

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 @@ -261,6 +261,7 @@ func expandClientAddons(d *schema.ResourceData) *management.ClientAddons {
addons.SalesforceSandboxAPI = expandClientAddonSalesforceSandboxAPI(addonsCfg.GetAttr("salesforce_sandbox_api"))
addons.Layer = expandClientAddonLayer(addonsCfg.GetAttr("layer"))
addons.SAPAPI = expandClientAddonSAPAPI(addonsCfg.GetAttr("sap_api"))
addons.SharePoint = expandClientAddonSharepoint(addonsCfg.GetAttr("sharepoint"))
return stop
})

Expand Down Expand Up @@ -564,6 +565,21 @@ func expandClientAddonSAPAPI(sapAPICfg cty.Value) *management.SAPAPIClientAddon
return &sapAPIAddon
}

func expandClientAddonSharepoint(sharepointCfg cty.Value) *management.SharePointClientAddon {
var sharepointAddon management.SharePointClientAddon

sharepointCfg.ForEachElement(func(_ cty.Value, sharepointCfg cty.Value) (stop bool) {
sharepointAddon = management.SharePointClientAddon{
URL: value.String(sharepointCfg.GetAttr("url")),
ExternalURL: value.Strings(sharepointCfg.GetAttr("external_url")),
}

return stop
})

return &sharepointAddon
}

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 @@ -111,6 +111,7 @@ func flattenClientAddons(addons *management.ClientAddons) []interface{} {
"salesforce_sandbox_api": nil,
"layer": nil,
"sap_api": nil,
"sharepoint": nil,
}

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

if addons.GetSharePoint() != nil {
m["sharepoint"] = []interface{}{
map[string]interface{}{
"url": addons.GetSharePoint().GetURL(),
"external_url": addons.GetSharePoint().GetExternalURL(),
},
}
}

return []interface{}{m}
}
24 changes: 24 additions & 0 deletions internal/auth0/client/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,30 @@ func NewResource() *schema.Resource {
},
},
},
"sharepoint": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: "SharePoint SSO configuration.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"url": {
Description: "Internal SharePoint application URL.",
Type: schema.TypeString,
Optional: true,
},
"external_url": {
Description: "External SharePoint application URLs if exposed to the Internet.",
Type: schema.TypeList,
Elem: &schema.Schema{
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 @@ -980,6 +980,20 @@ resource "auth0_client" "my_client" {
}
`

const testAccUpdateClientWithAddonsSharepoint = `
resource "auth0_client" "my_client" {
name = "Acceptance Test - SSO Integration - {{.testName}}"
app_type = "sso_integration"
addons {
sharepoint {
url = "https://example.com:123"
external_url = [ "https://example.com/v2" ]
}
}
}
`

func TestAccClientAddons(t *testing.T) {
acctest.Test(t, resource.TestCase{
Steps: []resource.TestStep{
Expand Down Expand Up @@ -1160,6 +1174,16 @@ func TestAccClientAddons(t *testing.T) {
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.sap_api.0.name_identifier_format", "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified"),
),
},
{
Config: acctest.ParseTestName(testAccUpdateClientWithAddonsSharepoint, 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.sharepoint.0.url", "https://example.com:123"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.sharepoint.0.external_url.0", "https://example.com/v2"),
),
},
},
})
}
Expand Down
Loading

0 comments on commit 9272325

Please sign in to comment.