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

Add missing support for Custom email provider in EmailProviderManager #452

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 12 additions & 0 deletions management/email_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ const (

// EmailProviderMS365 constant.
EmailProviderMS365 = "ms365"

// EmailProviderCustom constant.
EmailProviderCustom = "custom"
)

// EmailProvider is used to configure Email Providers.
Expand Down Expand Up @@ -118,6 +121,11 @@ type EmailProviderCredentialsMS365 struct {
ClientSecret *string `json:"clientSecret,omitempty"`
}

// EmailProviderCredentialsCustom represent the
// credentials required to use the custom provider.
type EmailProviderCredentialsCustom struct {
}

// EmailProviderSettingsMandrill are the provider
// specific settings used by the mandrill provider.
type EmailProviderSettingsMandrill struct {
Expand Down Expand Up @@ -226,6 +234,10 @@ func (ep *EmailProvider) UnmarshalJSON(b []byte) error {
credentials = &EmailProviderCredentialsMS365{}
// No settings for ms365.
settings = nil
case EmailProviderCustom:
credentials = &EmailProviderCredentialsCustom{}
// No settings for custom.
settings = nil
case "":
credentials = nil
settings = nil
Expand Down
10 changes: 10 additions & 0 deletions management/email_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ func TestEmailProviderJSON(t *testing.T) {
},
json: `{"name":"ms365","enabled":true,"default_from_address":"[email protected]","credentials":{"tenantId":"ms365_tenant_id","clientId":"ms365_client_id","clientSecret":"ms365_client_secret"}}`,
},
{
name: "it can %s a custom email provider",
emailProvider: &EmailProvider{
Name: auth0.String("custom"),
Enabled: auth0.Bool(true),
DefaultFromAddress: auth0.String("[email protected]"),
Credentials: &EmailProviderCredentialsCustom{},
},
json: `{"name":"custom","enabled":true,"default_from_address":"[email protected]","credentials":{}}`,
},
}

for _, testCase := range jsonTestCases {
Expand Down
5 changes: 5 additions & 0 deletions management/management.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions management/management.gen_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading