|
2 | 2 | package test |
3 | 3 |
|
4 | 4 | import ( |
| 5 | + "encoding/json" |
5 | 6 | "fmt" |
6 | 7 | "log" |
7 | 8 | "math/rand" |
@@ -136,15 +137,47 @@ func TestRunSecurityEnforcedUpgradeSolutionSchematics(t *testing.T) { |
136 | 137 | CheckApplyResultForUpgrade: true, |
137 | 138 | }) |
138 | 139 |
|
| 140 | + serviceCredentialSecrets := []map[string]any{ |
| 141 | + { |
| 142 | + "secret_group_name": fmt.Sprintf("%s-secret-group", options.Prefix), |
| 143 | + "service_credentials": []map[string]string{ |
| 144 | + { |
| 145 | + "secret_name": fmt.Sprintf("%s-cred-reader", options.Prefix), |
| 146 | + "service_credentials_source_service_role_crn": "crn:v1:bluemix:public:iam::::role:Viewer", |
| 147 | + }, |
| 148 | + { |
| 149 | + "secret_name": fmt.Sprintf("%s-cred-writer", options.Prefix), |
| 150 | + "service_credentials_source_service_role_crn": "crn:v1:bluemix:public:iam::::role:Editor", |
| 151 | + }, |
| 152 | + }, |
| 153 | + }, |
| 154 | + } |
| 155 | + |
| 156 | + serviceCredentialNames := map[string]string{ |
| 157 | + "admin": "Administrator", |
| 158 | + "user1": "Viewer", |
| 159 | + "user2": "Editor", |
| 160 | + } |
| 161 | + |
| 162 | + serviceCredentialNamesJSON, err := json.Marshal(serviceCredentialNames) |
| 163 | + if err != nil { |
| 164 | + log.Fatalf("Error converting to JSON: %s", err) |
| 165 | + } |
| 166 | + |
139 | 167 | options.TerraformVars = []testschematic.TestSchematicTerraformVar{ |
140 | 168 | {Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true}, |
141 | 169 | {Name: "prefix", Value: options.Prefix, DataType: "string"}, |
142 | 170 | {Name: "deletion_protection", Value: false, DataType: "bool"}, |
143 | 171 | {Name: "existing_resource_group_name", Value: resourceGroup, DataType: "string"}, |
144 | 172 | {Name: "existing_kms_instance_crn", Value: permanentResources["hpcs_south_crn"], DataType: "string"}, |
| 173 | + {Name: "existing_secrets_manager_instance_crn", Value: permanentResources["secretsManagerCRN"], DataType: "string"}, |
| 174 | + {Name: "service_credential_secrets", Value: serviceCredentialSecrets, DataType: "list(object)"}, |
| 175 | + {Name: "service_credential_names", Value: string(serviceCredentialNamesJSON), DataType: "map(string)"}, |
| 176 | + {Name: "admin_pass_secrets_manager_secret_name", Value: options.Prefix, DataType: "string"}, |
| 177 | + {Name: "admin_pass_secrets_manager_secret_group", Value: fmt.Sprintf("mongodb-%s-admin-secrets", options.Prefix), DataType: "string"}, |
145 | 178 | } |
146 | 179 |
|
147 | | - err := options.RunSchematicUpgradeTest() |
| 180 | + err = options.RunSchematicUpgradeTest() |
148 | 181 | assert.Nil(t, err, "This should not have errored") |
149 | 182 | } |
150 | 183 |
|
|
0 commit comments