|
| 1 | +package integrationtest |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + "testing" |
| 6 | + |
| 7 | + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" |
| 8 | + "github.com/oracle/terraform-provider-oci/httpreplay" |
| 9 | + "github.com/oracle/terraform-provider-oci/internal/acctest" |
| 10 | + "github.com/oracle/terraform-provider-oci/internal/utils" |
| 11 | +) |
| 12 | + |
| 13 | +var ( |
| 14 | + DataSafeMaskingPolicyHealthReportManagementResourceConfig = acctest.GenerateResourceFromRepresentationMap("oci_data_safe_masking_policy_health_report_management", "test_masking_policy_health_report_management", acctest.Optional, acctest.Create, DataSafeMaskingPolicyHealthReportManagementRepresentation) |
| 15 | + |
| 16 | + ignoreMaskPolicyHealthReportSystemTagsChangesRep = map[string]interface{}{ |
| 17 | + "ignore_changes": acctest.Representation{RepType: acctest.Required, Create: []string{`defined_tags`}}, |
| 18 | + } |
| 19 | + |
| 20 | + DataSafeMaskingPolicyHealthReportManagementRepresentation = map[string]interface{}{ |
| 21 | + "target_id": acctest.Representation{RepType: acctest.Required, Create: `${var.target_id}`}, |
| 22 | + "masking_policy_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.masking_policy_id}`}, |
| 23 | + "lifecycle": acctest.RepresentationGroup{RepType: acctest.Required, Group: ignoreMaskPolicyHealthReportSystemTagsChangesRep}, |
| 24 | + } |
| 25 | +) |
| 26 | + |
| 27 | +func TestDataSafeMaskingPolicyHealthReportManagementResource_basic(t *testing.T) { |
| 28 | + httpreplay.SetScenario("TestDataSafeMaskingPolicyHealthReportManagementResource_basic") |
| 29 | + defer httpreplay.SaveScenario() |
| 30 | + |
| 31 | + config := acctest.ProviderTestConfig() |
| 32 | + |
| 33 | + compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid") |
| 34 | + compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId) |
| 35 | + |
| 36 | + targetId := utils.GetEnvSettingWithBlankDefault("data_safe_target_ocid") |
| 37 | + targetIdVariableStr := fmt.Sprintf("variable \"target_id\" { default = \"%s\" }\n", targetId) |
| 38 | + |
| 39 | + maskingPolicyId := utils.GetEnvSettingWithBlankDefault("data_safe_masking_policy_id") |
| 40 | + maskingPolicyIdVariableStr := fmt.Sprintf("variable \"masking_policy_id\" { default = \"%s\" }\n", maskingPolicyId) |
| 41 | + |
| 42 | + resourceName := "oci_data_safe_masking_policy_health_report_management.test_masking_policy_health_report_management" |
| 43 | + |
| 44 | + acctest.ResourceTest(t, nil, []resource.TestStep{ |
| 45 | + { |
| 46 | + Config: config + compartmentIdVariableStr + maskingPolicyIdVariableStr + targetIdVariableStr + |
| 47 | + acctest.GenerateResourceFromRepresentationMap("oci_data_safe_masking_policy_health_report_management", "test_masking_policy_health_report_management", acctest.Optional, acctest.Create, DataSafeMaskingPolicyHealthReportManagementRepresentation), |
| 48 | + Check: acctest.ComposeAggregateTestCheckFuncWrapper( |
| 49 | + |
| 50 | + resource.TestCheckResourceAttrSet(resourceName, "id"), |
| 51 | + resource.TestCheckResourceAttr(resourceName, "target_id", targetId), |
| 52 | + resource.TestCheckResourceAttr(resourceName, "masking_policy_id", maskingPolicyId), |
| 53 | + resource.TestCheckResourceAttrSet(resourceName, "compartment_id"), |
| 54 | + resource.TestCheckResourceAttrSet(resourceName, "display_name"), |
| 55 | + ), |
| 56 | + }, |
| 57 | + }) |
| 58 | +} |
0 commit comments