Skip to content

Commit

Permalink
DXCDT-741 Fix email-provider tests, and functionality of update
Browse files Browse the repository at this point in the history
  • Loading branch information
acwest committed Jan 9, 2025
1 parent 63cf697 commit 53da0c1
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 34 deletions.
11 changes: 8 additions & 3 deletions internal/cli/email_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
79 changes: 48 additions & 31 deletions test/integration/email-test-cases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,55 @@ config:
retries: 1

tests:
001 - create email provider:
command: auth0 email provider create --provider=mandrill --enabled=false --default-from-address='[email protected]' --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='[email protected]' --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='[email protected]' --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 [email protected]
- SETTINGS '{}'
- PROVIDER mandrill
- ENABLED
- DEFAULT FROM ADDRESS not-[email protected]
- SETTINGS {}

003 - update and enable email provider:
007 - update and enable email provider:
command: auth0 email provider update --enabled --default-from-address='[email protected]'
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 [email protected]
- ENABLED ✓
- PROVIDER mandrill
- ENABLED ✓
- DEFAULT FROM ADDRESS [email protected]
- SETTINGS {}

005 - it successfully updates welcome email template:
100 - it successfully updates welcome email template:
command: auth0 email templates update welcome --enabled --body "<h1>Welcome!</h1>" --from "[email protected]" --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:
Expand All @@ -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 "<h1>Verify link</h1>" --from "[email protected]" --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:
Expand All @@ -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 "<h1>Verify code</h1>" --from "[email protected]" --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:
Expand All @@ -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 "<h1>Change password</h1>" --from "[email protected]" --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:
Expand All @@ -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 "<h1>Change password</h1>" --from "[email protected]" --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:
Expand All @@ -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 "<h1>Password breached</h1>" --from "[email protected]" --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:
Expand All @@ -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 "<h1>Enroll in MFA</h1>" --from "[email protected]" --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:
Expand All @@ -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 "<h1>MFA Enrollment code</h1>" --from "[email protected]" --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:
Expand All @@ -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 "<h1>You are invited!</h1>" --from "[email protected]" --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:
Expand All @@ -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:
Expand Down

0 comments on commit 53da0c1

Please sign in to comment.