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

DXCDT-347: Allow updating templates for phone-message-hook in auth0 guardian #444

Merged
merged 5 commits into from
Jan 27, 2023
Merged
Changes from 3 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
2 changes: 1 addition & 1 deletion docs/resources/guardian.md
Original file line number Diff line number Diff line change
@@ -112,7 +112,7 @@ Optional:

- `message_types` (List of String) Message types to use, array of `sms` and/or `voice`. Adding both to the array should enable the user to choose.
- `options` (Block List, Max: 1) Options for the various providers. (see [below for nested schema](#nestedblock--phone--options))
- `provider` (String) Provider to use, one of `auth0`, `twilio` or `phone-message-hook`.
- `provider` (String) Provider to use, one of `auth0`, `twilio` or `phone-message-hook`. Selecting `phone-message-hook` will require a Phone Message Action to be created before. [Learn how.](https://auth0.com/docs/customize/actions/flows-and-triggers/send-phone-message-flow)
sergiught marked this conversation as resolved.
Show resolved Hide resolved

<a id="nestedblock--phone--options"></a>
### Nested Schema for `phone.options`
5 changes: 4 additions & 1 deletion internal/provider/resource_auth0_guardian.go
Original file line number Diff line number Diff line change
@@ -140,7 +140,10 @@ func newGuardian() *schema.Resource {
false,
),
RequiredWith: []string{"phone.0.message_types"},
Description: "Provider to use, one of `auth0`, `twilio` or `phone-message-hook`.",
Description: "Provider to use, one of `auth0`, `twilio` or `phone-message-hook`. " +
"Selecting `phone-message-hook` will require a " +
"Phone Message Action to be created before. " +
"[Learn how].(https://auth0.com/docs/customize/actions/flows-and-triggers/send-phone-message-flow)",
},
"message_types": {
Type: schema.TypeList,
11 changes: 8 additions & 3 deletions internal/provider/resource_auth0_guardian_test.go
Original file line number Diff line number Diff line change
@@ -113,14 +113,17 @@ resource "auth0_guardian" "foo" {
}
`

const testAccGuardianPhoneWithCustomProviderAndEmptyOptions = `
const testAccGuardianPhoneWithCustomProviderAndOptions = `
resource "auth0_guardian" "foo" {
policy = "all-applications"
phone {
enabled = true
provider = "phone-message-hook"
message_types = ["sms"]
options {}
options {
enrollment_message = "enroll foo"
verification_message = "verify foo"
}
}
}
`
@@ -186,14 +189,16 @@ func TestAccGuardianPhone(t *testing.T) {
),
},
{
Config: testAccGuardianPhoneWithCustomProviderAndEmptyOptions,
Config: testAccGuardianPhoneWithCustomProviderAndOptions,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_guardian.foo", "policy", "all-applications"),
resource.TestCheckResourceAttr("auth0_guardian.foo", "phone.#", "1"),
resource.TestCheckResourceAttr("auth0_guardian.foo", "phone.0.enabled", "true"),
resource.TestCheckResourceAttr("auth0_guardian.foo", "phone.0.message_types.0", "sms"),
resource.TestCheckResourceAttr("auth0_guardian.foo", "phone.0.provider", "phone-message-hook"),
resource.TestCheckResourceAttr("auth0_guardian.foo", "phone.0.options.#", "1"),
resource.TestCheckResourceAttr("auth0_guardian.foo", "phone.0.options.0.enrollment_message", "enroll foo"),
resource.TestCheckResourceAttr("auth0_guardian.foo", "phone.0.options.0.verification_message", "verify foo"),
),
},
{
6 changes: 2 additions & 4 deletions internal/provider/structure_auth0_guardian.go
Original file line number Diff line number Diff line change
@@ -49,13 +49,11 @@ func flattenPhone(enabled bool, api *management.Management) ([]interface{}, erro
if err != nil {
return nil, err
}
case "auth0":
case "auth0", "phone-message-hook":
phoneProviderOptions, err = flattenAuth0Options(api)
if err != nil {
return nil, err
}
case "phone-message-hook":
phoneProviderOptions = []interface{}{nil}
}
phoneData["options"] = phoneProviderOptions

@@ -285,7 +283,7 @@ func configurePhone(config cty.Value, api *management.Management) error {
if err = updateTwilioOptions(options, api); err != nil {
return true
}
case "auth0":
case "auth0", "phone-message-hook":
if err = updateAuth0Options(options, api); err != nil {
return true
}
Loading