Expose source port of firewall rules (#305)
* Expose source port of firewall rules * Add tests --------- Co-authored-by: Joshua Spence <josh@spence.com.au>
This commit is contained in:
committed by
GitHub
parent
cecb61809d
commit
7eadb9ba08
@@ -119,6 +119,12 @@ func resourceFirewallRule() *schema.Resource {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
"src_port": {
|
||||
Description: "The source port of the firewall rule.",
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ValidateFunc: validatePortRange,
|
||||
},
|
||||
"src_mac": {
|
||||
Description: "The source MAC address of the firewall rule.",
|
||||
Type: schema.TypeString,
|
||||
@@ -257,6 +263,7 @@ func resourceFirewallRuleGetResourceData(d *schema.ResourceData) (*unifi.Firewal
|
||||
SrcMACAddress: d.Get("src_mac").(string),
|
||||
SrcAddress: d.Get("src_address").(string),
|
||||
SrcAddressIPV6: d.Get("src_address_ipv6").(string),
|
||||
SrcPort: d.Get("src_port").(string),
|
||||
SrcNetworkID: d.Get("src_network_id").(string),
|
||||
SrcFirewallGroupIDs: srcFirewallGroupIDs,
|
||||
|
||||
@@ -292,6 +299,7 @@ func resourceFirewallRuleSetResourceData(resp *unifi.FirewallRule, d *schema.Res
|
||||
d.Set("src_address", resp.SrcAddress)
|
||||
d.Set("src_address_ipv6", resp.SrcAddressIPV6)
|
||||
d.Set("src_network_id", resp.SrcNetworkID)
|
||||
d.Set("src_port", resp.SrcPort)
|
||||
|
||||
d.Set("dst_network_type", resp.DstNetworkType)
|
||||
d.Set("dst_firewall_group_ids", stringSliceToSet(resp.DstFirewallGroupIDs))
|
||||
|
||||
@@ -24,13 +24,17 @@ func TestAccFirewallRule_basic(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccFirewallRule_dst_port(t *testing.T) {
|
||||
func TestAccFirewallRule_port(t *testing.T) {
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { preCheck(t) },
|
||||
ProviderFactories: providerFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccFirewallRuleConfigWithPort,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
resource.TestCheckResourceAttr("unifi_firewall_rule.test", "src_port", "123"),
|
||||
resource.TestCheckResourceAttr("unifi_firewall_rule.test", "dst_port", "53"),
|
||||
),
|
||||
},
|
||||
importStep("unifi_firewall_rule.test"),
|
||||
},
|
||||
@@ -159,6 +163,7 @@ resource "unifi_firewall_rule" "test" {
|
||||
protocol = "tcp"
|
||||
|
||||
src_address = "192.168.3.3"
|
||||
src_port = 123
|
||||
dst_address = "192.168.1.1"
|
||||
dst_port = 53
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user