Skip to content

Commit

Permalink
Merge pull request #140 from auth0/patch/issue-139
Browse files Browse the repository at this point in the history
Fix conversion issue flattenAddons func in client resource
  • Loading branch information
sergiught authored Apr 14, 2022
2 parents 39bc476 + 9d76828 commit cb5ed0f
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.30.1

BUG FIXES:

- `resource/auth0_client`: Fix conversion issue flattenAddons func in client resource ([#140](https://github.com/auth0/terraform-provider-auth0/pull/140))


## 0.30.0

FEATURES:
Expand Down
10 changes: 7 additions & 3 deletions auth0/resource_auth0_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,10 @@ func flattenClientAddons(addons map[string]interface{}) []interface{} {
"include_attribute_name_format": samlp["includeAttributeNameFormat"],
"binding": samlp["binding"],
"signing_cert": samlp["signingCert"],
"logout": mapToState(samlp["logout"].(map[string]interface{})),
}

if logout, ok := samlp["logout"].(map[string]interface{}); ok {
samlpMap["logout"] = mapToState(logout)
}

m["samlp"] = []interface{}{samlpMap}
Expand All @@ -1009,8 +1012,9 @@ func flattenClientAddons(addons map[string]interface{}) []interface{} {
"springcm", "wams", "wsfed", "zendesk", "zoom",
} {
if value, ok := addons[name]; ok {
addonType := value.(map[string]interface{})
m[name] = mapToState(addonType)
if addonType, ok := value.(map[string]interface{}); ok {
m[name] = mapToState(addonType)
}
}
}

Expand Down
83 changes: 83 additions & 0 deletions auth0/resource_auth0_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,94 @@ func TestAccClient(t *testing.T) {
resource.TestCheckResourceAttr("auth0_client.my_client", "signing_keys.#", "1"), // checks that signing_keys is set, and it includes 1 element
),
},
{
Config: random.Template(testAccClientConfigWithoutAddonsWithSAMLPLogout, rand),
Check: resource.ComposeTestCheckFunc(
random.TestCheckResourceAttr("auth0_client.my_client", "name", "Acceptance Test - {{.random}}", rand),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.#", "1"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.samlp.#", "1"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.samlp.0.logout.%", "2"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.samlp.0.logout.callback", "http://example.com/callback"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.samlp.0.logout.slo_enabled", "true"),
),
},
},
})
}

const testAccClientConfig = `
resource "auth0_client" "my_client" {
name = "Acceptance Test - {{.random}}"
description = "Test Application Long Description"
app_type = "non_interactive"
custom_login_page_on = true
is_first_party = true
is_token_endpoint_ip_header_trusted = true
token_endpoint_auth_method = "client_secret_post"
oidc_conformant = true
callbacks = [ "https://example.com/callback" ]
allowed_origins = [ "https://example.com" ]
allowed_clients = [ "https://allowed.example.com" ]
grant_types = [ "authorization_code", "http://auth0.com/oauth/grant-type/password-realm", "implicit", "password", "refresh_token" ]
organization_usage = "deny"
organization_require_behavior = "no_prompt"
allowed_logout_urls = [ "https://example.com" ]
web_origins = [ "https://example.com" ]
jwt_configuration {
lifetime_in_seconds = 300
secret_encoded = true
alg = "RS256"
scopes = {
foo = "bar"
}
}
client_metadata = {
foo = "zoo"
}
addons {
firebase = {
client_email = "[email protected]"
lifetime_in_seconds = 1
private_key = "wer"
private_key_id = "qwreerwerwe"
}
samlp {
audience = "https://example.com/saml"
mappings = {
email = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"
name = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name"
}
create_upn_claim = false
passthrough_claims_with_no_mapping = false
map_unknown_claims_as_is = false
map_identities = false
name_identifier_format = "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent"
name_identifier_probes = [
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"
]
signing_cert = "-----BEGIN PUBLIC KEY-----\nMIGf...bpP/t3\n+JGNGIRMj1hF1rnb6QIDAQAB\n-----END PUBLIC KEY-----\n"
}
}
refresh_token {
leeway = 42
token_lifetime = 424242
rotation_type = "rotating"
expiration_type = "expiring"
infinite_token_lifetime = true
infinite_idle_token_lifetime = false
idle_token_lifetime = 3600
}
mobile {
ios {
team_id = "9JA89QQLNQ"
app_bundle_identifier = "com.my.bundle.id"
}
}
initiate_login_uri = "https://example.com/login"
}
`

const testAccClientConfigWithoutAddonsWithSAMLPLogout = `
resource "auth0_client" "my_client" {
name = "Acceptance Test - {{.random}}"
description = "Test Application Long Description"
Expand Down

0 comments on commit cb5ed0f

Please sign in to comment.