@@ -63,7 +63,7 @@ resource "oci_identity_compartment" "t2" {
6363
6464resource "oci_identity_group" "t" {
6565 #Required
66- compartment_id = "${var.tenancyocid }"
66+ compartment_id = "${var.tenancy_ocid }"
6767 description = "group for policy test"
6868 name = "GroupName"
6969}
@@ -74,12 +74,8 @@ func TestIdentityPolicyResource_basic(t *testing.T) {
7474 provider := testAccProvider
7575 config := testProviderConfig ()
7676
77- tenancyOcid := getRequiredEnvSetting ("tenancy_ocid" )
78- tenancyOcidVariableStr := fmt .Sprintf ("variable \" tenancyocid\" { default = \" %s\" }\n " , tenancyOcid )
7977 compartmentId := getRequiredEnvSetting ("compartment_id_for_create" )
8078 compartmentIdVariableStr := fmt .Sprintf ("variable \" compartment_id\" { default = \" %s\" }\n " , compartmentId )
81- compartmentId2 := getRequiredEnvSetting ("compartment_id_for_update" )
82- compartmentIdVariableStr2 := fmt .Sprintf ("variable \" compartment_id\" { default = \" %s\" }\n " , compartmentId2 )
8379
8480 resourceName := "oci_identity_policy.test_policy"
8581 datasourceName := "data.oci_identity_policies.test_policies"
@@ -95,7 +91,7 @@ func TestIdentityPolicyResource_basic(t *testing.T) {
9591 {
9692 ImportState : true ,
9793 ImportStateVerify : true ,
98- Config : config + PolicyPropertyVariables + tenancyOcidVariableStr + compartmentIdVariableStr + PolicyRequiredOnlyResource ,
94+ Config : config + PolicyPropertyVariables + compartmentIdVariableStr + PolicyRequiredOnlyResource ,
9995 Check : resource .ComposeAggregateTestCheckFunc (
10096 resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
10197 resource .TestCheckResourceAttr (resourceName , "description" , "Policy for users who need to launch instances, attach volumes, manage images" ),
@@ -111,11 +107,11 @@ func TestIdentityPolicyResource_basic(t *testing.T) {
111107
112108 // delete before next create
113109 {
114- Config : config + compartmentIdVariableStr ,
110+ Config : config + compartmentIdVariableStr + PolicyResourceDependencies ,
115111 },
116112 // verify create with optionals
117113 {
118- Config : config + PolicyPropertyVariables + tenancyOcidVariableStr + compartmentIdVariableStr + PolicyResourceConfig ,
114+ Config : config + PolicyPropertyVariables + compartmentIdVariableStr + PolicyResourceConfig ,
119115 Check : resource .ComposeAggregateTestCheckFunc (
120116 resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
121117 resource .TestCheckResourceAttr (resourceName , "description" , "Policy for users who need to launch instances, attach volumes, manage images" ),
@@ -140,7 +136,7 @@ variable "policy_description" { default = "description2" }
140136variable "policy_name" { default = "LaunchInstances" }
141137variable "policy_version_date" { default = "" }
142138
143- ` + compartmentIdVariableStr + tenancyOcidVariableStr + PolicyResourceConfig ,
139+ ` + compartmentIdVariableStr + PolicyResourceConfig ,
144140 Check : resource .ComposeAggregateTestCheckFunc (
145141 resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
146142 resource .TestCheckResourceAttr (resourceName , "description" , "description2" ),
@@ -167,9 +163,9 @@ variable "policy_description" { default = "description2" }
167163variable "policy_name" { default = "name2" }
168164variable "policy_version_date" { default = "" }
169165
170- ` + compartmentIdVariableStr2 + tenancyOcidVariableStr + PolicyRecreateResource ,
166+ ` + compartmentIdVariableStr + PolicyRecreateResource ,
171167 Check : resource .ComposeAggregateTestCheckFunc (
172- resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId2 ),
168+ resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
173169 resource .TestCheckResourceAttr (resourceName , "description" , "description2" ),
174170 resource .TestCheckResourceAttrSet (resourceName , "id" ),
175171 resource .TestCheckResourceAttr (resourceName , "name" , "name2" ),
@@ -202,12 +198,12 @@ data "oci_identity_policies" "test_policies" {
202198 values = ["${oci_identity_policy.test_policy.id}"]
203199 }
204200}
205- ` + compartmentIdVariableStr2 + tenancyOcidVariableStr + PolicyRecreateResource ,
201+ ` + compartmentIdVariableStr + PolicyRecreateResource ,
206202 Check : resource .ComposeTestCheckFunc (
207- resource .TestCheckResourceAttr (datasourceName , "compartment_id" , compartmentId2 ),
203+ resource .TestCheckResourceAttr (datasourceName , "compartment_id" , compartmentId ),
208204
209205 resource .TestCheckResourceAttr (datasourceName , "policies.#" , "1" ),
210- resource .TestCheckResourceAttr (datasourceName , "policies.0.compartment_id" , compartmentId2 ),
206+ resource .TestCheckResourceAttr (datasourceName , "policies.0.compartment_id" , compartmentId ),
211207 resource .TestCheckResourceAttr (datasourceName , "policies.0.description" , "description2" ),
212208 resource .TestCheckResourceAttrSet (datasourceName , "policies.0.id" ),
213209 resource .TestCheckResourceAttr (datasourceName , "policies.0.name" , "name2" ),
@@ -224,12 +220,8 @@ func TestIdentityPolicyResource_forcenew(t *testing.T) {
224220 provider := testAccProvider
225221 config := testProviderConfig ()
226222
227- tenancyOcid := getRequiredEnvSetting ("tenancy_ocid" )
228- tenancyOcidVariableStr := fmt .Sprintf ("variable \" tenancyocid\" { default = \" %s\" }\n " , tenancyOcid )
229223 compartmentId := getRequiredEnvSetting ("compartment_id_for_create" )
230224 compartmentIdVariableStr := fmt .Sprintf ("variable \" compartment_id\" { default = \" %s\" }\n " , compartmentId )
231- compartmentId2 := getRequiredEnvSetting ("compartment_id_for_update" )
232- compartmentIdVariableStr2 := fmt .Sprintf ("variable \" compartment_id\" { default = \" %s\" }\n " , compartmentId2 )
233225
234226 resourceName := "oci_identity_policy.test_policy"
235227
@@ -242,7 +234,7 @@ func TestIdentityPolicyResource_forcenew(t *testing.T) {
242234 Steps : []resource.TestStep {
243235 // verify create with optionals
244236 {
245- Config : config + PolicyPropertyVariables + tenancyOcidVariableStr + compartmentIdVariableStr + PolicyResourceConfig ,
237+ Config : config + PolicyPropertyVariables + compartmentIdVariableStr + PolicyResourceConfig ,
246238 Check : resource .ComposeAggregateTestCheckFunc (
247239 resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
248240 resource .TestCheckResourceAttr (resourceName , "description" , "Policy for users who need to launch instances, attach volumes, manage images" ),
@@ -264,38 +256,11 @@ func TestIdentityPolicyResource_forcenew(t *testing.T) {
264256 {
265257 Config : config + `
266258variable "policy_description" { default = "Policy for users who need to launch instances, attach volumes, manage images" }
267- variable "policy_name" { default = "LaunchInstances" }
268- variable "policy_version_date" { default = "" }
269- ` + compartmentIdVariableStr2 + tenancyOcidVariableStr + PolicyRecreateResource ,
270- Check : resource .ComposeAggregateTestCheckFunc (
271- resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId2 ),
272- resource .TestCheckResourceAttr (resourceName , "description" , "Policy for users who need to launch instances, attach volumes, manage images" ),
273- resource .TestCheckResourceAttrSet (resourceName , "id" ),
274- resource .TestCheckResourceAttr (resourceName , "name" , "LaunchInstances" ),
275- resource .TestCheckResourceAttrSet (resourceName , "state" ),
276- resource .TestCheckResourceAttr (resourceName , "statements.#" , "1" ),
277- resource .TestCheckResourceAttrSet (resourceName , "time_created" ),
278- resource .TestCheckNoResourceAttr (resourceName , "version_date" ),
279-
280- func (s * terraform.State ) (err error ) {
281- resId2 , err = fromInstanceState (s , resourceName , "id" )
282- if resId == resId2 {
283- return fmt .Errorf ("Resource was expected to be recreated when updating parameter CompartmentId but the id did not change." )
284- }
285- resId = resId2
286- return err
287- },
288- ),
289- },
290-
291- {
292- Config : config + `
293- variable "policy_description" { default = "Policy for users who need to launch instances, attach volumes, manage images" }
294259variable "policy_name" { default = "name2" }
295260variable "policy_version_date" { default = "" }
296- ` + compartmentIdVariableStr2 + tenancyOcidVariableStr + PolicyRecreateResource ,
261+ ` + compartmentIdVariableStr + PolicyRecreateResource ,
297262 Check : resource .ComposeAggregateTestCheckFunc (
298- resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId2 ),
263+ resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
299264 resource .TestCheckResourceAttr (resourceName , "description" , "Policy for users who need to launch instances, attach volumes, manage images" ),
300265 resource .TestCheckResourceAttrSet (resourceName , "id" ),
301266 resource .TestCheckResourceAttr (resourceName , "name" , "name2" ),
0 commit comments