diff --git a/internal/cli/email_provider.go b/internal/cli/email_provider.go
index 44617714..2e204292 100644
--- a/internal/cli/email_provider.go
+++ b/internal/cli/email_provider.go
@@ -303,8 +303,13 @@ func updateEmailProviderCmd(cli *cli) *cobra.Command {
var credentials map[string]interface{}
var settings map[string]interface{}
+ emailProvider := &management.EmailProvider{}
+
// Check if we are changing providers.
if len(inputs.name) > 0 && inputs.name != currentProvider.GetName() {
+ // Only set the name if we are changing it.
+ emailProvider.Name = &inputs.name
+
// If we are changing providers, we need new credentials and settings.
if inputs.name == emailProviderCustom {
if len(inputs.credentials) > 0 {
@@ -343,9 +348,9 @@ func updateEmailProviderCmd(cli *cli) *cobra.Command {
}
}
- emailProvider := &management.EmailProvider{
- Name: &inputs.name,
- Enabled: &inputs.enabled,
+ // Set the flag if it was supplied or entered by the prompt.
+ if canPrompt(cmd) || emailProviderEnabled.IsSet(cmd) {
+ emailProvider.Enabled = &inputs.enabled
}
if len(inputs.defaultFromAddress) > 0 {
diff --git a/test/integration/email-test-cases.yaml b/test/integration/email-test-cases.yaml
index d4d225c6..b0248b48 100644
--- a/test/integration/email-test-cases.yaml
+++ b/test/integration/email-test-cases.yaml
@@ -3,38 +3,55 @@ config:
retries: 1
tests:
- 001 - create email provider:
- command: auth0 email provider create --provider=mandrill --enabled=false --default-from-address='admin@auth0.invalid' --credentials='{"api_key":"some-api-key"}' --settings='{}'
+ 001 - clean up email provider:
+ command: auth0 email provider delete --force
exit-code: 0
- 002 - it successfully shows the email provider:
+ 002 - create email provider:
+ command: auth0 email provider create --provider=mandrill --enabled=false --default-from-address='not-admin@auth0.invalid' --credentials='{"api_key":"some-api-key"}' --settings='{}'
+ exit-code: 0
+
+ 003 - delete up email provider:
+ command: auth0 email provider delete --force
+ exit-code: 0
+
+ 004 - it doesn't show the email provider:
+ command: auth0 email provider show
+ exit-code: 1
+
+ 005 - create email provider:
+ command: auth0 email provider create --provider=mandrill --enabled=false --default-from-address='not-admin@auth0.invalid' --credentials='{"api_key":"some-api-key"}' --settings='{}'
+ exit-code: 0
+
+ 006 - it successfully shows the email provider:
command: auth0 email provider show
exit-code: 0
stdout:
contains:
- - PROVIDER mandrill
- - ENABLED ✗
- - DEFAULT FROM ADDRESS admin@auth0.invalid
- - SETTINGS '{}'
+ - PROVIDER mandrill
+ - ENABLED ✗
+ - DEFAULT FROM ADDRESS not-admin@auth0.invalid
+ - SETTINGS {}
- 003 - update and enable email provider:
+ 007 - update and enable email provider:
command: auth0 email provider update --enabled --default-from-address='admin@auth0.invalid'
exit-code: 0
- 004 - it successfully shows the email provider:
+ 008 - it successfully shows the email provider:
command: auth0 email provider show
exit-code: 0
stdout:
contains:
- - PROVIDER mandrill
- - DEFAULT FROM ADDRESS admin@auth0.invalid
- - ENABLED ✓
+ - PROVIDER mandrill
+ - ENABLED ✓
+ - DEFAULT FROM ADDRESS admin@auth0.invalid
+ - SETTINGS {}
- 005 - it successfully updates welcome email template:
+ 100 - it successfully updates welcome email template:
command: auth0 email templates update welcome --enabled --body "
Welcome!
" --from "welcome@travel0.com" --lifetime 6100 --subject "Welcome to Travel0" --url "travel0.com" --force
exit-code: 0
- 006 - it successfully shows welcome email template:
+ 101 - it successfully shows welcome email template:
command: auth0 email templates show welcome
exit-code: 0
stdout:
@@ -46,11 +63,11 @@ tests:
- RESULT URL LIFETIME 6100
- ENABLED ✓
- 007 - it successfully updates verify-link email template:
+ 102 - it successfully updates verify-link email template:
command: auth0 email templates update verify-link --enabled --body "Verify link
" --from "verify@travel0.com" --lifetime 6100 --subject "Verify link" --url "travel0.com" --force
exit-code: 0
- 008 - it successfully shows verify-link email template:
+ 103 - it successfully shows verify-link email template:
command: auth0 email templates show verify-link
exit-code: 0
stdout:
@@ -61,11 +78,11 @@ tests:
- RESULT URL travel0.com
- RESULT URL LIFETIME 6100
- ENABLED ✓
- 009 - it successfully updates verify-code email template:
+ 104 - it successfully updates verify-code email template:
command: auth0 email templates update verify-code --enabled --body "Verify code
" --from "verify@travel0.com" --lifetime 6100 --subject "Verify code" --url "travel0.com" --force
exit-code: 0
- 010 - it successfully shows verify-code email template:
+ 105 - it successfully shows verify-code email template:
command: auth0 email templates show verify-code
exit-code: 0
stdout:
@@ -76,11 +93,11 @@ tests:
- RESULT URL travel0.com
- RESULT URL LIFETIME 6100
- ENABLED ✓
- 011 - it successfully updates change-password email template:
+ 106 - it successfully updates change-password email template:
command: auth0 email templates update change-password --enabled --body "Change password
" --from "change-password@travel0.com" --lifetime 6100 --subject "Change password" --url "travel0.com" --force
exit-code: 0
- 012 - it successfully shows change-password email template:
+ 107 - it successfully shows change-password email template:
command: auth0 email templates show change-password
exit-code: 0
stdout:
@@ -91,11 +108,11 @@ tests:
- RESULT URL travel0.com
- RESULT URL LIFETIME 6100
- ENABLED ✓
- 013 - it successfully updates blocked-account email template:
+ 108 - it successfully updates blocked-account email template:
command: auth0 email templates update blocked-account --enabled --body "Change password
" --from "blocked@travel0.com" --lifetime 6100 --subject "Blocked!" --url "travel0.com" --force
exit-code: 0
- 014 - it successfully shows blocked-account email template:
+ 109 - it successfully shows blocked-account email template:
command: auth0 email templates show blocked-account
exit-code: 0
stdout:
@@ -106,11 +123,11 @@ tests:
- RESULT URL travel0.com
- RESULT URL LIFETIME 6100
- ENABLED ✓
- 015 - it successfully updates password-breach email template:
+ 110 - it successfully updates password-breach email template:
command: auth0 email templates update password-breach --enabled --body "Password breached
" --from "security@travel0.com" --lifetime 6100 --subject "Breached Password!" --url "travel0.com" --force
exit-code: 0
- 016 - it successfully shows password-breach email template:
+ 111 - it successfully shows password-breach email template:
command: auth0 email templates show password-breach
exit-code: 0
stdout:
@@ -121,11 +138,11 @@ tests:
- RESULT URL travel0.com
- RESULT URL LIFETIME 6100
- ENABLED ✓
- 017 - it successfully updates mfa-enrollment email template:
+ 112 - it successfully updates mfa-enrollment email template:
command: auth0 email templates update mfa-enrollment --enabled --body "Enroll in MFA
" --from "security@travel0.com" --lifetime 6100 --subject "Enroll in MFA!" --url "travel0.com" --force
exit-code: 0
- 018 - it successfully shows mfa-enrollment email template:
+ 113 - it successfully shows mfa-enrollment email template:
command: auth0 email templates show mfa-enrollment
exit-code: 0
stdout:
@@ -136,11 +153,11 @@ tests:
- RESULT URL travel0.com
- RESULT URL LIFETIME 6100
- ENABLED ✓
- 019 - it successfully updates mfa-code email template:
+ 114 - it successfully updates mfa-code email template:
command: auth0 email templates update mfa-code --enabled --body "MFA Enrollment code
" --from "security@travel0.com" --lifetime 6100 --subject "MFA Enrollment Code" --url "travel0.com" --force
exit-code: 0
- 020 - it successfully shows mfa-code email template:
+ 115 - it successfully shows mfa-code email template:
command: auth0 email templates show mfa-code
exit-code: 0
stdout:
@@ -151,11 +168,11 @@ tests:
- RESULT URL travel0.com
- RESULT URL LIFETIME 6100
- ENABLED ✓
- 021 - it successfully updates user-invitation email template:
+ 116 - it successfully updates user-invitation email template:
command: auth0 email templates update user-invitation --enabled --body "You are invited!
" --from "invited@travel0.com" --lifetime 6100 --subject "You are invited!" --url "travel0.com" --force
exit-code: 0
- 022 - it successfully shows user-invitation email template:
+ 117 - it successfully shows user-invitation email template:
command: auth0 email templates show user-invitation
exit-code: 0
stdout:
@@ -166,7 +183,7 @@ tests:
- RESULT URL travel0.com
- RESULT URL LIFETIME 6100
- ENABLED ✓
- 023 - it successfully shows user-invitation email template (json):
+ 118 - it successfully shows user-invitation email template (json):
command: "auth0 email templates show user-invitation --json | jq ."
exit-code: 0
stdout:
diff --git a/test/integration/scripts/test-cleanup.sh b/test/integration/scripts/test-cleanup.sh
index 9b51d685..ca0eed9a 100755
--- a/test/integration/scripts/test-cleanup.sh
+++ b/test/integration/scripts/test-cleanup.sh
@@ -33,6 +33,9 @@ delete_resources "logs streams" "integration-test-" "id"
auth0 domains delete $(./test/integration/scripts/get-custom-domain-id.sh) --no-input
+# clean up the email provider
+auth0 email provider delete --force
+
# Reset universal login branding
auth0 ul update --accent "#2A2E35" --background "#FF4F40" --logo "https://example.com/logo.png" --favicon "https://example.com/favicon.png" --font https://example.com/font.woff --no-input