Skip to content

Commit eba7bdd

Browse files
committed
fix permissions for local testing TestAccTFEPolicySet
1 parent b283095 commit eba7bdd

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

internal/provider/resource_tfe_policy_set_test.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package provider
55

66
import (
7+
"context"
78
"fmt"
89
"os"
910
"regexp"
@@ -60,6 +61,19 @@ func TestAccTFEPolicySet_pinnedPolicyRuntimeVersion(t *testing.T) {
6061
sha := genSentinelSha(t, "secret", "data")
6162
version := genSafeRandomSentinelVersion()
6263

64+
adminClient := testAdminClient(t, versionMaintenanceAdmin)
65+
66+
opts := tfe.AdminSentinelVersionCreateOptions{
67+
Version: version,
68+
SHA: sha,
69+
URL: "https://hashicorp.com",
70+
}
71+
72+
tool, err := adminClient.Admin.SentinelVersions.Create(context.Background(), opts)
73+
if err != nil {
74+
t.Fatal(err)
75+
}
76+
6377
org, orgCleanup := createBusinessOrganization(t, tfeClient)
6478
t.Cleanup(orgCleanup)
6579

@@ -71,7 +85,7 @@ func TestAccTFEPolicySet_pinnedPolicyRuntimeVersion(t *testing.T) {
7185
CheckDestroy: testAccCheckTFEPolicySetDestroy,
7286
Steps: []resource.TestStep{
7387
{
74-
Config: testAccTFEPolicySet_pinnedPolicyRuntimeVersion(org.Name, version, sha),
88+
Config: testAccTFEPolicySet_pinnedPolicyRuntimeVersion(org.Name, tool.Version),
7589
Check: resource.ComposeTestCheckFunc(
7690
testAccCheckTFEPolicySetExists("tfe_policy_set.foobar", policySet),
7791
testAccCheckTFEPolicySetAttributes(policySet),
@@ -1034,14 +1048,8 @@ resource "tfe_policy_set" "foobar" {
10341048
}`, organization, organization)
10351049
}
10361050

1037-
func testAccTFEPolicySet_pinnedPolicyRuntimeVersion(organization string, version string, sha string) string {
1051+
func testAccTFEPolicySet_pinnedPolicyRuntimeVersion(organization string, version string) string {
10381052
return fmt.Sprintf(`
1039-
resource "tfe_sentinel_version" "foobar" {
1040-
version = "%s"
1041-
url = "https://www.hashicorp.com"
1042-
sha = "%s"
1043-
}
1044-
10451053
resource "tfe_sentinel_policy" "foo" {
10461054
name = "policy-foo"
10471055
policy = "main = rule { true }"
@@ -1055,7 +1063,7 @@ resource "tfe_policy_set" "foobar" {
10551063
agent_enabled = true
10561064
policy_tool_version = "%s"
10571065
policy_ids = [tfe_sentinel_policy.foo.id]
1058-
}`, version, sha, organization, organization, version)
1066+
}`, organization, organization, version)
10591067
}
10601068

10611069
func testAccTFEPolicySetOPA_basic(organization string, version string, sha string) string {

0 commit comments

Comments
 (0)