Skip to content

Commit

Permalink
Added support for custom email provider (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
duedares-rvj authored Oct 7, 2024
2 parents 831f015 + 55d6bab commit 49eb8e1
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
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.

0 comments on commit 49eb8e1

Please sign in to comment.