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

User schema #531

Merged
merged 3 commits into from
Jul 14, 2021
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
3 changes: 3 additions & 0 deletions examples/okta_group_membership/okta_group_membership.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ resource "okta_user" "test" {
resource "okta_group" "test" {
name = "testAcc_replace_with_uuid"
description = "testing, testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_group_membership" "test" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ resource "okta_user" "test" {
resource "okta_group" "test_2" {
name = "testAcc_2_replace_with_uuid"
description = "testing, testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_group_membership" "test_2" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ resource "okta_user" "test" {
resource "okta_group" "test" {
name = "testAcc_replace_with_uuid"
description = "testing, testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_group_membership" "test" {
Expand All @@ -23,6 +26,9 @@ resource "okta_group_membership" "test" {
resource "okta_group" "test_2" {
name = "testAcc_2_replace_with_uuid"
description = "testing, testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_group_membership" "test_2" {
Expand Down
3 changes: 3 additions & 0 deletions examples/okta_group_memberships/basic.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
resource "okta_group" "test" {
name = "testAcc_replace_with_uuid"
description = "testing, testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_user" "test1" {
Expand Down
3 changes: 3 additions & 0 deletions examples/okta_group_memberships/basic_removal.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
resource "okta_group" "test" {
name = "testAcc_replace_with_uuid"
description = "testing, testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_user" "test1" {
Expand Down
3 changes: 3 additions & 0 deletions examples/okta_group_memberships/basic_update.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
resource "okta_group" "test" {
name = "testAcc_replace_with_uuid"
description = "testing, testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_user" "test1" {
Expand Down
3 changes: 3 additions & 0 deletions examples/okta_group_role/basic.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
resource "okta_group" "test" {
name = "testAcc_replace_with_uuid"
description = "testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_user" "test" {
Expand Down
3 changes: 3 additions & 0 deletions examples/okta_group_role/group_targets.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
resource "okta_group" "test" {
name = "testAcc_replace_with_uuid"
description = "testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_user" "test" {
Expand Down
3 changes: 3 additions & 0 deletions examples/okta_group_role/group_targets_removed.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
resource "okta_group" "test" {
name = "testAcc_replace_with_uuid"
description = "testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_user" "test" {
Expand Down
3 changes: 3 additions & 0 deletions examples/okta_group_role/group_targets_updated.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
resource "okta_group" "test" {
name = "testAcc_replace_with_uuid"
description = "testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_user" "test" {
Expand Down
3 changes: 3 additions & 0 deletions examples/okta_group_roles/all_roles.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
resource "okta_group" "test" {
name = "testAcc_replace_with_uuid"
description = "testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_group_roles" "test" {
Expand Down
3 changes: 3 additions & 0 deletions examples/okta_group_roles/basic.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
resource "okta_group" "test" {
name = "testAcc_replace_with_uuid"
description = "testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_group_roles" "test" {
Expand Down
31 changes: 27 additions & 4 deletions examples/okta_policy_rule_signon/factor_sequence.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ data "okta_behavior" "new_city" {
}

resource "okta_network_zone" "test" {
name = "testAcc_replace_with_uuid"
type = "IP"
gateways = ["1.2.3.4/24", "2.3.4.5-2.3.4.15"]
proxies = ["2.2.3.4/24", "3.3.4.5-3.3.4.15"]
name = "testAcc_replace_with_uuid"
type = "IP"
gateways = [
"1.2.3.4/24",
"2.3.4.5-2.3.4.15"]
proxies = [
"2.2.3.4/24",
"3.3.4.5-3.3.4.15"]
depends_on = [okta_policy_rule_signon.test]
}

resource "okta_policy_rule_signon" "test" {
Expand Down Expand Up @@ -48,4 +53,22 @@ resource "okta_policy_rule_signon" "test" {
primary_criteria_factor_type = "token:hotp"
primary_criteria_provider = "CUSTOM"
}

depends_on = [
okta_factor.okta_sms,
okta_factor.okta_email,
okta_factor.hotp]
}

resource "okta_factor" "okta_sms" {
provider_id = "okta_sms"
}

resource "okta_factor" "okta_email" {
provider_id = "okta_email"
}

resource "okta_factor" "hotp" {
provider_id = "hotp"
}

3 changes: 3 additions & 0 deletions examples/okta_user/group_assigned.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
resource "okta_group" "test" {
name = "TestACC-replace_with_uuid"
description = "An acceptance test created group"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_user" "test" {
Expand Down
3 changes: 3 additions & 0 deletions examples/okta_user/group_unassigned.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
resource "okta_group" "test" {
name = "TestACC-replace_with_uuid"
description = "An acceptance test created group"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_user" "test" {
Expand Down
12 changes: 12 additions & 0 deletions examples/okta_user_group_memberships/basic.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,33 @@ resource "okta_user" "test" {
resource "okta_group" "test_1" {
name = "testAcc_1_replace_with_uuid"
description = "testing, testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_group" "test_2" {
name = "testAcc_2_replace_with_uuid"
description = "testing, testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_group" "test_3" {
name = "testAcc_3_replace_with_uuid"
description = "testing, testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_group" "test_4" {
name = "testAcc_4_replace_with_uuid"
description = "testing, testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_user_group_memberships" "test" {
Expand Down
12 changes: 12 additions & 0 deletions examples/okta_user_group_memberships/basic_removal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,33 @@ resource "okta_user" "test" {
resource "okta_group" "test_1" {
name = "testAcc_1_replace_with_uuid"
description = "testing, testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_group" "test_2" {
name = "testAcc_2_replace_with_uuid"
description = "testing, testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_group" "test_3" {
name = "testAcc_3_replace_with_uuid"
description = "testing, testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_group" "test_4" {
name = "testAcc_4_replace_with_uuid"
description = "testing, testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_user_group_memberships" "test" {
Expand Down
12 changes: 12 additions & 0 deletions examples/okta_user_group_memberships/basic_update.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,33 @@ resource "okta_user" "test" {
resource "okta_group" "test_1" {
name = "testAcc_1_replace_with_uuid"
description = "testing, testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_group" "test_2" {
name = "testAcc_2_replace_with_uuid"
description = "testing, testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_group" "test_3" {
name = "testAcc_3_replace_with_uuid"
description = "testing, testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_group" "test_4" {
name = "testAcc_4_replace_with_uuid"
description = "testing, testing"
lifecycle {
ignore_changes = [users]
}
}

resource "okta_user_group_memberships" "test" {
Expand Down
8 changes: 6 additions & 2 deletions okta/resource_okta_user_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ func resourceUserSchemaCreateOrUpdate(ctx context.Context, d *schema.ResourceDat
return diag.Errorf("failed to create user custom schema: %v", err)
}
var subschema *sdk.UserSubSchema
timer := time.NewTimer(time.Second * 3)
ticker := time.NewTicker(time.Millisecond * 500)
timer := time.NewTimer(time.Second * 30) // sometimes it takes some time to recreate user schema
ticker := time.NewTicker(time.Second)
loop:
for {
select {
Expand All @@ -124,8 +124,12 @@ loop:
case <-timer.C:
return diag.Errorf("failed to create user custom schema: no more attempts left")
case <-ticker.C:
time.Sleep(time.Second)
updated, _, err := getSupplementFromMetadata(m).UpdateCustomUserSchemaProperty(ctx, schemaUrl, d.Get("index").(string), userSubSchema(d))
if err != nil {
if strings.Contains(err.Error(), "Wait until the data clean up process finishes and then try again") {
continue
}
return diag.Errorf("failed to create user custom schema: %v", err)
}
d.SetId(d.Get("index").(string))
Expand Down
2 changes: 1 addition & 1 deletion okta/resource_okta_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func TestAccOktaUser_validRole(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testOktaUserConfigValidRole(rName),
ExpectError: regexp.MustCompile("'GROUP_ADMIN' is not a valid Okta role"),
ExpectError: regexp.MustCompile("expected value to be one of 'SUPER_ADMIN', 'ORG_ADMIN', 'API_ACCESS_MANAGEMENT_ADMIN', 'APP_ADMIN', 'USER_ADMIN', 'MOBILE_ADMIN', 'READ_ONLY_ADMIN', 'HELP_DESK_ADMIN', 'REPORT_ADMIN', 'GROUP_MEMBERSHIP_ADMIN', got 'GROUP_ADMIN'"),
},
},
})
Expand Down
5 changes: 1 addition & 4 deletions okta/user_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ var (
"array_enum": {
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Description: "Custom Subschema enumerated value of a property of type array.",
Elem: &schema.Schema{Type: schema.TypeString},
},
"array_one_of": {
Type: schema.TypeList,
ForceNew: true,
Optional: true,
Description: "array of valid JSON schemas for property type array.",
Elem: &schema.Resource{
Expand Down Expand Up @@ -63,14 +61,12 @@ var (
"enum": {
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Description: "Custom Subschema enumerated value of the property. see: developer.okta.com/docs/api/resources/schemas#user-profile-schema-property-object",
ConflictsWith: []string{"array_type"},
Elem: &schema.Schema{Type: schema.TypeString},
},
"one_of": {
Type: schema.TypeList,
ForceNew: true,
Optional: true,
Description: "Custom Subschema json schemas. see: developer.okta.com/docs/api/resources/schemas#user-profile-schema-property-object",
ConflictsWith: []string{"array_type"},
Expand Down Expand Up @@ -107,6 +103,7 @@ var (
Description: "Subschema unique restriction",
ValidateDiagFunc: elemInSlice([]string{"UNIQUE_VALIDATED", "NOT_UNIQUE"}),
ConflictsWith: []string{"one_of", "enum", "array_type"},
ForceNew: true,
},
}

Expand Down