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

Commit

Permalink
Changing name or strategy forces new resource (#27)
Browse files Browse the repository at this point in the history
* name,strategy forces new resource and is omited from updates
* change custom domain name, to avoid conflict
* typo and formatting
  • Loading branch information
alexkappa committed Aug 6, 2018
1 parent 4fa1297 commit 920292d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
43 changes: 24 additions & 19 deletions auth0/resource_auth0_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func newConnection() *schema.Resource {
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"strategy": {
Type: schema.TypeString,
Expand All @@ -41,6 +42,7 @@ func newConnection() *schema.Resource {
"waad", "weibo", "windowslive", "wordpress", "yahoo",
"yammer", "yandex",
}, true),
ForceNew: true,
},
"options": {
Type: schema.TypeList,
Expand Down Expand Up @@ -188,6 +190,8 @@ func readConnection(d *schema.ResourceData, m interface{}) error {

func updateConnection(d *schema.ResourceData, m interface{}) error {
c := buildConnection(d)
c.Strategy = ""
c.Name = ""
api := m.(*management.Management)
err := api.Connection.Update(d.Id(), c)
if err != nil {
Expand All @@ -214,26 +218,27 @@ func buildConnection(d *schema.ResourceData) *management.Connection {
vL := v.([]interface{})
for _, v := range vL {

options := v.(map[string]interface{})
if options, ok := v.(map[string]interface{}); ok {

c.Options = &management.ConnectionOptions{
Validation: options["validation"].(map[string]interface{}),
PasswordPolicy: options["password_policy"].(string),
PasswordHistory: options["password_history"].(map[string]interface{}),
PasswordNoPersonalInfo: options["password_no_personal_info"].(map[string]interface{}),
PasswordDictionary: options["password_dictionary"].(map[string]interface{}),
APIEnableUsers: options["api_enable_users"].(bool),
BasicProfile: options["basic_profile"].(bool),
ExtAdmin: options["ext_admin"].(bool),
ExtIsSuspended: options["ext_is_suspended"].(bool),
ExtAgreedTerms: options["ext_agreed_terms"].(bool),
ExtGroups: options["ext_groups"].(bool),
ExtAssignedPlans: options["ext_assigned_plans"].(bool),
ExtProfile: options["ext_profile"].(bool),
EnabledDatabaseCustomization: options["enabled_database_customization"].(bool),
BruteForceProtection: options["brute_force_protection"].(bool),
ImportMode: options["import_mode"].(bool),
DisableSignup: options["disable_signup"].(bool),
c.Options = &management.ConnectionOptions{
Validation: options["validation"].(map[string]interface{}),
PasswordPolicy: options["password_policy"].(string),
PasswordHistory: options["password_history"].(map[string]interface{}),
PasswordNoPersonalInfo: options["password_no_personal_info"].(map[string]interface{}),
PasswordDictionary: options["password_dictionary"].(map[string]interface{}),
APIEnableUsers: options["api_enable_users"].(bool),
BasicProfile: options["basic_profile"].(bool),
ExtAdmin: options["ext_admin"].(bool),
ExtIsSuspended: options["ext_is_suspended"].(bool),
ExtAgreedTerms: options["ext_agreed_terms"].(bool),
ExtGroups: options["ext_groups"].(bool),
ExtAssignedPlans: options["ext_assigned_plans"].(bool),
ExtProfile: options["ext_profile"].(bool),
EnabledDatabaseCustomization: options["enabled_database_customization"].(bool),
BruteForceProtection: options["brute_force_protection"].(bool),
ImportMode: options["import_mode"].(bool),
DisableSignup: options["disable_signup"].(bool),
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions auth0/resource_auth0_custom_domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestAccCustomDomain(t *testing.T) {
resource.TestStep{
Config: testAccCustomDomain,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_custom_domain.my_custom_domain", "domain", "auth.example.com"),
resource.TestCheckResourceAttr("auth0_custom_domain.my_custom_domain", "domain", "auth.example-app.com"),
resource.TestCheckResourceAttr("auth0_custom_domain.my_custom_domain", "type", "auth0_managed_certs"),
resource.TestCheckResourceAttr("auth0_custom_domain.my_custom_domain", "status", "pending_verification"),
),
Expand All @@ -30,7 +30,7 @@ const testAccCustomDomain = `
provider "auth0" {}
resource "auth0_custom_domain" "my_custom_domain" {
domain = "auth.example.com"
domain = "auth.example-app.com"
type = "auth0_managed_certs"
verification_method = "txt"
}
Expand Down

0 comments on commit 920292d

Please sign in to comment.