Skip to content

Commit 980ae05

Browse files
committed
feat(specs): Add spec, tests and examples for panos_correlation_log_settings
1 parent 8ac9916 commit 980ae05

File tree

4 files changed

+667
-0
lines changed

4 files changed

+667
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# A correlation log setting can be imported by providing the following base64 encoded object as the ID
2+
# {
3+
# location = {
4+
# template = {
5+
# name = "example-template"
6+
# panorama_device = "localhost.localdomain"
7+
# }
8+
# }
9+
#
10+
# name = "example-correlation-settings"
11+
# }
12+
terraform import panos_correlation_log_settings.example $(echo '{"location":{"template":{"name":"example-template","panorama_device":"localhost.localdomain"}},"name":"example-correlation-settings"}' | base64)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
resource "panos_template" "example" {
2+
location = { panorama = {} }
3+
name = "example-template"
4+
}
5+
6+
resource "panos_correlation_log_settings" "example" {
7+
location = {
8+
template = {
9+
name = panos_template.example.name
10+
}
11+
}
12+
13+
name = "example-correlation-settings"
14+
description = "correlation log settings example"
15+
filter = "(severity eq high)"
16+
quarantine = false
17+
18+
actions = [
19+
{
20+
name = "integration-action"
21+
type = {
22+
integration = {
23+
action = "Azure-Security-Center-Integration"
24+
}
25+
}
26+
}
27+
]
28+
}
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
package provider_test
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
7+
"github.com/hashicorp/terraform-plugin-testing/config"
8+
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
9+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
10+
"github.com/hashicorp/terraform-plugin-testing/knownvalue"
11+
"github.com/hashicorp/terraform-plugin-testing/statecheck"
12+
"github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
13+
)
14+
15+
func TestAccCorrelationLogSettings(t *testing.T) {
16+
t.Parallel()
17+
18+
nameSuffix := acctest.RandStringFromCharSet(6, acctest.CharSetAlphaNum)
19+
prefix := fmt.Sprintf("test-acc-%s", nameSuffix)
20+
21+
resource.Test(t, resource.TestCase{
22+
PreCheck: func() { testAccPreCheck(t) },
23+
ProtoV6ProviderFactories: testAccProviders,
24+
Steps: []resource.TestStep{
25+
{
26+
Config: correlationLogSettingsTmpl,
27+
ConfigVariables: map[string]config.Variable{
28+
"prefix": config.StringVariable(prefix),
29+
"description": config.StringVariable("test description"),
30+
"filter": config.StringVariable("(severity eq high)"),
31+
"quarantine": config.BoolVariable(false),
32+
},
33+
ConfigStateChecks: []statecheck.StateCheck{
34+
statecheck.ExpectKnownValue(
35+
"panos_correlation_log_settings.settings",
36+
tfjsonpath.New("description"),
37+
knownvalue.StringExact("test description"),
38+
),
39+
statecheck.ExpectKnownValue(
40+
"panos_correlation_log_settings.settings",
41+
tfjsonpath.New("filter"),
42+
knownvalue.StringExact("(severity eq high)"),
43+
),
44+
statecheck.ExpectKnownValue(
45+
"panos_correlation_log_settings.settings",
46+
tfjsonpath.New("quarantine"),
47+
knownvalue.Bool(false),
48+
),
49+
},
50+
},
51+
{
52+
Config: correlationLogSettingsTmpl,
53+
ConfigVariables: map[string]config.Variable{
54+
"prefix": config.StringVariable(prefix),
55+
"description": config.StringVariable("updated description"),
56+
"filter": config.StringVariable("(severity eq critical)"),
57+
"quarantine": config.BoolVariable(true),
58+
"actions": config.ListVariable(config.ObjectVariable(map[string]config.Variable{
59+
"name": config.StringVariable("integration-action"),
60+
"type": config.ObjectVariable(map[string]config.Variable{
61+
"integration": config.ObjectVariable(map[string]config.Variable{
62+
"action": config.StringVariable("Azure-Security-Center-Integration"),
63+
}),
64+
}),
65+
})),
66+
},
67+
ConfigStateChecks: []statecheck.StateCheck{
68+
statecheck.ExpectKnownValue(
69+
"panos_correlation_log_settings.settings",
70+
tfjsonpath.New("description"),
71+
knownvalue.StringExact("updated description"),
72+
),
73+
statecheck.ExpectKnownValue(
74+
"panos_correlation_log_settings.settings",
75+
tfjsonpath.New("filter"),
76+
knownvalue.StringExact("(severity eq critical)"),
77+
),
78+
statecheck.ExpectKnownValue(
79+
"panos_correlation_log_settings.settings",
80+
tfjsonpath.New("quarantine"),
81+
knownvalue.Bool(true),
82+
),
83+
statecheck.ExpectKnownValue(
84+
"panos_correlation_log_settings.settings",
85+
tfjsonpath.New("actions").AtSliceIndex(0).AtMapKey("name"),
86+
knownvalue.StringExact("integration-action"),
87+
),
88+
statecheck.ExpectKnownValue(
89+
"panos_correlation_log_settings.settings",
90+
tfjsonpath.New("actions").AtSliceIndex(0).AtMapKey("type").AtMapKey("integration").AtMapKey("action"),
91+
knownvalue.StringExact("Azure-Security-Center-Integration"),
92+
),
93+
},
94+
},
95+
},
96+
})
97+
}
98+
99+
const correlationLogSettingsTmpl = `
100+
variable "prefix" { type = string }
101+
variable "description" { type = string }
102+
variable "filter" { type = string }
103+
variable "quarantine" { type = bool }
104+
variable "actions" {
105+
type = any
106+
default = []
107+
}
108+
109+
110+
resource "panos_template" "tmpl" {
111+
location = { panorama = {} }
112+
name = var.prefix
113+
}
114+
115+
resource "panos_syslog_profile" "syslog1" {
116+
location = { template = { name = panos_template.tmpl.name } }
117+
118+
name = "${var.prefix}1"
119+
120+
servers = [{
121+
name = "server2"
122+
server = "10.0.0.2"
123+
}]
124+
}
125+
126+
resource "panos_syslog_profile" "syslog2" {
127+
location = { template = { name = panos_template.tmpl.name } }
128+
129+
name = "${var.prefix}2"
130+
131+
servers = [{
132+
name = "server2"
133+
server = "10.0.0.2"
134+
}]
135+
}
136+
137+
resource "panos_correlation_log_settings" "settings" {
138+
location = { template = { name = panos_template.tmpl.name } }
139+
name = var.prefix
140+
description = var.description
141+
filter = var.filter
142+
quarantine = var.quarantine
143+
syslog_profiles = [panos_syslog_profile.syslog1.name, panos_syslog_profile.syslog2.name]
144+
actions = var.actions
145+
}
146+
`

0 commit comments

Comments
 (0)