Skip to content

Commit 8ba55cf

Browse files
Terraform Team AutomationjiaqchenO
authored andcommitted
Added - management resource for masking policy health report in Data Safe
1 parent d7c5674 commit 8ba55cf

File tree

5 files changed

+531
-1
lines changed

5 files changed

+531
-1
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
variable "tenancy_ocid" {}
5+
variable "user_ocid" {}
6+
variable "fingerprint" {}
7+
variable "private_key_path" {}
8+
variable "region" {}
9+
variable "data_safe_target_ocid" {}
10+
variable "data_safe_masking_policy_id" {}
11+
12+
provider "oci" {
13+
tenancy_ocid = var.tenancy_ocid
14+
user_ocid = var.user_ocid
15+
fingerprint = var.fingerprint
16+
private_key_path = var.private_key_path
17+
region = var.region
18+
}
19+
20+
21+
resource "oci_data_safe_masking_policy_health_report_management" "test_health_report" {
22+
#Required
23+
target_id = var.data_safe_target_ocid
24+
masking_policy_id = var.data_safe_masking_policy_id
25+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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

Comments
 (0)