Skip to content

Commit

Permalink
Fix acceptance test TestAccOktaAppSignOnPolicyRule
Browse files Browse the repository at this point in the history
  • Loading branch information
monde committed Apr 18, 2022
1 parent 3024e82 commit 6d305cd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
20 changes: 12 additions & 8 deletions examples/okta_app_signon_policy_rule/basic_updated.tf
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,18 @@ resource "okta_app_signon_policy_rule" "test" {
os_type = "MACOS"
type = "DESKTOP"
}
platform_include {
os_type = "OTHER"
type = "DESKTOP"
}
platform_include {
os_type = "OTHER"
type = "MOBILE"
}
# FIXME Okta API for /api/v1/policies/{policyId}/rules/{ruleId}
# is not returning os_expression even when it has been set throwing off the TF state.
# platform_include {
# os_expression = ".*"
# os_type = "OTHER"
# type = "DESKTOP"
# }
# platform_include {
# os_expression = ".*"
# os_type = "OTHER"
# type = "MOBILE"
# }
platform_include {
os_type = "WINDOWS"
type = "DESKTOP"
Expand Down
5 changes: 5 additions & 0 deletions okta/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"os"
"strings"
"sync"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/okta/okta-sdk-golang/v2/okta"
Expand Down Expand Up @@ -683,6 +684,10 @@ func deleteApplication(ctx context.Context, d *schema.ResourceData, m interface{
return err
}
}
if os.Getenv("TF_ACC") != "" {
// slow down Okta API call deactivate and delete app if this is running in acceptance tests
time.Sleep(time.Second)
}
_, err := client.Application.DeleteApplication(ctx, d.Id())
return err
}
Expand Down
2 changes: 1 addition & 1 deletion okta/resource_okta_app_signon_policy_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestAccOktaAppSignOnPolicyRule(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "network_includes.#", "1"),
resource.TestCheckResourceAttr(resourceName, "network_excludes.#", "0"),
resource.TestCheckResourceAttr(resourceName, "network_connection", "ZONE"),
resource.TestCheckResourceAttr(resourceName, "platform_include.#", "6"),
resource.TestCheckResourceAttr(resourceName, "platform_include.#", "4"),
resource.TestCheckResourceAttr(resourceName, "re_authentication_frequency", "PT43800H"),
resource.TestCheckResourceAttr(resourceName, "type", "ASSURANCE"),
resource.TestCheckResourceAttr(resourceName, "constraints.#", "2"),
Expand Down

0 comments on commit 6d305cd

Please sign in to comment.