Skip to content

Commit 5a7efcd

Browse files
committed
feat(specs): Create spec, tests and examples for panos_globalprotect_log_settings
1 parent 1b347d6 commit 5a7efcd

File tree

4 files changed

+655
-0
lines changed

4 files changed

+655
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# A globalprotect 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-gp-settings"
11+
# }
12+
terraform import panos_globalprotect_log_settings.example $(echo '{"location":{"template":{"name":"example-template","panorama_device":"localhost.localdomain"}},"name":"example-gp-settings"}' | base64)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
resource "panos_template" "example" {
2+
location = { panorama = {} }
3+
name = "example-template"
4+
}
5+
6+
resource "panos_globalprotect_log_settings" "example" {
7+
location = {
8+
template = {
9+
name = panos_template.example.name
10+
}
11+
}
12+
13+
name = "example-gp-settings"
14+
description = "globalprotect log settings example"
15+
filter = "(severity eq high)"
16+
send_to_panorama = true
17+
18+
actions = [
19+
{
20+
name = "tag-action"
21+
type = {
22+
tagging = {
23+
action = "add-tag"
24+
target = "source-address"
25+
tags = ["tag1", "tag2"]
26+
registration = {
27+
panorama = {}
28+
}
29+
}
30+
}
31+
}
32+
]
33+
}
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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 TestAccGlobalprotectLogSettings(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: globalprotectLogSettingsTmpl,
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+
"send_to_panorama": config.BoolVariable(true),
32+
},
33+
ConfigStateChecks: []statecheck.StateCheck{
34+
statecheck.ExpectKnownValue(
35+
"panos_globalprotect_log_settings.settings",
36+
tfjsonpath.New("description"),
37+
knownvalue.StringExact("test description"),
38+
),
39+
// statecheck.ExpectKnownValue(
40+
// "panos_globalprotect_log_settings.settings",
41+
// tfjsonpath.New("filter"),
42+
// knownvalue.StringExact("(severity eq high)"),
43+
// ),
44+
statecheck.ExpectKnownValue(
45+
"panos_globalprotect_log_settings.settings",
46+
tfjsonpath.New("send_to_panorama"),
47+
knownvalue.Bool(true),
48+
),
49+
},
50+
},
51+
{
52+
Config: globalprotectLogSettingsTmpl,
53+
ConfigVariables: map[string]config.Variable{
54+
"prefix": config.StringVariable(prefix),
55+
"description": config.StringVariable("updated description"),
56+
"filter": config.StringVariable("(status eq 200)"),
57+
"send_to_panorama": config.BoolVariable(false),
58+
"actions": config.ListVariable(config.ObjectVariable(map[string]config.Variable{
59+
"name": config.StringVariable("tag-action"),
60+
"type": config.ObjectVariable(map[string]config.Variable{
61+
"tagging": config.ObjectVariable(map[string]config.Variable{
62+
"action": config.StringVariable("add-tag"),
63+
"target": config.StringVariable("source-address"),
64+
"tags": config.ListVariable(config.StringVariable("tag1"), config.StringVariable("tag2")),
65+
}),
66+
}),
67+
})),
68+
},
69+
ConfigStateChecks: []statecheck.StateCheck{
70+
statecheck.ExpectKnownValue(
71+
"panos_globalprotect_log_settings.settings",
72+
tfjsonpath.New("description"),
73+
knownvalue.StringExact("updated description"),
74+
),
75+
// statecheck.ExpectKnownValue(
76+
// "panos_globalprotect_log_settings.settings",
77+
// tfjsonpath.New("filter"),
78+
// knownvalue.StringExact("(severity eq critical)"),
79+
// ),
80+
statecheck.ExpectKnownValue(
81+
"panos_globalprotect_log_settings.settings",
82+
tfjsonpath.New("send_to_panorama"),
83+
knownvalue.Bool(false),
84+
),
85+
statecheck.ExpectKnownValue(
86+
"panos_globalprotect_log_settings.settings",
87+
tfjsonpath.New("actions").AtSliceIndex(0).AtMapKey("name"),
88+
knownvalue.StringExact("tag-action"),
89+
),
90+
},
91+
},
92+
},
93+
})
94+
}
95+
96+
const globalprotectLogSettingsTmpl = `
97+
variable "prefix" { type = string }
98+
variable "description" { type = string }
99+
variable "filter" { type = string }
100+
variable "send_to_panorama" { type = bool }
101+
variable "actions" {
102+
type = any
103+
default = []
104+
}
105+
106+
107+
resource "panos_template" "tmpl" {
108+
location = { panorama = {} }
109+
name = var.prefix
110+
}
111+
112+
resource "panos_globalprotect_log_settings" "settings" {
113+
location = { template = { name = panos_template.tmpl.name } }
114+
name = var.prefix
115+
description = var.description
116+
#filter = var.filter
117+
send_to_panorama = var.send_to_panorama
118+
actions = var.actions
119+
}
120+
`

0 commit comments

Comments
 (0)