@@ -6,10 +6,14 @@ import (
66	"os" 
77	"testing" 
88
9+ 	"github.com/IBM/go-sdk-core/core" 
910	"github.com/gruntwork-io/terratest/modules/logger" 
1011	"github.com/gruntwork-io/terratest/modules/terraform" 
1112	"github.com/stretchr/testify/assert" 
13+ 	"github.com/stretchr/testify/require" 
14+ 	"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/cloudinfo" 
1215	"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/common" 
16+ 	"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testaddons" 
1317	"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testhelper" 
1418	"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testschematic" 
1519)
@@ -174,11 +178,11 @@ func TestPlanValidation(t *testing.T) {
174178	options .TerraformOptions .NoColor  =  true 
175179	options .TerraformOptions .Logger  =  logger .Discard 
176180	options .TerraformOptions .Vars  =  map [string ]interface {}{
177- 		"prefix" :                         options .Prefix ,
178- 		"existing_secrets_manager_crn" :   permanentResources ["secretsManagerCRN" ],
179- 		"acme_letsencrypt_private_key " :   "PRIVATE_KEY_VALUE" , // pragma: allowlist secret 
180- 		"skip_iam_authorization_policy" : true ,
181- 		"provider_visibility" :           "public" ,
181+ 		"prefix" :                       options .Prefix ,
182+ 		"existing_secrets_manager_crn" : permanentResources ["secretsManagerCRN" ],
183+ 		"acme_letsencrypt_private_key_secrets_manager_secret_crn " : permanentResources [ "acme_letsencrypt_private_key_secret_crn" ] , // pragma: allowlist secret 
184+ 		"skip_iam_authorization_policy" :                            true ,
185+ 		"provider_visibility" :                                      "public" ,
182186	}
183187
184188	// Init 
@@ -190,3 +194,60 @@ func TestPlanValidation(t *testing.T) {
190194	assert .Nil (t , planErr , "Terraform plan should not error" )
191195	assert .NotNil (t , planOutput , "Expected Terraform plan output" )
192196}
197+ 
198+ func  TestSecretManagerDefaultConfiguration (t  * testing.T ) {
199+ 	t .Parallel ()
200+ 
201+ 	options  :=  testaddons .TestAddonsOptionsDefault (& testaddons.TestAddonOptions {
202+ 		Testing :               t ,
203+ 		Prefix :                "pbsme" ,
204+ 		ResourceGroup :         resourceGroup ,
205+ 		OverrideInputMappings : core .BoolPtr (true ),
206+ 		QuietMode :             false , // Suppress logs except on failure 
207+ 	})
208+ 
209+ 	options .AddonConfig  =  cloudinfo .NewAddonConfigTerraform (
210+ 		options .Prefix ,
211+ 		"deploy-arch-secrets-manager-public-cert-engine" ,
212+ 		"fully-configurable" ,
213+ 		map [string ]interface {}{
214+ 			"prefix" : options .Prefix ,
215+ 			"acme_letsencrypt_private_key_secrets_manager_secret_crn" : permanentResources ["acme_letsencrypt_private_key_secret_crn" ], // pragma: allowlist secret 
216+ 			"secrets_manager_region" :                                  "eu-de" ,
217+ 			"secrets_manager_service_plan" :                            "__NULL__" ,
218+ 			"skip_iam_authorization_policy" :                           true ,
219+ 		},
220+ 	)
221+ 
222+ 	options .AddonConfig .Dependencies  =  []cloudinfo.AddonConfig {
223+ 		{
224+ 			OfferingName :   "deploy-arch-ibm-secrets-manager" ,
225+ 			OfferingFlavor : "fully-configurable" ,
226+ 			Inputs : map [string ]interface {}{
227+ 				"existing_secrets_manager_crn" :         permanentResources ["secretsManagerCRN" ],
228+ 				"service_plan" :                         "__NULL__" , // no plan value needed when using existing SM 
229+ 				"skip_secrets_manager_iam_auth_policy" : true ,       // since using an existing Secrets Manager instance, attempting to re-create auth policy can cause conflicts if the policy already exists 
230+ 				"secret_groups" :                        []string {}, // passing empty array for secret groups as default value is creating general group and it will cause conflicts as we are using an existing SM 
231+ 			},
232+ 			Enabled : core .BoolPtr (true ),
233+ 		},
234+ 		// // Disable target / route creation to prevent hitting quota in account 
235+ 		{
236+ 			OfferingName :   "deploy-arch-ibm-cloud-monitoring" ,
237+ 			OfferingFlavor : "fully-configurable" ,
238+ 			Inputs : map [string ]interface {}{
239+ 				"enable_metrics_routing_to_cloud_monitoring" : false ,
240+ 			},
241+ 		},
242+ 		{
243+ 			OfferingName :   "deploy-arch-ibm-activity-tracker" ,
244+ 			OfferingFlavor : "fully-configurable" ,
245+ 			Inputs : map [string ]interface {}{
246+ 				"enable_activity_tracker_event_routing_to_cloud_logs" : false ,
247+ 			},
248+ 		},
249+ 	}
250+ 
251+ 	err  :=  options .RunAddonTest ()
252+ 	require .NoError (t , err )
253+ }
0 commit comments