Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# A hipmatch log setting can be imported by providing the following base64 encoded object as the ID
# {
# location = {
# template = {
# name = "example-template"
# panorama_device = "localhost.localdomain"
# }
# }
#
# name = "example-hipmatch-settings"
# }
terraform import panos_hipmatch_log_settings.example $(echo '{"location":{"template":{"name":"example-template","panorama_device":"localhost.localdomain"}},"name":"example-hipmatch-settings"}' | base64)
120 changes: 120 additions & 0 deletions assets/terraform/test/resource_hipmatch_log_settings_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package provider_test

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-testing/config"
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/knownvalue"
"github.com/hashicorp/terraform-plugin-testing/statecheck"
"github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
)

func TestAccHipmatchLogSettings(t *testing.T) {
t.Parallel()

nameSuffix := acctest.RandStringFromCharSet(6, acctest.CharSetAlphaNum)
prefix := fmt.Sprintf("test-acc-%s", nameSuffix)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProviders,
Steps: []resource.TestStep{
{
Config: hipmatchLogSettingsTmpl,
ConfigVariables: map[string]config.Variable{
"prefix": config.StringVariable(prefix),
"description": config.StringVariable("test description"),
"filter": config.StringVariable("(matchname eq test)"),
"send_to_panorama": config.BoolVariable(true),
},
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectKnownValue(
"panos_hipmatch_log_settings.settings",
tfjsonpath.New("description"),
knownvalue.StringExact("test description"),
),
statecheck.ExpectKnownValue(
"panos_hipmatch_log_settings.settings",
tfjsonpath.New("filter"),
knownvalue.StringExact("(matchname eq test)"),
),
statecheck.ExpectKnownValue(
"panos_hipmatch_log_settings.settings",
tfjsonpath.New("send_to_panorama"),
knownvalue.Bool(true),
),
},
},
{
Config: hipmatchLogSettingsTmpl,
ConfigVariables: map[string]config.Variable{
"prefix": config.StringVariable(prefix),
"description": config.StringVariable("updated description"),
"filter": config.StringVariable("(matchname eq test2)"),
"send_to_panorama": config.BoolVariable(false),
"actions": config.ListVariable(config.ObjectVariable(map[string]config.Variable{
"name": config.StringVariable("tag-action"),
"type": config.ObjectVariable(map[string]config.Variable{
"tagging": config.ObjectVariable(map[string]config.Variable{
"action": config.StringVariable("add-tag"),
"target": config.StringVariable("source-address"),
"tags": config.ListVariable(config.StringVariable("tag1"), config.StringVariable("tag2")),
}),
}),
})),
},
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectKnownValue(
"panos_hipmatch_log_settings.settings",
tfjsonpath.New("description"),
knownvalue.StringExact("updated description"),
),
statecheck.ExpectKnownValue(
"panos_hipmatch_log_settings.settings",
tfjsonpath.New("filter"),
knownvalue.StringExact("(matchname eq test2)"),
),
statecheck.ExpectKnownValue(
"panos_hipmatch_log_settings.settings",
tfjsonpath.New("send_to_panorama"),
knownvalue.Bool(false),
),
statecheck.ExpectKnownValue(
"panos_hipmatch_log_settings.settings",
tfjsonpath.New("actions").AtSliceIndex(0).AtMapKey("name"),
knownvalue.StringExact("tag-action"),
),
},
},
},
})
}

const hipmatchLogSettingsTmpl = `
variable "prefix" { type = string }
variable "description" { type = string }
variable "filter" { type = string }
variable "send_to_panorama" { type = bool }
variable "actions" {
type = any
default = []
}


resource "panos_template" "tmpl" {
location = { panorama = {} }
name = var.prefix
}

resource "panos_hipmatch_log_settings" "settings" {
location = { template = { name = panos_template.tmpl.name } }
name = var.prefix
description = var.description
filter = var.filter
send_to_panorama = var.send_to_panorama
actions = var.actions
}
`
Loading
Loading