Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3/X] DXCDT-441: Reintroduce support for azure sb client addon #657

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/data-sources/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Read-Only:

- `aws` (List of Object) (see [below for nested schema](#nestedobjatt--addons--aws))
- `azure_blob` (List of Object) (see [below for nested schema](#nestedobjatt--addons--azure_blob))
- `azure_sb` (List of Object) (see [below for nested schema](#nestedobjatt--addons--azure_sb))

<a id="nestedobjatt--addons--aws"></a>
### Nested Schema for `addons.aws`
Expand Down Expand Up @@ -106,6 +107,18 @@ Read-Only:
- `storage_access_key` (String)


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

Read-Only:

- `entity_path` (String)
- `expiration` (Number)
- `namespace` (String)
- `sas_key` (String)
- `sas_key_name` (String)



<a id="nestedatt--jwt_configuration"></a>
### Nested Schema for `jwt_configuration`
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 @@ -64,6 +64,7 @@ Read-Only:

- `aws` (List of Object) (see [below for nested schema](#nestedobjatt--addons--aws))
- `azure_blob` (List of Object) (see [below for nested schema](#nestedobjatt--addons--azure_blob))
- `azure_sb` (List of Object) (see [below for nested schema](#nestedobjatt--addons--azure_sb))

<a id="nestedobjatt--addons--aws"></a>
### Nested Schema for `addons.aws`
Expand Down Expand Up @@ -95,6 +96,18 @@ Read-Only:
- `storage_access_key` (String)


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

Read-Only:

- `entity_path` (String)
- `expiration` (Number)
- `namespace` (String)
- `sas_key` (String)
- `sas_key_name` (String)



<a id="nestedatt--jwt_configuration"></a>
### Nested Schema for `jwt_configuration`
Expand Down
13 changes: 13 additions & 0 deletions docs/resources/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ Optional:

- `aws` (Block List, Max: 1) AWS Addon configuration. (see [below for nested schema](#nestedblock--addons--aws))
- `azure_blob` (Block List, Max: 1) Azure Blob Storage Addon configuration. (see [below for nested schema](#nestedblock--addons--azure_blob))
- `azure_sb` (Block List, Max: 1) Azure Storage Bus Addon configuration. (see [below for nested schema](#nestedblock--addons--azure_sb))

<a id="nestedblock--addons--aws"></a>
### Nested Schema for `addons.aws`
Expand Down Expand Up @@ -168,6 +169,18 @@ Optional:
- `storage_access_key` (String, Sensitive) Access key associated with this storage account.


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

Optional:

- `entity_path` (String) Entity you want to request a token for, such as `my-queue`.
- `expiration` (Number) Optional expiration in minutes for the generated token. Defaults to 5 minutes.
- `namespace` (String) Your Azure Service Bus namespace. Usually the first segment of your Service Bus URL (for example `https://acme-org.servicebus.windows.net` would be `acme-org`).
- `sas_key` (String, Sensitive) Primary Key associated with your shared access policy.
- `sas_key_name` (String) Your shared access policy name defined in your Service Bus entity.



<a id="nestedblock--jwt_configuration"></a>
### Nested Schema for `jwt_configuration`
Expand Down
13 changes: 13 additions & 0 deletions docs/resources/global_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Optional:

- `aws` (Block List, Max: 1) AWS Addon configuration. (see [below for nested schema](#nestedblock--addons--aws))
- `azure_blob` (Block List, Max: 1) Azure Blob Storage Addon configuration. (see [below for nested schema](#nestedblock--addons--azure_blob))
- `azure_sb` (Block List, Max: 1) Azure Storage Bus Addon configuration. (see [below for nested schema](#nestedblock--addons--azure_sb))

<a id="nestedblock--addons--aws"></a>
### Nested Schema for `addons.aws`
Expand Down Expand Up @@ -111,6 +112,18 @@ Optional:
- `storage_access_key` (String, Sensitive) Access key associated with this storage account.


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

Optional:

- `entity_path` (String) Entity you want to request a token for, such as `my-queue`.
- `expiration` (Number) Optional expiration in minutes for the generated token. Defaults to 5 minutes.
- `namespace` (String) Your Azure Service Bus namespace. Usually the first segment of your Service Bus URL (for example `https://acme-org.servicebus.windows.net` would be `acme-org`).
- `sas_key` (String, Sensitive) Primary Key associated with your shared access policy.
- `sas_key_name` (String) Your shared access policy name defined in your Service Bus entity.



<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 @@ -246,6 +246,7 @@ func expandClientAddons(d *schema.ResourceData) *management.ClientAddons {
d.GetRawConfig().GetAttr("addons").ForEachElement(func(_ cty.Value, addonsCfg cty.Value) (stop bool) {
addons.AWS = expandClientAddonAWS(addonsCfg.GetAttr("aws"))
addons.AzureBlob = expandClientAddonAzureBlob(addonsCfg.GetAttr("azure_blob"))
addons.AzureSB = expandClientAddonAzureSB(addonsCfg.GetAttr("azure_sb"))
return stop
})

Expand Down Expand Up @@ -298,6 +299,24 @@ func expandClientAddonAzureBlob(azureCfg cty.Value) *management.AzureBlobClientA
return &azureAddon
}

func expandClientAddonAzureSB(azureCfg cty.Value) *management.AzureSBClientAddon {
var azureAddon management.AzureSBClientAddon

azureCfg.ForEachElement(func(_ cty.Value, azureCfg cty.Value) (stop bool) {
azureAddon = management.AzureSBClientAddon{
Namespace: value.String(azureCfg.GetAttr("namespace")),
SASKeyName: value.String(azureCfg.GetAttr("sas_key_name")),
SASKey: value.String(azureCfg.GetAttr("sas_key")),
EntityPath: value.String(azureCfg.GetAttr("entity_path")),
Expiration: value.Int(azureCfg.GetAttr("expiration")),
}

return stop
})

return &azureAddon
}

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 @@ -97,6 +97,7 @@ func flattenClientAddons(addons *management.ClientAddons) []interface{} {
m := map[string]interface{}{
"aws": nil,
"azure_blob": nil,
"azure_sb": nil,
}

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

if addons.GetAzureSB() != nil {
m["azure_sb"] = []interface{}{
map[string]interface{}{
"namespace": addons.GetAzureSB().GetNamespace(),
"sas_key_name": addons.GetAzureSB().GetSASKeyName(),
"sas_key": addons.GetAzureSB().GetSASKey(),
"entity_path": addons.GetAzureSB().GetEntityPath(),
"expiration": addons.GetAzureSB().GetExpiration(),
},
}
}

return []interface{}{m}
}
40 changes: 40 additions & 0 deletions internal/auth0/client/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,46 @@ func NewResource() *schema.Resource {
},
},
},
"azure_sb": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: "Azure Storage Bus Addon configuration.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"namespace": {
Description: "Your Azure Service Bus namespace. Usually the first segment of " +
"your Service Bus URL (for example `https://acme-org.servicebus.windows.net` " +
"would be `acme-org`).",
Type: schema.TypeString,
Optional: true,
},
"sas_key_name": {
Description: "Your shared access policy name defined in your Service Bus entity.",
Type: schema.TypeString,
Optional: true,
},
"sas_key": {
Description: "Primary Key associated with your shared access policy.",
Type: schema.TypeString,
Optional: true,
Sensitive: true,
},
"entity_path": {
Description: "Entity you want to request a token for, such as `my-queue`.",
Type: schema.TypeString,
Optional: true,
},
"expiration": {
Description: "Optional expiration in minutes for the generated token. Defaults to 5 minutes.",
Type: schema.TypeInt,
ValidateFunc: validation.IntAtLeast(0),
Optional: true,
},
},
},
},
},
},
},
Expand Down
36 changes: 33 additions & 3 deletions internal/auth0/client/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ func TestAccClient(t *testing.T) {
resource.TestCheckResourceAttr("auth0_client.my_client", "oidc_conformant", "false"),
resource.TestCheckResourceAttr("auth0_client.my_client", "cross_origin_auth", "false"),
resource.TestCheckResourceAttr("auth0_client.my_client", "mobile.#", "0"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.#", "0"),

resource.TestCheckResourceAttr("auth0_client.my_client", "native_social_login.#", "0"),
resource.TestCheckResourceAttr("auth0_client.my_client", "signing_keys.#", "1"),
resource.TestCheckResourceAttr("auth0_client.my_client", "grant_types.#", "4"),
Expand Down Expand Up @@ -636,7 +636,7 @@ func TestAccClient(t *testing.T) {
resource.TestCheckResourceAttr("auth0_client.my_client", "oidc_conformant", "true"),
resource.TestCheckResourceAttr("auth0_client.my_client", "cross_origin_auth", "false"),
resource.TestCheckResourceAttr("auth0_client.my_client", "mobile.#", "0"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.#", "0"),

resource.TestCheckResourceAttr("auth0_client.my_client", "native_social_login.#", "0"),
resource.TestCheckResourceAttr("auth0_client.my_client", "signing_keys.#", "1"),
resource.TestCheckResourceAttr("auth0_client.my_client", "grant_types.#", "5"),
Expand Down Expand Up @@ -703,7 +703,7 @@ func TestAccClient(t *testing.T) {
resource.TestCheckResourceAttr("auth0_client.my_client", "oidc_conformant", "true"),
resource.TestCheckResourceAttr("auth0_client.my_client", "cross_origin_auth", "false"),
resource.TestCheckResourceAttr("auth0_client.my_client", "mobile.#", "0"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.#", "0"),

resource.TestCheckResourceAttr("auth0_client.my_client", "native_social_login.#", "0"),
resource.TestCheckResourceAttr("auth0_client.my_client", "signing_keys.#", "1"),
resource.TestCheckResourceAttr("auth0_client.my_client", "grant_types.#", "0"),
Expand Down Expand Up @@ -778,6 +778,23 @@ resource "auth0_client" "my_client" {
}
`

const testAccUpdateClientWithAddonsAzureSB = `
resource "auth0_client" "my_client" {
name = "Acceptance Test - SSO Integration - {{.testName}}"
app_type = "sso_integration"

addons {
azure_sb {
namespace = "acmeorg"
sas_key_name = "my-policy"
sas_key = "my-key"
entity_path = "my-queue"
expiration = 10
}
}
}
`

func TestAccClientAddons(t *testing.T) {
acctest.Test(t, resource.TestCase{
Steps: []resource.TestStep{
Expand Down Expand Up @@ -813,6 +830,19 @@ func TestAccClientAddons(t *testing.T) {
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.azure_blob.0.container_list", "true"),
),
},
{
Config: acctest.ParseTestName(testAccUpdateClientWithAddonsAzureSB, 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.azure_sb.0.namespace", "acmeorg"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.azure_sb.0.sas_key_name", "my-policy"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.azure_sb.0.sas_key", "my-key"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.azure_sb.0.entity_path", "my-queue"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.azure_sb.0.expiration", "10"),
),
},
},
})
}
Expand Down
Loading