diff --git a/examples/okta_app_basic_auth/basic_updated.tf b/examples/okta_app_basic_auth/basic_updated.tf index d1584831..2a766d73 100644 --- a/examples/okta_app_basic_auth/basic_updated.tf +++ b/examples/okta_app_basic_auth/basic_updated.tf @@ -11,8 +11,8 @@ resource "okta_group" "group" { } resource "okta_app_basic_auth" "test" { - label = "testAcc_replace_with_uuid" - url = "https://example.com/login.html" + label = "testAcc_replace_with_uuid" + url = "https://example.com/login.html" auth_url = "https://example.com/auth.html" users { diff --git a/examples/okta_policy_password/basic_updated.tf b/examples/okta_policy_password/basic_updated.tf index e19af18a..adbf60f5 100644 --- a/examples/okta_policy_password/basic_updated.tf +++ b/examples/okta_policy_password/basic_updated.tf @@ -18,7 +18,7 @@ resource okta_policy_password test { password_expire_warn_days = 15 password_min_age_minutes = 60 password_history_count = 5 - password_max_lockout_attempts = 3 + password_max_lockout_attempts = 0 password_auto_unlock_minutes = 2 password_show_lockout_failures = true question_min_length = 10 diff --git a/go.mod b/go.mod index d7b230c3..d49d4bb1 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/articulate/terraform-provider-okta go 1.12 require ( - github.com/articulate/oktasdk-go v0.0.0-20190417182045-e41ed7befc56 + github.com/articulate/oktasdk-go v1.0.1 github.com/aws/aws-sdk-go v1.23.16 // indirect github.com/beevik/etree v1.1.0 // indirect github.com/bflad/tfproviderlint v0.4.0 diff --git a/go.sum b/go.sum index 832c3fca..e07dac70 100644 --- a/go.sum +++ b/go.sum @@ -55,8 +55,8 @@ github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/articulate/okta-sdk-golang v1.1.1 h1:ymEGt5P/Ckqygz7TtyUINRp7oP7fAhS0nAqoAZ4eM3o= github.com/articulate/okta-sdk-golang v1.1.1/go.mod h1:6ymIhzFQtMyBnwqkEHc/reQUMalObOjgyOSbf3w21PM= -github.com/articulate/oktasdk-go v0.0.0-20190417182045-e41ed7befc56 h1:3oNDqjcsOep3W9pV9SQegVkViLCBGMu8ECIliq3B9dU= -github.com/articulate/oktasdk-go v0.0.0-20190417182045-e41ed7befc56/go.mod h1:UTdWnHE/nQNjDvbmLBwxIHjJ3L8r3XlZZaqVDIUtu1I= +github.com/articulate/oktasdk-go v1.0.1 h1:UuvJSY5yUqT0w9+hdACq1bcmIKAqh25bnVHWWQtsvYQ= +github.com/articulate/oktasdk-go v1.0.1/go.mod h1:UTdWnHE/nQNjDvbmLBwxIHjJ3L8r3XlZZaqVDIUtu1I= github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM= github.com/aws/aws-sdk-go v1.16.36/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.19.18/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= diff --git a/okta/resource_okta_app_oauth_test.go b/okta/resource_okta_app_oauth_test.go index b4c347ee..e0891108 100644 --- a/okta/resource_okta_app_oauth_test.go +++ b/okta/resource_okta_app_oauth_test.go @@ -1,12 +1,14 @@ package okta import ( + "errors" "fmt" "regexp" "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/okta/okta-sdk-golang/okta" "github.com/okta/okta-sdk-golang/okta/query" ) @@ -57,6 +59,17 @@ func TestAccAppOauth_basic(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "client_id"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateCheck: func(s []*terraform.InstanceState) error { + if len(s) != 1 { + return errors.New("Failed to import schema into state") + } + + return nil + }, + }, }, }) } diff --git a/okta/resource_okta_policy_password.go b/okta/resource_okta_policy_password.go index da41f5ee..a2713d04 100644 --- a/okta/resource_okta_policy_password.go +++ b/okta/resource_okta_policy_password.go @@ -313,23 +313,23 @@ func buildPasswordPolicy(d *schema.ResourceData, m interface{}) *articulateOkta. } template.Conditions.AuthProvider.Provider = d.Get("auth_provider").(string) - template.Settings.Password.Complexity.MinLength = d.Get("password_min_length").(int) - template.Settings.Password.Complexity.MinLowerCase = d.Get("password_min_lowercase").(int) - template.Settings.Password.Complexity.MinUpperCase = d.Get("password_min_uppercase").(int) - template.Settings.Password.Complexity.MinNumber = d.Get("password_min_number").(int) - template.Settings.Password.Complexity.MinSymbol = d.Get("password_min_symbol").(int) + template.Settings.Password.Complexity.MinLength = intPtr(d.Get("password_min_length").(int)) + template.Settings.Password.Complexity.MinLowerCase = intPtr(d.Get("password_min_lowercase").(int)) + template.Settings.Password.Complexity.MinUpperCase = intPtr(d.Get("password_min_uppercase").(int)) + template.Settings.Password.Complexity.MinNumber = intPtr(d.Get("password_min_number").(int)) + template.Settings.Password.Complexity.MinSymbol = intPtr(d.Get("password_min_symbol").(int)) template.Settings.Password.Complexity.ExcludeUsername = d.Get("password_exclude_username").(bool) template.Settings.Password.Complexity.ExcludeAttributes = getExcludedAttrs(d.Get("password_exclude_first_name").(bool), d.Get("password_exclude_last_name").(bool)) template.Settings.Password.Complexity.Dictionary.Common.Exclude = d.Get("password_dictionary_lookup").(bool) - template.Settings.Password.Age.MaxAgeDays = d.Get("password_max_age_days").(int) - template.Settings.Password.Age.ExpireWarnDays = d.Get("password_expire_warn_days").(int) - template.Settings.Password.Age.MinAgeMinutes = d.Get("password_min_age_minutes").(int) - template.Settings.Password.Age.HistoryCount = d.Get("password_history_count").(int) - template.Settings.Password.Lockout.MaxAttempts = d.Get("password_max_lockout_attempts").(int) - template.Settings.Password.Lockout.AutoUnlockMinutes = d.Get("password_auto_unlock_minutes").(int) + template.Settings.Password.Age.MaxAgeDays = intPtr(d.Get("password_max_age_days").(int)) + template.Settings.Password.Age.ExpireWarnDays = intPtr(d.Get("password_expire_warn_days").(int)) + template.Settings.Password.Age.MinAgeMinutes = intPtr(d.Get("password_min_age_minutes").(int)) + template.Settings.Password.Age.HistoryCount = intPtr(d.Get("password_history_count").(int)) + template.Settings.Password.Lockout.MaxAttempts = intPtr(d.Get("password_max_lockout_attempts").(int)) + template.Settings.Password.Lockout.AutoUnlockMinutes = intPtr(d.Get("password_auto_unlock_minutes").(int)) template.Settings.Password.Lockout.ShowLockoutFailures = d.Get("password_show_lockout_failures").(bool) template.Settings.Recovery.Factors.RecoveryQuestion.Status = d.Get("question_recovery").(string) - template.Settings.Recovery.Factors.RecoveryQuestion.Properties.Complexity.MinLength = d.Get("question_min_length").(int) + template.Settings.Recovery.Factors.RecoveryQuestion.Properties.Complexity.MinLength = intPtr(d.Get("question_min_length").(int)) template.Settings.Recovery.Factors.OktaEmail.Properties.RecoveryToken.TokenLifetimeMinutes = d.Get("recovery_email_token").(int) template.Settings.Recovery.Factors.OktaSms.Status = d.Get("sms_recovery").(string) template.Settings.Recovery.Factors.OktaEmail.Status = d.Get("email_recovery").(string) diff --git a/okta/resource_okta_policy_password_test.go b/okta/resource_okta_policy_password_test.go index 2a10f58b..871af7d6 100644 --- a/okta/resource_okta_policy_password_test.go +++ b/okta/resource_okta_policy_password_test.go @@ -71,7 +71,7 @@ func TestAccOktaPolicyPassword_crud(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "password_expire_warn_days", "15"), resource.TestCheckResourceAttr(resourceName, "password_min_age_minutes", "60"), resource.TestCheckResourceAttr(resourceName, "password_history_count", "5"), - resource.TestCheckResourceAttr(resourceName, "password_max_lockout_attempts", "3"), + resource.TestCheckResourceAttr(resourceName, "password_max_lockout_attempts", "0"), resource.TestCheckResourceAttr(resourceName, "password_auto_unlock_minutes", "2"), resource.TestCheckResourceAttr(resourceName, "password_show_lockout_failures", "true"), resource.TestCheckResourceAttr(resourceName, "question_min_length", "10"), diff --git a/vendor/github.com/articulate/oktasdk-go/okta/policies.go b/vendor/github.com/articulate/oktasdk-go/okta/policies.go index 4bc17224..9e221bda 100644 --- a/vendor/github.com/articulate/oktasdk-go/okta/policies.go +++ b/vendor/github.com/articulate/oktasdk-go/okta/policies.go @@ -77,14 +77,14 @@ type Enroll struct { // Password policy settings password obj type Password struct { Complexity struct { - MinLength int `json:"minLength,omitempty"` + MinLength *int `json:"minLength,omitempty"` // omitempty considers zero values on primitives empty. Thus if you have a value like one of these where the // default is 1 but 0 is valid, you would never be able to set them to 0 because it would omit them and the // API would default them. Same goes for other primitives. - MinLowerCase int `json:"minLowerCase"` - MinUpperCase int `json:"minUpperCase"` - MinNumber int `json:"minNumber"` - MinSymbol int `json:"minSymbol"` + MinLowerCase *int `json:"minLowerCase"` + MinUpperCase *int `json:"minUpperCase"` + MinNumber *int `json:"minNumber"` + MinSymbol *int `json:"minSymbol"` ExcludeUsername bool `json:"excludeUsername"` ExcludeAttributes []string `json:"excludeAttributes,omitempty"` Dictionary struct { @@ -94,14 +94,14 @@ type Password struct { } `json:"dictionary,omitempty"` } `json:"complexity,omitempty"` Age struct { - MaxAgeDays int `json:"maxAgeDays,omitempty"` - ExpireWarnDays int `json:"expireWarnDays,omitempty"` - MinAgeMinutes int `json:"minAgeMinutes,omitempty"` - HistoryCount int `json:"historyCount,omitempty"` + MaxAgeDays *int `json:"maxAgeDays,omitempty"` + ExpireWarnDays *int `json:"expireWarnDays,omitempty"` + MinAgeMinutes *int `json:"minAgeMinutes,omitempty"` + HistoryCount *int `json:"historyCount,omitempty"` } `json:"age,omitempty"` Lockout struct { - MaxAttempts int `json:"maxAttempts,omitempty"` - AutoUnlockMinutes int `json:"autoUnlockMinutes,omitempty"` + MaxAttempts *int `json:"maxAttempts,omitempty"` + AutoUnlockMinutes *int `json:"autoUnlockMinutes,omitempty"` ShowLockoutFailures bool `json:"showLockoutFailures,omitempty"` } `json:"lockout,omitempty"` } @@ -113,7 +113,7 @@ type Recovery struct { Status string `json:"status,omitempty"` Properties struct { Complexity struct { - MinLength int `json:"minLength,omitempty"` + MinLength *int `json:"minLength,omitempty"` } `json:"complexity,omitempty"` } `json:"properties,omitempty"` } `json:"recovery_question,omitempty"` diff --git a/vendor/github.com/articulate/oktasdk-go/okta/utils.go b/vendor/github.com/articulate/oktasdk-go/okta/utils.go new file mode 100644 index 00000000..1f233f40 --- /dev/null +++ b/vendor/github.com/articulate/oktasdk-go/okta/utils.go @@ -0,0 +1,5 @@ +package okta + +func intPtr(i int) *int { + return &i +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 7c981902..e5340ebb 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -14,7 +14,7 @@ github.com/apparentlymart/go-cidr/cidr github.com/apparentlymart/go-textseg/textseg # github.com/armon/go-radix v1.0.0 github.com/armon/go-radix -# github.com/articulate/oktasdk-go v0.0.0-20190417182045-e41ed7befc56 +# github.com/articulate/oktasdk-go v1.0.1 github.com/articulate/oktasdk-go/okta # github.com/aws/aws-sdk-go v1.23.16 github.com/aws/aws-sdk-go/aws