Skip to content

Commit

Permalink
Fix firewall filerting rules panic issue (#242)
Browse files Browse the repository at this point in the history
* fix firewall filtering rules  data panic
* fix firewall filtering rules resource test
  • Loading branch information
amazzalel-habib authored May 24, 2023
1 parent 9551344 commit 4a58ebb
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 12 deletions.
40 changes: 38 additions & 2 deletions zia/data_source_zia_firewall_filtering_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,25 @@ func dataSourceFirewallFilteringRule() *schema.Resource {
"src_ip_groups": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeInt,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"extensions": {
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
},
},
"dest_addresses": {
Type: schema.TypeList,
Expand All @@ -243,7 +261,25 @@ func dataSourceFirewallFilteringRule() *schema.Resource {
"dest_ip_groups": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeInt,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"extensions": {
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
},
},
"nw_services": {
Type: schema.TypeList,
Expand Down
20 changes: 10 additions & 10 deletions zia/resource_zia_firewall_filtering_rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ func TestAccResourceFirewallFilteringRuleBasic(t *testing.T) {
resource.TestCheckResourceAttr(resourceTypeAndName, "state", variable.FWRuleResourceState),
resource.TestCheckResourceAttrSet(resourceTypeAndName, "order"),
resource.TestCheckResourceAttr(resourceTypeAndName, "nw_services.#", "1"),
resource.TestCheckResourceAttr(resourceTypeAndName, "departments.#", "2"),
resource.TestCheckResourceAttr(resourceTypeAndName, "groups.#", "2"),
resource.TestCheckResourceAttr(resourceTypeAndName, "time_windows.#", "2"),
resource.TestCheckResourceAttr(resourceTypeAndName, "src_ip_groups.#", "2"),
resource.TestCheckResourceAttr(resourceTypeAndName, "dest_ip_groups.#", "2"),
resource.TestCheckResourceAttr(resourceTypeAndName, "departments.0.id.#", "2"),
resource.TestCheckResourceAttr(resourceTypeAndName, "groups.0.id.#", "2"),
resource.TestCheckResourceAttr(resourceTypeAndName, "time_windows.0.id.#", "2"),
resource.TestCheckResourceAttr(resourceTypeAndName, "src_ip_groups.0.id.#", "2"),
resource.TestCheckResourceAttr(resourceTypeAndName, "dest_ip_groups.0.id.#", "2"),
resource.TestCheckResourceAttr(resourceTypeAndName, "enable_full_logging", strconv.FormatBool(variable.FWRuleEnableLogging)),
),
},
Expand All @@ -53,11 +53,11 @@ func TestAccResourceFirewallFilteringRuleBasic(t *testing.T) {
resource.TestCheckResourceAttr(resourceTypeAndName, "state", variable.FWRuleResourceState),
resource.TestCheckResourceAttrSet(resourceTypeAndName, "order"),
resource.TestCheckResourceAttr(resourceTypeAndName, "nw_services.#", "1"),
resource.TestCheckResourceAttr(resourceTypeAndName, "departments.#", "2"),
resource.TestCheckResourceAttr(resourceTypeAndName, "groups.#", "2"),
resource.TestCheckResourceAttr(resourceTypeAndName, "time_windows.#", "2"),
resource.TestCheckResourceAttr(resourceTypeAndName, "src_ip_groups.#", "2"),
resource.TestCheckResourceAttr(resourceTypeAndName, "dest_ip_groups.#", "2"),
resource.TestCheckResourceAttr(resourceTypeAndName, "departments.0.id.#", "2"),
resource.TestCheckResourceAttr(resourceTypeAndName, "groups.0.id.#", "2"),
resource.TestCheckResourceAttr(resourceTypeAndName, "time_windows.0.id.#", "2"),
resource.TestCheckResourceAttr(resourceTypeAndName, "src_ip_groups.0.id.#", "2"),
resource.TestCheckResourceAttr(resourceTypeAndName, "dest_ip_groups.0.id.#", "2"),
resource.TestCheckResourceAttr(resourceTypeAndName, "enable_full_logging", strconv.FormatBool(variable.FWRuleEnableLogging)),
),
},
Expand Down

0 comments on commit 4a58ebb

Please sign in to comment.