Skip to content

Commit

Permalink
Clean up, specific PR test, and example config for @jakezarobsky-8451'…
Browse files Browse the repository at this point in the history
…s PR #1366

Closes #1366
  • Loading branch information
monde committed Nov 17, 2022
1 parent d880b39 commit a9c7948
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 12 deletions.
1 change: 1 addition & 0 deletions examples/okta_app_bookmark/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ App. [See Okta documentation for more details](https://developer.okta.com/docs/a

- Example of an app with a group association [can be found here](./basic.tf)
- Example of an app with a user association [can be found here](./basic_updated.tf)
- Example of an app with a authentication policy [can be found here](./app_with_authentication_policy.tf)
23 changes: 23 additions & 0 deletions examples/okta_app_bookmark/app_with_authentication_policy.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
resource "okta_group" "group" {
name = "testAcc_replace_with_uuid"
}

data "okta_policy" "test" {
name = "Any two factors"
type = "ACCESS_POLICY"
}

resource "okta_app_signon_policy" "test" {
name = "testAcc_Policy_replace_with_uuid"
description = "Sign On Policy"
depends_on = [
data.okta_policy.test
]
}

resource "okta_app_bookmark" "test" {
label = "testAcc_replace_with_uuid"
url = "https://test.com"
groups = [okta_group.group.id]
authentication_policy = okta_app_signon_policy.test.id
}
7 changes: 3 additions & 4 deletions examples/okta_app_bookmark/basic.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ resource "okta_group" "group" {
}

resource "okta_app_bookmark" "test" {
label = "testAcc_replace_with_uuid"
url = "https://test.com"
authentication_policy = "some-authentication-policy-id"
groups = [okta_group.group.id]
label = "testAcc_replace_with_uuid"
url = "https://test.com"
groups = [okta_group.group.id]
}
9 changes: 4 additions & 5 deletions examples/okta_app_bookmark/basic_updated.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ resource "okta_group" "group" {
}

resource "okta_app_bookmark" "test" {
label = "testAcc_replace_with_uuid"
url = "https://test.com"
authentication_policy = "some-authentication-policy-id"
groups = [okta_group.group.id]

label = "testAcc_replace_with_uuid"
url = "https://test.com"

users {
id = okta_user.user.id
username = okta_user.user.email
}

groups = [okta_group.group.id]
}
66 changes: 63 additions & 3 deletions okta/resource_okta_app_bookmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestAccAppBookmarkApplication_crud(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "url", "https://test.com"),
resource.TestCheckResourceAttr(resourceName, "groups.#", "1"),
resource.TestCheckResourceAttrSet(resourceName, "logo_url"),
resource.TestCheckResourceAttr(resourceName, "authentication_policy", "some-authentication-policy-id"),
resource.TestCheckResourceAttrSet(resourceName, "authentication_policy"),
),
},
{
Expand All @@ -43,7 +43,7 @@ func TestAccAppBookmarkApplication_crud(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "url", "https://test.com"),
resource.TestCheckResourceAttr(resourceName, "users.#", "1"),
resource.TestCheckResourceAttrSet(resourceName, "logo_url"),
resource.TestCheckResourceAttr(resourceName, "authentication_policy", "some-authentication-policy-id"),
resource.TestCheckResourceAttrSet(resourceName, "authentication_policy"),
),
},
},
Expand All @@ -58,7 +58,6 @@ func TestAccAppBookmarkApplication_timeouts(t *testing.T) {
resource "okta_app_bookmark" "test" {
label = "testAcc_replace_with_uuid"
url = "https://test.com"
authentication_policy = "test_policy_id"
timeouts {
create = "60m"
read = "2h"
Expand All @@ -83,3 +82,64 @@ resource "okta_app_bookmark" "test" {
},
})
}

// TestAccAppBookmarkApplication_PR1366 Test for @jakezarobsky-8451 PR #1366
// https://github.com/okta/terraform-provider-okta/pull/1366
func TestAccAppBookmarkApplication_PR1366_authentication_policy(t *testing.T) {
ri := acctest.RandInt()
mgr := newFixtureManager(appBookmark)
resourceName := fmt.Sprintf("%s.test", appBookmark)
config := `
resource "okta_group" "group" {
name = "testAcc_replace_with_uuid"
}
data "okta_policy" "test" {
name = "Any two factors"
type = "ACCESS_POLICY"
}
resource "okta_app_signon_policy" "test" {
name = "testAcc_Policy_replace_with_uuid"
description = "Sign On Policy"
depends_on = [
data.okta_policy.test
]
}
resource "okta_user" "user" {
admin_roles = ["APP_ADMIN", "USER_ADMIN"]
first_name = "TestAcc"
last_name = "blah"
login = "testAcc-replace_with_uuid@example.com"
email = "testAcc-replace_with_uuid@example.com"
}
resource "okta_app_bookmark" "test" {
label = "testAcc_replace_with_uuid"
url = "https://test.com"
groups = [okta_group.group.id]
users {
id = okta_user.user.id
username = okta_user.user.email
}
authentication_policy = okta_app_signon_policy.test.id
}`
resource.Test(t, resource.TestCase{
PreCheck: testAccPreCheck(t),
ErrorCheck: testAccErrorChecks(t),
ProviderFactories: testAccProvidersFactories,
CheckDestroy: createCheckResourceDestroy(appBookmark, createDoesAppExist(okta.NewBookmarkApplication())),
Steps: []resource.TestStep{
{
Config: mgr.ConfigReplace(config, ri),
Check: resource.ComposeTestCheckFunc(
ensureResourceExists(resourceName, createDoesAppExist(okta.NewAutoLoginApplication())),
resource.TestCheckResourceAttr(resourceName, "label", buildResourceName(ri)),
resource.TestCheckResourceAttr(resourceName, "status", statusActive),
resource.TestCheckResourceAttr(resourceName, "url", "https://test.com"),
resource.TestCheckResourceAttr(resourceName, "groups.#", "1"),
resource.TestCheckResourceAttr(resourceName, "users.#", "1"),
resource.TestCheckResourceAttrSet(resourceName, "logo_url"),
resource.TestCheckResourceAttrSet(resourceName, "authentication_policy"),
),
},
},
})
}

0 comments on commit a9c7948

Please sign in to comment.