Skip to content

Commit 12e69ba

Browse files
committed
unit test
1 parent c74e9d2 commit 12e69ba

File tree

3 files changed

+75
-2
lines changed

3 files changed

+75
-2
lines changed

solutions/fully-configurable/provider.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ provider "ibm" {
1010
region = local.kms_region
1111
visibility = var.provider_visibility
1212
}
13-

solutions/fully-configurable/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
variable "existing_resource_group_name" {
66
type = string
77
description = "The name of an existing resource group to provision the resources."
8+
default = "Default"
89
}
910

1011
variable "ibmcloud_api_key" {

tests/pr_test.go

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ import (
2424

2525
const completeExampleDir = "examples/complete"
2626
const fsExampleDir = "examples/fscloud"
27-
const solutionDADir = "solutions/standard"
27+
const solutionDADir = "solutions/security-enforced"
28+
const fullyConfigurableDADir = "solutions/fully-configurable"
2829

2930
// Use existing group for tests
3031
const resourceGroup = "geretain-test-event-notifications"
@@ -166,6 +167,78 @@ func TestDAInSchematics(t *testing.T) {
166167
assert.Nil(t, err, "This should not have errored")
167168
}
168169

170+
func TestFullyConfigurableDAInSchematics(t *testing.T) {
171+
t.Parallel()
172+
173+
var region = validRegions[rand.Intn(len(validRegions))]
174+
175+
options := testschematic.TestSchematicOptionsDefault(&testschematic.TestSchematicOptions{
176+
Testing: t,
177+
Prefix: "en-da",
178+
TarIncludePatterns: []string{
179+
"*.tf",
180+
fullyConfigurableDADir + "/*.tf",
181+
},
182+
TemplateFolder: fullyConfigurableDADir,
183+
Tags: []string{"test-schematic"},
184+
DeleteWorkspaceOnFail: false,
185+
WaitJobCompleteMinutes: 60,
186+
})
187+
188+
serviceCredentialSecrets := []map[string]interface{}{
189+
{
190+
"secret_group_name": fmt.Sprintf("%s-secret-group", options.Prefix),
191+
"service_credentials": []map[string]string{
192+
{
193+
"secret_name": fmt.Sprintf("%s-cred-reader", options.Prefix),
194+
"service_credentials_source_service_role_crn": "crn:v1:bluemix:public:iam::::serviceRole:Reader",
195+
},
196+
{
197+
"secret_name": fmt.Sprintf("%s-cred-writer", options.Prefix),
198+
"service_credentials_source_service_role_crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer",
199+
},
200+
{
201+
"secret_name": fmt.Sprintf("%s-cred-editor", options.Prefix),
202+
"service_credentials_source_service_role_crn": "crn:v1:bluemix:public:iam::::role:Editor",
203+
},
204+
},
205+
},
206+
}
207+
208+
serviceCredentialNames := map[string]string{
209+
"admin": "Manager",
210+
"user1": "Writer",
211+
"user2": "Reader",
212+
}
213+
214+
serviceCredentialNamesJSON, err := json.Marshal(serviceCredentialNames)
215+
if err != nil {
216+
log.Fatalf("Error converting to JSON: %s", err)
217+
}
218+
219+
options.TerraformVars = []testschematic.TestSchematicTerraformVar{
220+
{Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true},
221+
{Name: "region", Value: region, DataType: "string"},
222+
{Name: "existing_resource_group_name", Value: permanentResources["general_test_storage_cos_instance_resource_group"], DataType: "string"},
223+
224+
{Name: "key_management_service_encryption_enabled", Value: true, DataType: "bool"},
225+
{Name: "existing_key_management_service_instance_crn", Value: permanentResources["hpcs_south_crn"], DataType: "string"},
226+
{Name: "key_management_service_endpoint_url", Value: permanentResources["hpcs_south_private_endpoint"], DataType: "string"},
227+
228+
{Name: "cloud_object_storage_integration_enabled", Value: true, DataType: "bool"},
229+
{Name: "existing_cloud_object_storage_instance_crn", Value: permanentResources["general_test_storage_cos_instance_crn"], DataType: "string"},
230+
{Name: "existing_cloud_object_storage_endpoint", Value: "https://s3.direct.us-south.cloud-object-storage.appdomain.cloud", DataType: "string"},
231+
{Name: "cloud_object_storage_bucket_region", Value: "us-south", DataType: "string"},
232+
233+
{Name: "existing_secrets_manager_instance_crn", Value: permanentResources["secretsManagerCRN"], DataType: "string"},
234+
{Name: "service_credential_secrets", Value: serviceCredentialSecrets, DataType: "list(object)"},
235+
{Name: "service_credential_names", Value: string(serviceCredentialNamesJSON), DataType: "map(string)"},
236+
}
237+
238+
err = options.RunSchematicTest()
239+
assert.Nil(t, err, "This should not have errored")
240+
}
241+
169242
func TestFSCloudInSchematics(t *testing.T) {
170243
t.Parallel()
171244

0 commit comments

Comments
 (0)