Skip to content

Commit 0985d6a

Browse files
neverdreamsdshelbyo
authored andcommitted
fix test issue TOP-147 - Identity test failing in orchestration because of missing compartment_id.
Squashed commit of the following: commit fd8d773b9312f97d6c2e576ddfc4d636c1e7c042 Author: Yuanshu Yun <[email protected]> Date: Thu Nov 29 15:41:47 2018 -0800 fix test issue TOP-147 - Identity test failing in orchestration because of missing compartment_id.
1 parent 8cfa208 commit 0985d6a

14 files changed

+61
-22
lines changed

oci/identity_api_key_resource_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func (s *ResourceIdentityAPIKeyTestSuite) SetupTest() {
4848
resource "oci_identity_user" "t" {
4949
name = "{{.token}}"
5050
description = "automated test user"
51+
compartment_id = "${var.tenancy_ocid}"
5152
}`, nil)
5253
s.ResourceName = "oci_identity_api_key.t"
5354
}

oci/identity_api_keys_data_source_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func (s *DatasourceIdentityAPIKeysTestSuite) SetupTest() {
2727
resource "oci_identity_user" "t" {
2828
name = "{{.userName}}"
2929
description = "automated test user"
30+
compartment_id = "${var.tenancy_ocid}"
3031
}
3132
3233
resource "oci_identity_api_key" "t" {

oci/identity_group_resource_test.go

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
package provider
44

55
import (
6+
"os"
67
"regexp"
8+
"strings"
79
"testing"
810

911
"github.com/hashicorp/terraform/helper/resource"
@@ -63,11 +65,7 @@ func (s *ResourceIdentityGroupTestSuite) TestAccResourceIdentityGroup_basic() {
6365
},
6466
// verify create w/o compartment, verify that it defaults to tenancy
6567
{
66-
Config: s.Config + tokenFn(`
67-
resource "oci_identity_group" "t" {
68-
name = "{{.token}}"
69-
description = "tf test group"
70-
}`, nil),
68+
Config: s.Config + tokenFn(identityGroupTestStepConfigFn("tf test group"), nil),
7169
Check: resource.ComposeAggregateTestCheckFunc(
7270
resource.TestCheckResourceAttr(s.ResourceName, "compartment_id", getEnvSettingWithBlankDefault("tenancy_ocid")),
7371
resource.TestCheckResourceAttr(s.ResourceName, "name", token),
@@ -83,11 +81,7 @@ func (s *ResourceIdentityGroupTestSuite) TestAccResourceIdentityGroup_basic() {
8381
},
8482
// verify update
8583
{
86-
Config: s.Config + tokenFn(`
87-
resource "oci_identity_group" "t" {
88-
name = "{{.token}}"
89-
description = "tf test group (updated)"
90-
}`, nil),
84+
Config: s.Config + tokenFn(identityGroupTestStepConfigFn("tf test group (updated)"), nil),
9185
Check: resource.ComposeAggregateTestCheckFunc(
9286
resource.TestCheckResourceAttr(s.ResourceName, "description", "tf test group (updated)"),
9387
resource.TestCheckResourceAttrSet(s.ResourceName, "compartment_id"),
@@ -108,6 +102,24 @@ func (s *ResourceIdentityGroupTestSuite) TestAccResourceIdentityGroup_basic() {
108102
})
109103
}
110104

105+
func identityGroupTestStepConfigFn(description string) string {
106+
useDelegationToken := strings.EqualFold(os.Getenv("DELEGATION_TOKEN"), "true")
107+
if useDelegationToken {
108+
return fmt.Sprintf(`
109+
resource "oci_identity_group" "t" {
110+
name = "{{.token}}"
111+
description = "%s"
112+
compartment_id = "${var.tenancy_ocid}"
113+
}`, description)
114+
}
115+
116+
return fmt.Sprintf(`
117+
resource "oci_identity_group" "t" {
118+
name = "{{.token}}"
119+
description = "%s"
120+
}`, description)
121+
}
122+
111123
func TestResourceIdentityGroupTestSuite(t *testing.T) {
112124
suite.Run(t, new(ResourceIdentityGroupTestSuite))
113125
}

oci/identity_groups_data_source_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func (s *DatasourceIdentityGroupsTestSuite) SetupTest() {
2929
resource "oci_identity_group" "t" {
3030
name = "{{.token}}"
3131
description = "automated test group"
32+
compartment_id = "${var.tenancy_ocid}"
3233
}`, nil)
3334
s.ResourceName = "data.oci_identity_groups.t"
3435
}

oci/identity_policies_data_source_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ func (s *DatasourceIdentityPolicyTestSuite) SetupTest() {
2828
resource "oci_identity_compartment" "t" {
2929
name = "-tf-compartment"
3030
description = "tf test compartment"
31+
compartment_id = "${var.tenancy_ocid}"
3132
}
3233
3334
resource "oci_identity_group" "t" {
3435
name = "{{.token}}"
3536
description = "automated test group"
37+
compartment_id = "${var.tenancy_ocid}"
3638
}
3739
3840
resource "oci_identity_policy" "p" {

oci/identity_policy_resource_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ func (s *ResourceIdentityPolicyTestSuite) SetupTest() {
3030
resource "oci_identity_compartment" "t" {
3131
name = "-tf-compartment"
3232
description = "tf test compartment"
33+
compartment_id = "${var.tenancy_ocid}"
3334
}
3435
3536
resource "oci_identity_group" "t" {
3637
name = "{{.token}}"
3738
description = "automated test group"
39+
compartment_id = "${var.tenancy_ocid}"
3840
}`, nil)
3941
s.ResourceName = "oci_identity_policy.p"
4042
}

oci/identity_policy_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ var (
3939
resource "oci_identity_compartment" "t" {
4040
name = "Network"
4141
description = "For network components"
42+
compartment_id = "${var.tenancy_ocid}"
4243
}
4344
4445
resource "oci_identity_group" "t" {

oci/identity_swift_password_resource_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ func (s *ResourceIdentitySwiftPasswordTestSuite) SetupTest() {
2828
resource "oci_identity_user" "t" {
2929
name = "{{.token}}"
3030
description = "tf test user"
31+
compartment_id = "${var.tenancy_ocid}"
3132
}
3233
resource "oci_identity_user" "t2" {
3334
name = "{{.token}}2"
3435
description = "tf test user 2"
36+
compartment_id = "${var.tenancy_ocid}"
3537
}`, nil)
3638

3739
s.ResourceName = "oci_identity_swift_password.t"

oci/identity_swift_passwords_data_source_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func (s *DatasourceIdentitySwiftPasswordsTestSuite) SetupTest() {
2727
resource "oci_identity_user" "t" {
2828
name = "{{.token}}"
2929
description = "tf test user"
30+
compartment_id = "${var.tenancy_ocid}"
3031
}
3132
resource "oci_identity_swift_password" "t" {
3233
user_id = "${oci_identity_user.t.id}"

oci/identity_ui_password_resource_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func (s *ResourceIdentityUIPasswordTestSuite) SetupTest() {
2727
resource "oci_identity_user" "t" {
2828
name = "-tf-user"
2929
description = "tf test user"
30+
compartment_id = "${var.tenancy_ocid}"
3031
}`, nil)
3132

3233
s.ResourceName = "oci_identity_ui_password.t"

0 commit comments

Comments
 (0)