Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

Commit

Permalink
finalise support for emails and add acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkappa committed Jun 20, 2018
1 parent 920318a commit 6a93939
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Gopkg.lock

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

1 change: 1 addition & 0 deletions auth0/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func Provider() *schema.Provider {
"auth0_resource_server": newResourceServer(),
"auth0_rule": newRule(),
"auth0_rule_config": newRuleConfig(),
"auth0_email": newEmail(),
},
ConfigureFunc: configure,
}
Expand Down
19 changes: 19 additions & 0 deletions auth0/resource_auth0_email.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func createEmail(d *schema.ResourceData, m interface{}) error {
if err := api.Email.Create(e); err != nil {
return err
}
d.SetId(e.Name)
return nil
}

Expand All @@ -93,9 +94,27 @@ func readEmail(d *schema.ResourceData, m interface{}) error {
if err != nil {
return err
}
d.SetId(e.Name)
d.Set("name", e.Name)
d.Set("enabled", e.Enabled)
d.Set("default_from_address", e.DefaultFromAddress)

if credentials := e.Credentials; credentials != nil {
d.Set("credentials", []map[string]interface{}{
{
"api_user": e.Credentials.APIUser,
"api_key": e.Credentials.APIKey,
"access_key_id": e.Credentials.AccessKeyID,
"secret_access_key": e.Credentials.SecretAccessKey,
"region": e.Credentials.Region,
"smtp_host": e.Credentials.SMTPHost,
"smtp_port": e.Credentials.SMTPPort,
"smtp_user": e.Credentials.SMTPUser,
"smtp_pass": e.Credentials.SMTPPass,
},
})
}

return nil
}

Expand Down
45 changes: 45 additions & 0 deletions auth0/resource_auth0_email_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package auth0

import (
"testing"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)

func TestAccEmail(t *testing.T) {

resource.Test(t, resource.TestCase{
Providers: map[string]terraform.ResourceProvider{
"auth0": Provider(),
},
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccEmailConfig,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_email.my_email_provider", "name", "ses"),
resource.TestCheckResourceAttr("auth0_email.my_email_provider", "enabled", "true"),
resource.TestCheckResourceAttr("auth0_email.my_email_provider", "default_from_address", "[email protected]"),
resource.TestCheckResourceAttr("auth0_email.my_email_provider", "credentials.0.access_key_id", "AKIAXXXXXXXXXXXXXXXX"),
resource.TestCheckResourceAttr("auth0_email.my_email_provider", "credentials.0.secret_access_key", "7e8c2148xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"),
resource.TestCheckResourceAttr("auth0_email.my_email_provider", "credentials.0.region", "us-east-1"),
),
},
},
})
}

const testAccEmailConfig = `
provider "auth0" {}
resource "auth0_email" "my_email_provider" {
name = "ses"
enabled = true
default_from_address = "[email protected]"
credentials = {
access_key_id = "AKIAXXXXXXXXXXXXXXXX"
secret_access_key = "7e8c2148xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
region = "us-east-1"
}
}
`
14 changes: 7 additions & 7 deletions example/client/main.tf
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
provider "auth0" {}

resource "auth0_client" "my_app_client" {
name = "Example Application (Managed by Terraform)"
description = "Example Application Long Description"
name = "Example Penis Application (Managed by Terraform)"
description = "Example Penis Application Loooooong Description"
app_type = "non_interactive"
is_first_party = false
is_first_party = true
oidc_conformant = false
callbacks = ["https://example.com/callback"]
allowed_origins = ["https://example.com"]
web_origins = ["https://example.com"]
callbacks = ["https://peni.com/callback"]
allowed_origins = ["https://peni.com"]
web_origins = ["https://peni.com"]

jwt_configuration = {
lifetime_in_seconds = 300
lifetime_in_seconds = 120
secret_encoded = true
alg = "RS256"
}
Expand Down
12 changes: 12 additions & 0 deletions example/email/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
provider "auth0" {}

resource "auth0_email" "my_email_provider" {
name = "ses"
enabled = true
default_from_address = "[email protected]"
credentials = {
access_key_id = "AKIAXXXXXXXXXXXXXXXX"
secret_access_key = "7e8c2148xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
region = "us-east-1"
}
}
11 changes: 11 additions & 0 deletions vendor/github.com/yieldr/go-auth0/management/connection.go

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

2 changes: 1 addition & 1 deletion vendor/github.com/yieldr/go-auth0/management/email.go

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

0 comments on commit 6a93939

Please sign in to comment.