Skip to content

Commit

Permalink
Reintroduce support for office365 client addon
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught committed Jun 28, 2023
1 parent 47dd453 commit a700043
Show file tree
Hide file tree
Showing 9 changed files with 408 additions and 152 deletions.
10 changes: 10 additions & 0 deletions docs/data-sources/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Read-Only:
- `firebase` (List of Object) (see [below for nested schema](#nestedobjatt--addons--firebase))
- `mscrm` (List of Object) (see [below for nested schema](#nestedobjatt--addons--mscrm))
- `newrelic` (List of Object) (see [below for nested schema](#nestedobjatt--addons--newrelic))
- `office365` (List of Object) (see [below for nested schema](#nestedobjatt--addons--office365))
- `rms` (List of Object) (see [below for nested schema](#nestedobjatt--addons--rms))
- `sentry` (List of Object) (see [below for nested schema](#nestedobjatt--addons--sentry))
- `slack` (List of Object) (see [below for nested schema](#nestedobjatt--addons--slack))
Expand Down Expand Up @@ -171,6 +172,15 @@ Read-Only:
- `account` (String)


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

Read-Only:

- `connection` (String)
- `domain` (String)


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

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 @@ -70,6 +70,7 @@ Read-Only:
- `firebase` (List of Object) (see [below for nested schema](#nestedobjatt--addons--firebase))
- `mscrm` (List of Object) (see [below for nested schema](#nestedobjatt--addons--mscrm))
- `newrelic` (List of Object) (see [below for nested schema](#nestedobjatt--addons--newrelic))
- `office365` (List of Object) (see [below for nested schema](#nestedobjatt--addons--office365))
- `rms` (List of Object) (see [below for nested schema](#nestedobjatt--addons--rms))
- `sentry` (List of Object) (see [below for nested schema](#nestedobjatt--addons--sentry))
- `slack` (List of Object) (see [below for nested schema](#nestedobjatt--addons--slack))
Expand Down Expand Up @@ -160,6 +161,15 @@ Read-Only:
- `account` (String)


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

Read-Only:

- `connection` (String)
- `domain` (String)


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

Expand Down
10 changes: 10 additions & 0 deletions docs/resources/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ Optional:
- `firebase` (Block List, Max: 1) Google Firebase addon configuration. (see [below for nested schema](#nestedblock--addons--firebase))
- `mscrm` (Block List, Max: 1) Microsoft Dynamics CRM SSO configuration. (see [below for nested schema](#nestedblock--addons--mscrm))
- `newrelic` (Block List, Max: 1) New Relic SSO configuration. (see [below for nested schema](#nestedblock--addons--newrelic))
- `office365` (Block List, Max: 1) Microsoft Office 365 SSO configuration. (see [below for nested schema](#nestedblock--addons--office365))
- `rms` (Block List, Max: 1) Active Directory Rights Management Service SSO configuration. (see [below for nested schema](#nestedblock--addons--rms))
- `sentry` (Block List, Max: 1) Sentry SSO configuration. (see [below for nested schema](#nestedblock--addons--sentry))
- `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))
Expand Down Expand Up @@ -233,6 +234,15 @@ Optional:
- `account` (String) Your New Relic Account ID found in your New Relic URL after the `/accounts/` path, for example `https://rpm.newrelic.com/accounts/123456/query` would be `123456`.


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

Optional:

- `connection` (String) Optional Auth0 database connection for testing an already-configured Office 365 tenant.
- `domain` (String) Your Office 365 domain name. e.g. `acme-org.com`.


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

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 @@ -86,6 +86,7 @@ Optional:
- `firebase` (Block List, Max: 1) Google Firebase addon configuration. (see [below for nested schema](#nestedblock--addons--firebase))
- `mscrm` (Block List, Max: 1) Microsoft Dynamics CRM SSO configuration. (see [below for nested schema](#nestedblock--addons--mscrm))
- `newrelic` (Block List, Max: 1) New Relic SSO configuration. (see [below for nested schema](#nestedblock--addons--newrelic))
- `office365` (Block List, Max: 1) Microsoft Office 365 SSO configuration. (see [below for nested schema](#nestedblock--addons--office365))
- `rms` (Block List, Max: 1) Active Directory Rights Management Service SSO configuration. (see [below for nested schema](#nestedblock--addons--rms))
- `sentry` (Block List, Max: 1) Sentry SSO configuration. (see [below for nested schema](#nestedblock--addons--sentry))
- `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))
Expand Down Expand Up @@ -176,6 +177,15 @@ Optional:
- `account` (String) Your New Relic Account ID found in your New Relic URL after the `/accounts/` path, for example `https://rpm.newrelic.com/accounts/123456/query` would be `123456`.


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

Optional:

- `connection` (String) Optional Auth0 database connection for testing an already-configured Office 365 tenant.
- `domain` (String) Your Office 365 domain name. e.g. `acme-org.com`.


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

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 @@ -255,6 +255,7 @@ func expandClientAddons(d *schema.ResourceData) *management.ClientAddons {
addons.Egnyte = expandClientAddonEgnyte(addonsCfg.GetAttr("egnyte"))
addons.Firebase = expandClientAddonFirebase(addonsCfg.GetAttr("firebase"))
addons.NewRelic = expandClientAddonNewRelic(addonsCfg.GetAttr("newrelic"))
addons.Office365 = expandClientAddonOffice365(addonsCfg.GetAttr("office365"))
return stop
})

Expand Down Expand Up @@ -454,6 +455,21 @@ func expandClientAddonNewRelic(newRelicCfg cty.Value) *management.NewRelicClient
return &newRelicAddon
}

func expandClientAddonOffice365(office365Cfg cty.Value) *management.Office365ClientAddon {
var office365Addon management.Office365ClientAddon

office365Cfg.ForEachElement(func(_ cty.Value, office365Cfg cty.Value) (stop bool) {
office365Addon = management.Office365ClientAddon{
Domain: value.String(office365Cfg.GetAttr("domain")),
Connection: value.String(office365Cfg.GetAttr("connection")),
}

return stop
})

return &office365Addon
}

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 @@ -105,6 +105,7 @@ func flattenClientAddons(addons *management.ClientAddons) []interface{} {
"echosign": nil,
"egnyte": nil,
"firebase": nil,
"office365": nil,
}

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

if addons.GetOffice365() != nil {
m["office365"] = []interface{}{
map[string]interface{}{
"domain": addons.GetOffice365().GetDomain(),
"connection": addons.GetOffice365().GetConnection(),
},
}
}

return []interface{}{m}
}
22 changes: 22 additions & 0 deletions internal/auth0/client/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,28 @@ func NewResource() *schema.Resource {
},
},
},
"office365": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: "Microsoft Office 365 SSO configuration.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"domain": {
Description: "Your Office 365 domain name. e.g. `acme-org.com`.",
Type: schema.TypeString,
Optional: true,
},
"connection": {
Description: "Optional Auth0 database connection for testing an " +
"already-configured Office 365 tenant.",
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 @@ -904,6 +904,20 @@ resource "auth0_client" "my_client" {
}
`

const testAccUpdateClientWithAddonsOffice365 = `
resource "auth0_client" "my_client" {
name = "Acceptance Test - SSO Integration - {{.testName}}"
app_type = "sso_integration"
addons {
office365 {
domain = "acmeorg"
connection = "Username-Password-Authentication"
}
}
}
`

func TestAccClientAddons(t *testing.T) {
acctest.Test(t, resource.TestCase{
Steps: []resource.TestStep{
Expand Down Expand Up @@ -1029,6 +1043,16 @@ func TestAccClientAddons(t *testing.T) {
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.newrelic.0.account", "123456"),
),
},
{
Config: acctest.ParseTestName(testAccUpdateClientWithAddonsOffice365, 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.office365.0.domain", "acmeorg"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.office365.0.connection", "Username-Password-Authentication"),
),
},
},
})
}
Expand Down
Loading

0 comments on commit a700043

Please sign in to comment.