Skip to content

Commit

Permalink
Reintroduce support for slack client addon
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught committed Jun 28, 2023
1 parent 3bed43e commit d2b075b
Show file tree
Hide file tree
Showing 9 changed files with 305 additions and 58 deletions.
9 changes: 9 additions & 0 deletions docs/data-sources/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Read-Only:
- `azure_sb` (List of Object) (see [below for nested schema](#nestedobjatt--addons--azure_sb))
- `mscrm` (List of Object) (see [below for nested schema](#nestedobjatt--addons--mscrm))
- `rms` (List of Object) (see [below for nested schema](#nestedobjatt--addons--rms))
- `slack` (List of Object) (see [below for nested schema](#nestedobjatt--addons--slack))

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


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

Read-Only:

- `team` (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 @@ -67,6 +67,7 @@ Read-Only:
- `azure_sb` (List of Object) (see [below for nested schema](#nestedobjatt--addons--azure_sb))
- `mscrm` (List of Object) (see [below for nested schema](#nestedobjatt--addons--mscrm))
- `rms` (List of Object) (see [below for nested schema](#nestedobjatt--addons--rms))
- `slack` (List of Object) (see [below for nested schema](#nestedobjatt--addons--slack))

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


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

Read-Only:

- `team` (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 @@ -140,6 +140,7 @@ Optional:
- `azure_sb` (Block List, Max: 1) Azure Storage Bus Addon configuration. (see [below for nested schema](#nestedblock--addons--azure_sb))
- `mscrm` (Block List, Max: 1) Microsoft Dynamics CRM SSO configuration. (see [below for nested schema](#nestedblock--addons--mscrm))
- `rms` (Block List, Max: 1) Active Directory Rights Management Service SSO configuration. (see [below for nested schema](#nestedblock--addons--rms))
- `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>
### Nested Schema for `addons.aws`
Expand Down Expand Up @@ -199,6 +200,14 @@ Optional:
- `url` (String) URL of your Rights Management Server. It can be internal or external, but users will have to be able to reach it.


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

Optional:

- `team` (String) Slack team name.



<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 @@ -83,6 +83,7 @@ Optional:
- `azure_sb` (Block List, Max: 1) Azure Storage Bus Addon configuration. (see [below for nested schema](#nestedblock--addons--azure_sb))
- `mscrm` (Block List, Max: 1) Microsoft Dynamics CRM SSO configuration. (see [below for nested schema](#nestedblock--addons--mscrm))
- `rms` (Block List, Max: 1) Active Directory Rights Management Service SSO configuration. (see [below for nested schema](#nestedblock--addons--rms))
- `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>
### Nested Schema for `addons.aws`
Expand Down Expand Up @@ -142,6 +143,14 @@ Optional:
- `url` (String) URL of your Rights Management Server. It can be internal or external, but users will have to be able to reach it.


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

Optional:

- `team` (String) Slack team name.



<a id="nestedblock--jwt_configuration"></a>
### Nested Schema for `jwt_configuration`
Expand Down
19 changes: 19 additions & 0 deletions internal/auth0/client/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ func expandClientAddons(d *schema.ResourceData) *management.ClientAddons {
addons.AzureSB = expandClientAddonAzureSB(addonsCfg.GetAttr("azure_sb"))
addons.RMS = expandClientAddonRMS(addonsCfg.GetAttr("rms"))
addons.MSCRM = expandClientAddonMSCRM(addonsCfg.GetAttr("mscrm"))
addons.Slack = expandClientAddonSlack(addonsCfg.GetAttr("slack"))
return stop
})

Expand Down Expand Up @@ -355,6 +356,24 @@ func expandClientAddonMSCRM(mscrmCfg cty.Value) *management.MSCRMClientAddon {
return &mscrmAddon
}

func expandClientAddonSlack(slackCfg cty.Value) *management.SlackClientAddon {
var slackAddon management.SlackClientAddon

slackCfg.ForEachElement(func(_ cty.Value, slackCfg cty.Value) (stop bool) {
slackAddon = management.SlackClientAddon{
Team: value.String(slackCfg.GetAttr("team")),
}

return stop
})

if slackAddon == (management.SlackClientAddon{}) {
return nil
}

return &slackAddon
}

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 @@ -100,6 +100,7 @@ func flattenClientAddons(addons *management.ClientAddons) []interface{} {
"azure_sb": nil,
"rms": nil,
"mscrm": nil,
"slack": nil,
}

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

if addons.GetSlack() != nil {
m["slack"] = []interface{}{
map[string]interface{}{
"team": addons.GetSlack().GetTeam(),
},
}
}

return []interface{}{m}
}
17 changes: 17 additions & 0 deletions internal/auth0/client/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,23 @@ func NewResource() *schema.Resource {
},
},
},
"slack": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: "Slack team or workspace name usually first segment in your Slack URL, " +
"for example `https://acme-org.slack.com` would be `acme-org`.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"team": {
Description: "Slack team name.",
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 @@ -821,6 +821,19 @@ resource "auth0_client" "my_client" {
}
`

const testAccUpdateClientWithAddonsSlack = `
resource "auth0_client" "my_client" {
name = "Acceptance Test - SSO Integration - {{.testName}}"
app_type = "sso_integration"
addons {
slack {
team = "acmeorg"
}
}
}
`

func TestAccClientAddons(t *testing.T) {
acctest.Test(t, resource.TestCase{
Steps: []resource.TestStep{
Expand Down Expand Up @@ -887,6 +900,15 @@ func TestAccClientAddons(t *testing.T) {
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.mscrm.0.url", "https://example.com"),
),
},
{
Config: acctest.ParseTestName(testAccUpdateClientWithAddonsSlack, 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.slack.0.team", "acmeorg"),
),
},
},
})
}
Expand Down
Loading

0 comments on commit d2b075b

Please sign in to comment.