Skip to content

Commit

Permalink
Reintroduce support for azure sb client addon
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught committed Jun 26, 2023
1 parent 52cdcf0 commit 731ef19
Show file tree
Hide file tree
Showing 9 changed files with 327 additions and 28 deletions.
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
15 changes: 14 additions & 1 deletion 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 @@ -165,7 +166,19 @@ Optional:
- `container_write` (Boolean) Indicates that for any blob in the container if the issued token has permission to create or write content, properties, metadata, or block list. Snapshot or lease the blob. Resize the blob (page blob only). Use the blob as the destination of a copy operation within the same account.
- `expiration` (Number) Expiration in minutes for the generated token (default of 5 minutes).
- `signed_identifier` (String) Shared access policy identifier defined in your storage account resource.
- `storage_access_key` (String) Access key associated with this storage account.
- `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. e.g. `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 (e.g. `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.



Expand Down
15 changes: 14 additions & 1 deletion 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 @@ -108,7 +109,19 @@ Optional:
- `container_write` (Boolean) Indicates that for any blob in the container if the issued token has permission to create or write content, properties, metadata, or block list. Snapshot or lease the blob. Resize the blob (page blob only). Use the blob as the destination of a copy operation within the same account.
- `expiration` (Number) Expiration in minutes for the generated token (default of 5 minutes).
- `signed_identifier` (String) Shared access policy identifier defined in your storage account resource.
- `storage_access_key` (String) Access key associated with this storage account.
- `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. e.g. `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 (e.g. `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.



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}
}
41 changes: 41 additions & 0 deletions internal/auth0/client/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ func NewResource() *schema.Resource {
Description: "Access key associated with this storage account.",
Type: schema.TypeString,
Optional: true,
Sensitive: true,
},
"container_name": {
Description: "Container to request a token for. e.g. `my-container`.",
Expand Down Expand Up @@ -607,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 (e.g. `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. e.g. `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
30 changes: 30 additions & 0 deletions internal/auth0/client/resource_test.go
Original file line number Diff line number Diff line change
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

0 comments on commit 731ef19

Please sign in to comment.