@@ -10,6 +10,7 @@ import (
10
10
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
11
11
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
12
12
"github.com/hashicorp/terraform-plugin-testing/knownvalue"
13
+ "github.com/hashicorp/terraform-plugin-testing/plancheck"
13
14
"github.com/hashicorp/terraform-plugin-testing/statecheck"
14
15
"github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
15
16
)
@@ -117,7 +118,7 @@ resource "ovh_okms" "kms" {
117
118
resource "ovh_okms_credential" "cred" {
118
119
okms_id = ovh_okms.kms.id
119
120
name = "%[2]s"
120
- identity_urns = ["urn:v1:eu:identity:account:${data.ovh_me.current_account.nichandle} "]
121
+ identity_urns = ["%[3]s "]
121
122
}
122
123
123
124
resource "ovh_okms_credential" "credcsr" {
@@ -159,22 +160,45 @@ func getAllCredsChecks(resName string, displayName string, resNameCsr string, di
159
160
func TestAccOkmsCredCreate (t * testing.T ) {
160
161
kmsName := acctest .RandomWithPrefix (test_prefix )
161
162
credName := acctest .RandomWithPrefix (test_prefix )
163
+ oldIdUrn := "urn:v1:eu:identity:account:${data.ovh_me.current_account.nichandle}"
164
+ newIdUrn := "urn:v1:eu:identity:user:badnic-ovh/user1"
162
165
163
166
resource .Test (t , resource.TestCase {
164
167
PreCheck : func () { testAccPreCheckCredentials (t ) },
165
168
ProtoV6ProviderFactories : testAccProtoV6ProviderFactories ,
166
169
Steps : []resource.TestStep {
167
170
{
168
- Config : fmt .Sprintf (confOkmsCredTest , kmsName , credName ),
171
+ Config : fmt .Sprintf (confOkmsCredTest , kmsName , credName , oldIdUrn ),
169
172
ConfigStateChecks : getAllCredsChecks (
170
173
"ovh_okms_credential.cred" ,
171
174
credName ,
172
175
"ovh_okms_credential.credcsr" ,
173
176
credName + "csr" ),
174
177
},
178
+ {
179
+ // Test update
180
+ Config : fmt .Sprintf (confOkmsCredTest , kmsName , credName , newIdUrn ),
181
+ ConfigPlanChecks : resource.ConfigPlanChecks {
182
+ PreApply : []plancheck.PlanCheck {
183
+ plancheck .ExpectNonEmptyPlan (),
184
+ plancheck .ExpectResourceAction (
185
+ "ovh_okms_credential.cred" ,
186
+ plancheck .ResourceActionReplace ),
187
+ },
188
+ },
189
+ ConfigStateChecks : []statecheck.StateCheck {
190
+ statecheck .ExpectKnownValue (
191
+ "ovh_okms_credential.cred" ,
192
+ tfjsonpath .New ("identity_urns" ),
193
+ knownvalue .ListExact ([]knownvalue.Check {
194
+ knownvalue .StringExact (newIdUrn ),
195
+ }),
196
+ ),
197
+ },
198
+ },
175
199
{
176
200
// Test datasource
177
- Config : fmt .Sprintf (confOkmsCredTest + confOkmsDatasourceTest , kmsName , credName ),
201
+ Config : fmt .Sprintf (confOkmsCredTest + confOkmsDatasourceTest , kmsName , credName , newIdUrn ),
178
202
ConfigStateChecks : append (
179
203
kmsCredDatasourceChecks ("ovh_okms_credential.cred" , "data.ovh_okms_credential.data_cred" ),
180
204
kmsCredDatasourceChecks ("ovh_okms_credential.credcsr" , "data.ovh_okms_credential.data_credcsr" )... ,
0 commit comments