Skip to content

Commit

Permalink
Fix type casting and acceptance test data
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhung committed Nov 30, 2023
1 parent a304903 commit 07d0d62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/xray/resource_xray_operational_risk_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func resourceXrayOperationalRiskPolicy() *schema.Resource {

var criteriaDiff = func(ctx context.Context, diff *schema.ResourceDiff, v interface{}) error {
rules := diff.Get("rule").([]interface{})
rules := diff.Get("rule").(*schema.Set).List()
if len(rules) == 0 {
return nil
}
Expand Down
8 changes: 5 additions & 3 deletions pkg/xray/resource_xray_security_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func TestAccSecurityPolicy_badGracePeriod(t *testing.T) {

func TestAccSecurityPolicy_withProjectKey(t *testing.T) {
_, fqrn, resourceName := testutil.MkNames("policy-", "xray_security_policy")
projectKey := fmt.Sprintf("testproj%d", testutil.RandSelect(1, 2, 3, 4, 5))
projectKey := fmt.Sprintf("testproj%d", testutil.RandomInt())

testData := sdk.MergeMaps(testDataSecurity)
testData["resource_name"] = resourceName
Expand Down Expand Up @@ -248,7 +248,8 @@ func TestAccSecurityPolicy_createBlockDownloadTrueCVSS(t *testing.T) {

testData["resource_name"] = resourceName
testData["policy_name"] = fmt.Sprintf("terraform-security-policy-4-%d", testutil.RandomInt())
testData["rule_name"] = fmt.Sprintf("test-security-rule-4-%d", testutil.RandomInt())
testData["rule_name_1"] = fmt.Sprintf("test-security-rule-4-%d", testutil.RandomInt())
testData["rule_name_2"] = fmt.Sprintf("test-security-rule-4-%d", testutil.RandomInt())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -275,7 +276,8 @@ func TestAccSecurityPolicy_createBlockDownloadFalseCVSS(t *testing.T) {

testData["resource_name"] = resourceName
testData["policy_name"] = fmt.Sprintf("terraform-security-policy-5-%d", testutil.RandomInt())
testData["rule_name"] = fmt.Sprintf("test-security-rule-5-%d", testutil.RandomInt())
testData["rule_name_1"] = fmt.Sprintf("test-security-rule-5-%d", testutil.RandomInt())
testData["rule_name_2"] = fmt.Sprintf("test-security-rule-5-%d", testutil.RandomInt())
testData["block_unscanned"] = "false"
testData["block_active"] = "false"

Expand Down

0 comments on commit 07d0d62

Please sign in to comment.