diff --git a/go.sum b/go.sum index e038b024..c443e11f 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,5 @@ github.com/PaloAltoNetworks/pango v0.10.2 h1:Tjn6vIzzAq6Dd7N0mDuiP8w8pz8k5W9zz/TTSUQCsQY= github.com/PaloAltoNetworks/pango v0.10.2/go.mod h1:GztcRnVLur7G+VFG7Z5ZKNFgScLtsycwPMp1qVebE5g= -github.com/bl4ko/go-devicetype-library v0.1.10 h1:OJtTK1SXNbROn1M9XTmcpCJKkAsgvshX65ba9FiwcB0= -github.com/bl4ko/go-devicetype-library v0.1.10/go.mod h1:Pzm1BlRyR4uECezsRINDA6ZieFPumdFL+6yySpXM6t8= github.com/bl4ko/go-devicetype-library v0.1.11 h1:LGEseX0ATje/5YcUKpyCNb8bJEUrCCGV5Qmmon2flLE= github.com/bl4ko/go-devicetype-library v0.1.11/go.mod h1:Pzm1BlRyR4uECezsRINDA6ZieFPumdFL+6yySpXM6t8= github.com/buger/goterm v1.0.4 h1:Z9YvGmOih81P0FbVtEYTFF6YsSgxSUKEhf/f9bTMXbY= diff --git a/internal/utils/networking_test.go b/internal/utils/networking_test.go index b2823bc6..569dacdd 100644 --- a/internal/utils/networking_test.go +++ b/internal/utils/networking_test.go @@ -420,3 +420,63 @@ func TestRemoveZoneIndexFromIPAddress(t *testing.T) { }) } } + +func Test_subnetsContainIPAddress(t *testing.T) { + type args struct { + ipAddress string + subnets []string + } + tests := []struct { + name string + args args + want bool + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := subnetsContainIPAddress(tt.args.ipAddress, tt.args.subnets); got != tt.want { + t.Errorf("subnetsContainIPAddress() = %v, want %v", got, tt.want) + } + }) + } +} + +func TestIsPermittedIPAddress(t *testing.T) { + type args struct { + ipAddress string + permittedSubnets []string + ignoredSubnets []string + } + tests := []struct { + name string + args args + want bool + }{ + { + name: "Test permitted ip address", + args: args{ + ipAddress: "172.25.17.2", + permittedSubnets: []string{"172.0.0.0/8"}, + ignoredSubnets: []string{}, + }, + want: true, + }, + { + name: "Test unpermitted ip address", + args: args{ + ipAddress: "172.25.17.2", + permittedSubnets: []string{}, + ignoredSubnets: []string{"172.0.0.0/8"}, + }, + want: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := IsPermittedIPAddress(tt.args.ipAddress, tt.args.permittedSubnets, tt.args.ignoredSubnets); got != tt.want { + t.Errorf("IsPermittedIPAddress() = %v, want %v", got, tt.want) + } + }) + } +}