|
| 1 | +// ---------------------------------------------------------------------------- |
| 2 | +// |
| 3 | +// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** |
| 4 | +// |
| 5 | +// ---------------------------------------------------------------------------- |
| 6 | +// |
| 7 | +// This file is automatically generated by Magic Modules and manual |
| 8 | +// changes will be clobbered when the file is regenerated. |
| 9 | +// |
| 10 | +// Please read more about how to change this file in |
| 11 | +// .github/CONTRIBUTING.md. |
| 12 | +// |
| 13 | +// ---------------------------------------------------------------------------- |
| 14 | + |
| 15 | +package google |
| 16 | + |
| 17 | +import ( |
| 18 | + "fmt" |
| 19 | + "testing" |
| 20 | + |
| 21 | + "github.com/hashicorp/terraform/helper/acctest" |
| 22 | + "github.com/hashicorp/terraform/helper/resource" |
| 23 | +) |
| 24 | + |
| 25 | +func TestAccRuntimeconfigConfigIamBindingGenerated(t *testing.T) { |
| 26 | + t.Parallel() |
| 27 | + |
| 28 | + context := map[string]interface{}{ |
| 29 | + "random_suffix": acctest.RandString(10), |
| 30 | + "role": "roles/viewer", |
| 31 | + } |
| 32 | + |
| 33 | + resource.Test(t, resource.TestCase{ |
| 34 | + PreCheck: func() { testAccPreCheck(t) }, |
| 35 | + Providers: testAccProviders, |
| 36 | + Steps: []resource.TestStep{ |
| 37 | + { |
| 38 | + Config: testAccRuntimeconfigConfigIamBinding_basicGenerated(context), |
| 39 | + }, |
| 40 | + { |
| 41 | + ResourceName: "google_runtimeconfig_config_iam_binding.foo", |
| 42 | + ImportStateId: fmt.Sprintf("projects/%s/configs/%s roles/viewer", getTestProjectFromEnv(), fmt.Sprintf("my-config%s", context["random_suffix"])), |
| 43 | + ImportState: true, |
| 44 | + ImportStateVerify: true, |
| 45 | + }, |
| 46 | + { |
| 47 | + // Test Iam Binding update |
| 48 | + Config: testAccRuntimeconfigConfigIamBinding_updateGenerated(context), |
| 49 | + }, |
| 50 | + { |
| 51 | + ResourceName: "google_runtimeconfig_config_iam_binding.foo", |
| 52 | + ImportStateId: fmt.Sprintf("projects/%s/configs/%s roles/viewer", getTestProjectFromEnv(), fmt.Sprintf("my-config%s", context["random_suffix"])), |
| 53 | + ImportState: true, |
| 54 | + ImportStateVerify: true, |
| 55 | + }, |
| 56 | + }, |
| 57 | + }) |
| 58 | +} |
| 59 | + |
| 60 | +func TestAccRuntimeconfigConfigIamMemberGenerated(t *testing.T) { |
| 61 | + t.Parallel() |
| 62 | + |
| 63 | + context := map[string]interface{}{ |
| 64 | + "random_suffix": acctest.RandString(10), |
| 65 | + "role": "roles/viewer", |
| 66 | + } |
| 67 | + |
| 68 | + resource.Test(t, resource.TestCase{ |
| 69 | + PreCheck: func() { testAccPreCheck(t) }, |
| 70 | + Providers: testAccProviders, |
| 71 | + Steps: []resource.TestStep{ |
| 72 | + { |
| 73 | + // Test Iam Member creation (no update for member, no need to test) |
| 74 | + Config: testAccRuntimeconfigConfigIamMember_basicGenerated(context), |
| 75 | + }, |
| 76 | + { |
| 77 | + ResourceName: "google_runtimeconfig_config_iam_member.foo", |
| 78 | + ImportStateId: fmt. Sprintf( "projects/%s/configs/%s roles/viewer user:[email protected]", getTestProjectFromEnv(), fmt. Sprintf( "my-config%s", context[ "random_suffix"])), |
| 79 | + ImportState: true, |
| 80 | + ImportStateVerify: true, |
| 81 | + }, |
| 82 | + }, |
| 83 | + }) |
| 84 | +} |
| 85 | + |
| 86 | +func TestAccRuntimeconfigConfigIamPolicyGenerated(t *testing.T) { |
| 87 | + t.Parallel() |
| 88 | + |
| 89 | + context := map[string]interface{}{ |
| 90 | + "random_suffix": acctest.RandString(10), |
| 91 | + "role": "roles/viewer", |
| 92 | + } |
| 93 | + |
| 94 | + resource.Test(t, resource.TestCase{ |
| 95 | + PreCheck: func() { testAccPreCheck(t) }, |
| 96 | + Providers: testAccProviders, |
| 97 | + Steps: []resource.TestStep{ |
| 98 | + { |
| 99 | + Config: testAccRuntimeconfigConfigIamPolicy_basicGenerated(context), |
| 100 | + }, |
| 101 | + { |
| 102 | + ResourceName: "google_runtimeconfig_config_iam_policy.foo", |
| 103 | + ImportStateId: fmt.Sprintf("projects/%s/configs/%s", getTestProjectFromEnv(), fmt.Sprintf("my-config%s", context["random_suffix"])), |
| 104 | + ImportState: true, |
| 105 | + ImportStateVerify: true, |
| 106 | + }, |
| 107 | + }, |
| 108 | + }) |
| 109 | +} |
| 110 | + |
| 111 | +func testAccRuntimeconfigConfigIamMember_basicGenerated(context map[string]interface{}) string { |
| 112 | + return Nprintf(` |
| 113 | +resource "google_runtimeconfig_config" "config" { |
| 114 | + name = "my-config%{random_suffix}" |
| 115 | + description = "Runtime configuration values for my service" |
| 116 | +} |
| 117 | +
|
| 118 | +resource "google_runtimeconfig_config_iam_member" "foo" { |
| 119 | + project = "${google_runtimeconfig_config.config.project}" |
| 120 | + config = "${google_runtimeconfig_config.config.name}" |
| 121 | + role = "%{role}" |
| 122 | + |
| 123 | +} |
| 124 | +`, context) |
| 125 | +} |
| 126 | + |
| 127 | +func testAccRuntimeconfigConfigIamPolicy_basicGenerated(context map[string]interface{}) string { |
| 128 | + return Nprintf(` |
| 129 | +resource "google_runtimeconfig_config" "config" { |
| 130 | + name = "my-config%{random_suffix}" |
| 131 | + description = "Runtime configuration values for my service" |
| 132 | +} |
| 133 | +
|
| 134 | +data "google_iam_policy" "foo" { |
| 135 | + binding { |
| 136 | + role = "%{role}" |
| 137 | + members = ["user:[email protected]"] |
| 138 | + } |
| 139 | +} |
| 140 | +
|
| 141 | +resource "google_runtimeconfig_config_iam_policy" "foo" { |
| 142 | + project = "${google_runtimeconfig_config.config.project}" |
| 143 | + config = "${google_runtimeconfig_config.config.name}" |
| 144 | + policy_data = "${data.google_iam_policy.foo.policy_data}" |
| 145 | +} |
| 146 | +`, context) |
| 147 | +} |
| 148 | + |
| 149 | +func testAccRuntimeconfigConfigIamBinding_basicGenerated(context map[string]interface{}) string { |
| 150 | + return Nprintf(` |
| 151 | +resource "google_runtimeconfig_config" "config" { |
| 152 | + name = "my-config%{random_suffix}" |
| 153 | + description = "Runtime configuration values for my service" |
| 154 | +} |
| 155 | +
|
| 156 | +resource "google_runtimeconfig_config_iam_binding" "foo" { |
| 157 | + project = "${google_runtimeconfig_config.config.project}" |
| 158 | + config = "${google_runtimeconfig_config.config.name}" |
| 159 | + role = "%{role}" |
| 160 | + members = ["user:[email protected]"] |
| 161 | +} |
| 162 | +`, context) |
| 163 | +} |
| 164 | + |
| 165 | +func testAccRuntimeconfigConfigIamBinding_updateGenerated(context map[string]interface{}) string { |
| 166 | + return Nprintf(` |
| 167 | +resource "google_runtimeconfig_config" "config" { |
| 168 | + name = "my-config%{random_suffix}" |
| 169 | + description = "Runtime configuration values for my service" |
| 170 | +} |
| 171 | +
|
| 172 | +resource "google_runtimeconfig_config_iam_binding" "foo" { |
| 173 | + project = "${google_runtimeconfig_config.config.project}" |
| 174 | + config = "${google_runtimeconfig_config.config.name}" |
| 175 | + role = "%{role}" |
| 176 | + |
| 177 | +} |
| 178 | +`, context) |
| 179 | +} |
0 commit comments