Skip to content

Commit

Permalink
Reintroduce support for layer client addon
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught committed Jun 28, 2023
1 parent 9386060 commit 316204c
Show file tree
Hide file tree
Showing 9 changed files with 463 additions and 154 deletions.
13 changes: 13 additions & 0 deletions docs/data-sources/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Read-Only:
- `echosign` (List of Object) (see [below for nested schema](#nestedobjatt--addons--echosign))
- `egnyte` (List of Object) (see [below for nested schema](#nestedobjatt--addons--egnyte))
- `firebase` (List of Object) (see [below for nested schema](#nestedobjatt--addons--firebase))
- `layer` (List of Object) (see [below for nested schema](#nestedobjatt--addons--layer))
- `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))
Expand Down Expand Up @@ -159,6 +160,18 @@ Read-Only:
- `secret` (String)


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

Read-Only:

- `expiration` (Number)
- `key_id` (String)
- `principal` (String)
- `private_key` (String)
- `provider_id` (String)


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

Expand Down
13 changes: 13 additions & 0 deletions docs/data-sources/global_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Read-Only:
- `echosign` (List of Object) (see [below for nested schema](#nestedobjatt--addons--echosign))
- `egnyte` (List of Object) (see [below for nested schema](#nestedobjatt--addons--egnyte))
- `firebase` (List of Object) (see [below for nested schema](#nestedobjatt--addons--firebase))
- `layer` (List of Object) (see [below for nested schema](#nestedobjatt--addons--layer))
- `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))
Expand Down Expand Up @@ -148,6 +149,18 @@ Read-Only:
- `secret` (String)


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

Read-Only:

- `expiration` (Number)
- `key_id` (String)
- `principal` (String)
- `private_key` (String)
- `provider_id` (String)


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

Expand Down
16 changes: 16 additions & 0 deletions docs/resources/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ Optional:
- `echosign` (Block List, Max: 1) Adobe EchoSign SSO configuration. (see [below for nested schema](#nestedblock--addons--echosign))
- `egnyte` (Block List, Max: 1) Egnyte SSO configuration. (see [below for nested schema](#nestedblock--addons--egnyte))
- `firebase` (Block List, Max: 1) Google Firebase addon configuration. (see [below for nested schema](#nestedblock--addons--firebase))
- `layer` (Block List, Max: 1) Salesforce Sandbox addon configuration. (see [below for nested schema](#nestedblock--addons--layer))
- `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))
Expand Down Expand Up @@ -221,6 +222,21 @@ Optional:
- `secret` (String, Sensitive) Google Firebase Secret. (SDK 2 only).


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

Required:

- `key_id` (String, Sensitive) Authentication Key identifier used to sign the Layer token.
- `private_key` (String, Sensitive) Private key for signing the Layer token.
- `provider_id` (String) Provider ID of your Layer account.

Optional:

- `expiration` (Number) Optional expiration in minutes for the generated token. Defaults to 5 minutes.
- `principal` (String) Name of the property used as the unique user id in Layer. If not specified `user_id` is used.


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

Expand Down
16 changes: 16 additions & 0 deletions docs/resources/global_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Optional:
- `echosign` (Block List, Max: 1) Adobe EchoSign SSO configuration. (see [below for nested schema](#nestedblock--addons--echosign))
- `egnyte` (Block List, Max: 1) Egnyte SSO configuration. (see [below for nested schema](#nestedblock--addons--egnyte))
- `firebase` (Block List, Max: 1) Google Firebase addon configuration. (see [below for nested schema](#nestedblock--addons--firebase))
- `layer` (Block List, Max: 1) Salesforce Sandbox addon configuration. (see [below for nested schema](#nestedblock--addons--layer))
- `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))
Expand Down Expand Up @@ -164,6 +165,21 @@ Optional:
- `secret` (String, Sensitive) Google Firebase Secret. (SDK 2 only).


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

Required:

- `key_id` (String, Sensitive) Authentication Key identifier used to sign the Layer token.
- `private_key` (String, Sensitive) Private key for signing the Layer token.
- `provider_id` (String) Provider ID of your Layer account.

Optional:

- `expiration` (Number) Optional expiration in minutes for the generated token. Defaults to 5 minutes.
- `principal` (String) Name of the property used as the unique user id in Layer. If not specified `user_id` is used.


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

Expand Down
23 changes: 23 additions & 0 deletions internal/auth0/client/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ func expandClientAddons(d *schema.ResourceData) *management.ClientAddons {
addons.Salesforce = expandClientAddonSalesforce(addonsCfg.GetAttr("salesforce"))
addons.SalesforceAPI = expandClientAddonSalesforceAPI(addonsCfg.GetAttr("salesforce_api"))
addons.SalesforceSandboxAPI = expandClientAddonSalesforceSandboxAPI(addonsCfg.GetAttr("salesforce_sandbox_api"))
addons.Layer = expandClientAddonLayer(addonsCfg.GetAttr("layer"))
return stop
})

Expand Down Expand Up @@ -521,6 +522,28 @@ func expandClientAddonSalesforceSandboxAPI(salesforceCfg cty.Value) *management.
return &salesforceAddon
}

func expandClientAddonLayer(layerCfg cty.Value) *management.LayerClientAddon {
var layerAddon management.LayerClientAddon

layerCfg.ForEachElement(func(_ cty.Value, layerCfg cty.Value) (stop bool) {
layerAddon = management.LayerClientAddon{
ProviderID: value.String(layerCfg.GetAttr("provider_id")),
KeyID: value.String(layerCfg.GetAttr("key_id")),
PrivateKey: value.String(layerCfg.GetAttr("private_key")),
Principal: value.String(layerCfg.GetAttr("principal")),
Expiration: value.Int(layerCfg.GetAttr("expiration")),
}

return stop
})

if layerAddon == (management.LayerClientAddon{}) {
return nil
}

return &layerAddon
}

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

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

if addons.GetLayer() != nil {
m["layer"] = []interface{}{
map[string]interface{}{
"provider_id": addons.GetLayer().GetProviderID(),
"key_id": addons.GetLayer().GetKeyID(),
"private_key": addons.GetLayer().GetPrivateKey(),
"principal": addons.GetLayer().GetPrincipal(),
"expiration": addons.GetLayer().GetExpiration(),
},
}
}

return []interface{}{m}
}
41 changes: 41 additions & 0 deletions internal/auth0/client/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,47 @@ func NewResource() *schema.Resource {
},
},
},
"layer": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: "Salesforce Sandbox addon configuration.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"provider_id": {
Description: "Provider ID of your Layer account.",
Type: schema.TypeString,
Required: true,
},
"key_id": {
Description: "Authentication Key identifier used to sign the Layer token.",
Type: schema.TypeString,
Required: true,
Sensitive: true,
},
"private_key": {
Description: "Private key for signing the Layer token.",
Type: schema.TypeString,
Required: true,
Sensitive: true,
},
"principal": {
Description: "Name of the property used as the unique user id in Layer. " +
"If not specified `user_id` is used.",
Type: schema.TypeString,
Optional: true,
},
"expiration": {
Description: "Optional expiration in minutes for the generated token. " +
"Defaults to 5 minutes.",
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validation.IntAtLeast(0),
},
},
},
},
},
},
},
Expand Down
30 changes: 30 additions & 0 deletions internal/auth0/client/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,23 @@ resource "auth0_client" "my_client" {
}
`

const testAccUpdateClientWithAddonsLayer = `
resource "auth0_client" "my_client" {
name = "Acceptance Test - SSO Integration - {{.testName}}"
app_type = "sso_integration"
addons {
layer {
provider_id = "provider-id"
key_id = "key-id"
private_key = "private-key"
principal = "principal"
expiration = 10
}
}
}
`

func TestAccClientAddons(t *testing.T) {
acctest.Test(t, resource.TestCase{
Steps: []resource.TestStep{
Expand Down Expand Up @@ -1098,6 +1115,19 @@ func TestAccClientAddons(t *testing.T) {
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.salesforce_sandbox_api.0.community_url_section", "community-url-section"),
),
},
{
Config: acctest.ParseTestName(testAccUpdateClientWithAddonsLayer, 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.layer.0.provider_id", "provider-id"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.layer.0.key_id", "key-id"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.layer.0.private_key", "private-key"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.layer.0.principal", "principal"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.layer.0.expiration", "10"),
),
},
},
})
}
Expand Down
Loading

0 comments on commit 316204c

Please sign in to comment.