4
4
package provider
5
5
6
6
import (
7
+ "context"
7
8
"fmt"
8
9
"os"
9
10
"regexp"
@@ -60,6 +61,19 @@ func TestAccTFEPolicySet_pinnedPolicyRuntimeVersion(t *testing.T) {
60
61
sha := genSentinelSha (t , "secret" , "data" )
61
62
version := genSafeRandomSentinelVersion ()
62
63
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
+
63
77
org , orgCleanup := createBusinessOrganization (t , tfeClient )
64
78
t .Cleanup (orgCleanup )
65
79
@@ -71,7 +85,7 @@ func TestAccTFEPolicySet_pinnedPolicyRuntimeVersion(t *testing.T) {
71
85
CheckDestroy : testAccCheckTFEPolicySetDestroy ,
72
86
Steps : []resource.TestStep {
73
87
{
74
- Config : testAccTFEPolicySet_pinnedPolicyRuntimeVersion (org .Name , version , sha ),
88
+ Config : testAccTFEPolicySet_pinnedPolicyRuntimeVersion (org .Name , tool . Version ),
75
89
Check : resource .ComposeTestCheckFunc (
76
90
testAccCheckTFEPolicySetExists ("tfe_policy_set.foobar" , policySet ),
77
91
testAccCheckTFEPolicySetAttributes (policySet ),
@@ -1034,14 +1048,8 @@ resource "tfe_policy_set" "foobar" {
1034
1048
}` , organization , organization )
1035
1049
}
1036
1050
1037
- func testAccTFEPolicySet_pinnedPolicyRuntimeVersion (organization string , version string , sha string ) string {
1051
+ func testAccTFEPolicySet_pinnedPolicyRuntimeVersion (organization string , version string ) string {
1038
1052
return fmt .Sprintf (`
1039
- resource "tfe_sentinel_version" "foobar" {
1040
- version = "%s"
1041
- url = "https://www.hashicorp.com"
1042
- sha = "%s"
1043
- }
1044
-
1045
1053
resource "tfe_sentinel_policy" "foo" {
1046
1054
name = "policy-foo"
1047
1055
policy = "main = rule { true }"
@@ -1055,7 +1063,7 @@ resource "tfe_policy_set" "foobar" {
1055
1063
agent_enabled = true
1056
1064
policy_tool_version = "%s"
1057
1065
policy_ids = [tfe_sentinel_policy.foo.id]
1058
- }` , version , sha , organization , organization , version )
1066
+ }` , organization , organization , version )
1059
1067
}
1060
1068
1061
1069
func testAccTFEPolicySetOPA_basic (organization string , version string , sha string ) string {
0 commit comments