@@ -18,7 +18,7 @@ func TestAccTFEHYOKConfiguration_basic(t *testing.T) {
18
18
t .Skip ("Test skipped: HYOK_ORGANIZATION_NAME environment variable is not set" )
19
19
}
20
20
21
- hyok := & tfe.HYOKConfiguration {}
21
+ state := & tfe.HYOKConfiguration {}
22
22
23
23
// With AWS OIDC configuration
24
24
resource .Test (t , resource.TestCase {
@@ -28,7 +28,7 @@ func TestAccTFEHYOKConfiguration_basic(t *testing.T) {
28
28
{
29
29
Config : testAccTFEAWSHYOKConfigurationConfig (orgName , "apple" , "arn:aws:kms:us-east-1:123456789012:key/key1" , "us-east-1" ),
30
30
Check : resource .ComposeAggregateTestCheckFunc (
31
- testAccCheckTFEHYOKConfigurationExists ("tfe_hyok_configuration.hyok" , hyok ),
31
+ testAccCheckTFEHYOKConfigurationExists ("tfe_hyok_configuration.hyok" , state ),
32
32
resource .TestCheckResourceAttrSet ("tfe_hyok_configuration.hyok" , "id" ),
33
33
resource .TestCheckResourceAttrSet ("tfe_hyok_configuration.hyok" , "aws_oidc_configuration_id" ),
34
34
resource .TestCheckResourceAttr ("tfe_hyok_configuration.hyok" , "name" , "apple" ),
@@ -55,7 +55,7 @@ func TestAccTFEHYOKConfiguration_basic(t *testing.T) {
55
55
},
56
56
// Delete - must first revoke configuration to avoid dangling resources
57
57
{
58
- PreConfig : func () { revokeHYOKConfiguration (t , hyok .ID ) },
58
+ PreConfig : func () { revokeHYOKConfiguration (t , state .ID ) },
59
59
Config : testAccTFEHYOKConfigurationDestroyConfig (orgName ),
60
60
},
61
61
},
@@ -69,7 +69,7 @@ func TestAccTFEHYOKConfiguration_basic(t *testing.T) {
69
69
{
70
70
Config : testAccTFEVaultHYOKConfigurationConfig (orgName , "peach" , "key1" ),
71
71
Check : resource .ComposeAggregateTestCheckFunc (
72
- testAccCheckTFEHYOKConfigurationExists ("tfe_hyok_configuration.hyok" , hyok ),
72
+ testAccCheckTFEHYOKConfigurationExists ("tfe_hyok_configuration.hyok" , state ),
73
73
resource .TestCheckResourceAttrSet ("tfe_hyok_configuration.hyok" , "id" ),
74
74
resource .TestCheckResourceAttrSet ("tfe_hyok_configuration.hyok" , "vault_oidc_configuration_id" ),
75
75
resource .TestCheckResourceAttr ("tfe_hyok_configuration.hyok" , "name" , "peach" ),
@@ -94,7 +94,7 @@ func TestAccTFEHYOKConfiguration_basic(t *testing.T) {
94
94
},
95
95
// Delete - must first revoke configuration to avoid dangling resources
96
96
{
97
- PreConfig : func () { revokeHYOKConfiguration (t , hyok .ID ) },
97
+ PreConfig : func () { revokeHYOKConfiguration (t , state .ID ) },
98
98
Config : testAccTFEHYOKConfigurationDestroyConfig (orgName ),
99
99
},
100
100
},
@@ -108,7 +108,7 @@ func TestAccTFEHYOKConfiguration_basic(t *testing.T) {
108
108
{
109
109
Config : testAccTFEGCPHYOKConfigurationConfig (orgName , "cucumber" , "key1" , "global" , "key-ring-1" ),
110
110
Check : resource .ComposeAggregateTestCheckFunc (
111
- testAccCheckTFEHYOKConfigurationExists ("tfe_hyok_configuration.hyok" , hyok ),
111
+ testAccCheckTFEHYOKConfigurationExists ("tfe_hyok_configuration.hyok" , state ),
112
112
resource .TestCheckResourceAttrSet ("tfe_hyok_configuration.hyok" , "id" ),
113
113
resource .TestCheckResourceAttrSet ("tfe_hyok_configuration.hyok" , "gcp_oidc_configuration_id" ),
114
114
resource .TestCheckResourceAttr ("tfe_hyok_configuration.hyok" , "name" , "cucumber" ),
@@ -127,7 +127,7 @@ func TestAccTFEHYOKConfiguration_basic(t *testing.T) {
127
127
{
128
128
Config : testAccTFEGCPHYOKConfigurationConfig (orgName , "tomato" , "key2" , "global" , "key-ring-2" ),
129
129
Check : resource .ComposeAggregateTestCheckFunc (
130
- testAccCheckTFEHYOKConfigurationExists ("tfe_hyok_configuration.hyok" , hyok ),
130
+ testAccCheckTFEHYOKConfigurationExists ("tfe_hyok_configuration.hyok" , state ),
131
131
resource .TestCheckResourceAttrSet ("tfe_hyok_configuration.hyok" , "id" ),
132
132
resource .TestCheckResourceAttrSet ("tfe_hyok_configuration.hyok" , "gcp_oidc_configuration_id" ),
133
133
resource .TestCheckResourceAttr ("tfe_hyok_configuration.hyok" , "name" , "tomato" ),
@@ -138,7 +138,7 @@ func TestAccTFEHYOKConfiguration_basic(t *testing.T) {
138
138
},
139
139
// Delete - must first revoke configuration to avoid dangling resources
140
140
{
141
- PreConfig : func () { revokeHYOKConfiguration (t , hyok .ID ) },
141
+ PreConfig : func () { revokeHYOKConfiguration (t , state .ID ) },
142
142
Config : testAccTFEHYOKConfigurationDestroyConfig (orgName ),
143
143
},
144
144
},
@@ -152,7 +152,7 @@ func TestAccTFEHYOKConfiguration_basic(t *testing.T) {
152
152
{
153
153
Config : testAccTFEAzureHYOKConfigurationConfig (orgName , "banana" , "https://random.vault.azure.net/keys/key1" ),
154
154
Check : resource .ComposeAggregateTestCheckFunc (
155
- testAccCheckTFEHYOKConfigurationExists ("tfe_hyok_configuration.hyok" , hyok ),
155
+ testAccCheckTFEHYOKConfigurationExists ("tfe_hyok_configuration.hyok" , state ),
156
156
resource .TestCheckResourceAttrSet ("tfe_hyok_configuration.hyok" , "id" ),
157
157
resource .TestCheckResourceAttrSet ("tfe_hyok_configuration.hyok" , "azure_oidc_configuration_id" ),
158
158
resource .TestCheckResourceAttr ("tfe_hyok_configuration.hyok" , "name" , "banana" ),
@@ -177,7 +177,7 @@ func TestAccTFEHYOKConfiguration_basic(t *testing.T) {
177
177
},
178
178
// Delete - must first revoke configuration to avoid dangling resources
179
179
{
180
- PreConfig : func () { revokeHYOKConfiguration (t , hyok .ID ) },
180
+ PreConfig : func () { revokeHYOKConfiguration (t , state .ID ) },
181
181
Config : testAccTFEHYOKConfigurationDestroyConfig (orgName ),
182
182
},
183
183
},
@@ -189,6 +189,19 @@ func revokeHYOKConfiguration(t *testing.T, id string) {
189
189
if err != nil {
190
190
t .Fatalf ("failed to revoke HYOK configuration: %v" , err )
191
191
}
192
+
193
+ // Wait for configuration to be in the revoked status
194
+ _ , err = retryFn (10 , 1 , func () (any , error ) {
195
+ hyok , err := testAccConfiguredClient .Client .HYOKConfigurations .Read (ctx , id , nil )
196
+ if err != nil {
197
+ t .Fatalf ("failed to read HYOK configuration: %v" , err )
198
+ }
199
+
200
+ if hyok .Status != tfe .HYOKConfigurationRevoked {
201
+ return nil , fmt .Errorf ("expected HYOK configuration to be revoked, got %s" , hyok .Status )
202
+ }
203
+ return nil , nil
204
+ })
192
205
}
193
206
194
207
func testAccCheckTFEHYOKConfigurationExists (n string , hyokConfig * tfe.HYOKConfiguration ) resource.TestCheckFunc {
0 commit comments