Skip to content

Commit

Permalink
test(secmaster): adjust playbook action test case (#5632)
Browse files Browse the repository at this point in the history
  • Loading branch information
luoping-12345 authored Sep 30, 2024
1 parent a76ae8b commit c0602f7
Showing 1 changed file with 46 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,14 @@ func TestAccPlaybookAction_basic(t *testing.T) {
ProviderFactories: acceptance.TestAccProviderFactories,
CheckDestroy: rc.CheckResourceDestroy(),
Steps: []resource.TestStep{
// due to service problem, action_id is fixed to "c1d3fd3d-c1ec-4e62-b8cc-c6b0d96b309b"
{
Config: testPlaybookAction_basic(name),
Check: resource.ComposeTestCheckFunc(
rc.CheckResourceExists(),
resource.TestCheckResourceAttr(rName, "workspace_id", acceptance.HW_SECMASTER_WORKSPACE_ID),
resource.TestCheckResourceAttrPair(rName, "version_id",
"huaweicloud_secmaster_playbook_version.test", "id"),
resource.TestCheckResourceAttr(rName, "action_id", "c1d3fd3d-c1ec-4e62-b8cc-c6b0d96b309b"),
resource.TestCheckResourceAttr(rName, "name", name),
resource.TestCheckResourceAttrPair(rName, "version_id", "huaweicloud_secmaster_playbook_version.test", "id"),
resource.TestCheckResourceAttrPair(rName, "action_id", "data.huaweicloud_secmaster_workflows.test", "workflows.0.id"),
resource.TestCheckResourceAttrPair(rName, "name", "data.huaweicloud_secmaster_workflows.test", "workflows.0.name"),
resource.TestCheckResourceAttr(rName, "description", "created by terraform"),
resource.TestCheckResourceAttrSet(rName, "created_at"),
resource.TestCheckResourceAttrSet(rName, "updated_at"),
Expand All @@ -96,10 +94,7 @@ func TestAccPlaybookAction_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
rc.CheckResourceExists(),
resource.TestCheckResourceAttr(rName, "workspace_id", acceptance.HW_SECMASTER_WORKSPACE_ID),
resource.TestCheckResourceAttrPair(rName, "version_id",
"huaweicloud_secmaster_playbook_version.test", "id"),
resource.TestCheckResourceAttr(rName, "action_id", "c1d3fd3d-c1ec-4e62-b8cc-c6b0d96b309b"),
resource.TestCheckResourceAttr(rName, "name", name+"_update"),
resource.TestCheckResourceAttrPair(rName, "version_id", "huaweicloud_secmaster_playbook_version.test", "id"),
resource.TestCheckResourceAttr(rName, "description", ""),
resource.TestCheckResourceAttrSet(rName, "created_at"),
resource.TestCheckResourceAttrSet(rName, "updated_at"),
Expand All @@ -117,30 +112,62 @@ func TestAccPlaybookAction_basic(t *testing.T) {

func testPlaybookAction_basic(name string) string {
return fmt.Sprintf(`
%s
%[1]s
data "huaweicloud_secmaster_data_classes" "test" {
workspace_id = "%[2]s"
}
resource "huaweicloud_secmaster_playbook_version" "test" {
workspace_id = "%[2]s"
playbook_id = huaweicloud_secmaster_playbook.test.id
dataclass_id = data.huaweicloud_secmaster_data_classes.test.data_classes[0].id
description = "created by terraform"
}
data "huaweicloud_secmaster_workflows" "test" {
workspace_id = "%[2]s"
data_class_id = data.huaweicloud_secmaster_data_classes.test.data_classes[0].id
}
resource "huaweicloud_secmaster_playbook_action" "test" {
workspace_id = "%s"
workspace_id = "%[2]s"
version_id = huaweicloud_secmaster_playbook_version.test.id
action_id = "c1d3fd3d-c1ec-4e62-b8cc-c6b0d96b309b"
name = "%s"
action_id = data.huaweicloud_secmaster_workflows.test.workflows[0].id
name = data.huaweicloud_secmaster_workflows.test.workflows[0].name
description = "created by terraform"
}
`, testPlaybookVersion_basic(name), acceptance.HW_SECMASTER_WORKSPACE_ID, name)
`, testPlaybook_basic(name), acceptance.HW_SECMASTER_WORKSPACE_ID)
}

func testPlaybookAction_basic_update(name string) string {
return fmt.Sprintf(`
%s
%[1]s
data "huaweicloud_secmaster_data_classes" "test" {
workspace_id = "%[2]s"
}
resource "huaweicloud_secmaster_playbook_version" "test" {
workspace_id = "%[2]s"
playbook_id = huaweicloud_secmaster_playbook.test.id
dataclass_id = data.huaweicloud_secmaster_data_classes.test.data_classes[0].id
description = "created by terraform"
}
data "huaweicloud_secmaster_workflows" "test" {
workspace_id = "%[2]s"
data_class_id = data.huaweicloud_secmaster_data_classes.test.data_classes[0].id
}
resource "huaweicloud_secmaster_playbook_action" "test" {
workspace_id = "%s"
workspace_id = "%[2]s"
version_id = huaweicloud_secmaster_playbook_version.test.id
action_id = "c1d3fd3d-c1ec-4e62-b8cc-c6b0d96b309b"
name = "%s_update"
action_id = data.huaweicloud_secmaster_workflows.test.workflows[0].id
name = data.huaweicloud_secmaster_workflows.test.workflows[0].name
description = ""
}
`, testPlaybookVersion_basic(name), acceptance.HW_SECMASTER_WORKSPACE_ID, name)
`, testPlaybook_basic(name), acceptance.HW_SECMASTER_WORKSPACE_ID)
}

func testPlaybookActionImportState(name string) resource.ImportStateIdFunc {
Expand Down

0 comments on commit c0602f7

Please sign in to comment.