v1.16.7
v1.16.7
This commit is contained in:
@@ -9,7 +9,7 @@ var testSecurityPolicies = SecurityPoliciesList{
|
||||
{
|
||||
ID: "policy1",
|
||||
DisplayName: "DevelopersPolicy",
|
||||
Description: "First policy",
|
||||
AccessGroupName: "DevelopersGroup",
|
||||
CreatedAt: "2023-01-01T00:00:00Z",
|
||||
UpdatedAt: "2023-01-01T01:00:00Z",
|
||||
AccessGroupID: "group1",
|
||||
@@ -17,26 +17,14 @@ var testSecurityPolicies = SecurityPoliciesList{
|
||||
DefaultOpenSessionDrop: true,
|
||||
SecurityRules: []SecurityRule{
|
||||
{
|
||||
ID: "rule1",
|
||||
DisplayName: "DevRule1",
|
||||
Action: "ALLOW",
|
||||
Direction: "INGRESS",
|
||||
Enabled: true,
|
||||
Priority: 100,
|
||||
SecurityPolicyID: "policy1",
|
||||
VersionID: 1,
|
||||
},
|
||||
},
|
||||
Status: Status{
|
||||
Common: "ACTIVE",
|
||||
Hypervisors: []HypervisorStatus{
|
||||
{
|
||||
Name: "hv1",
|
||||
DisplayName: "Hypervisor1",
|
||||
Status: "SYNCED",
|
||||
HypervisorStatus: "HEALTHY",
|
||||
SyncedAt: "2023-01-01T01:00:00Z",
|
||||
},
|
||||
ID: "rule1",
|
||||
DisplayName: "DevRule1",
|
||||
Action: "ALLOW",
|
||||
Direction: "INGRESS",
|
||||
Enabled: true,
|
||||
Priority: 100,
|
||||
Type: "System",
|
||||
VersionID: 1,
|
||||
},
|
||||
},
|
||||
VersionID: 1,
|
||||
@@ -44,7 +32,7 @@ var testSecurityPolicies = SecurityPoliciesList{
|
||||
{
|
||||
ID: "policy2",
|
||||
DisplayName: "AdminsPolicy",
|
||||
Description: "Second policy",
|
||||
AccessGroupName: "AdminsGroup",
|
||||
CreatedAt: "2023-01-02T00:00:00Z",
|
||||
UpdatedAt: "2023-01-02T01:00:00Z",
|
||||
AccessGroupID: "group2",
|
||||
@@ -52,26 +40,14 @@ var testSecurityPolicies = SecurityPoliciesList{
|
||||
DefaultOpenSessionDrop: false,
|
||||
SecurityRules: []SecurityRule{
|
||||
{
|
||||
ID: "rule2",
|
||||
DisplayName: "AdminRule1",
|
||||
Action: "DENY",
|
||||
Direction: "EGRESS",
|
||||
Enabled: true,
|
||||
Priority: 50,
|
||||
SecurityPolicyID: "policy2",
|
||||
VersionID: 1,
|
||||
},
|
||||
},
|
||||
Status: Status{
|
||||
Common: "ACTIVE",
|
||||
Hypervisors: []HypervisorStatus{
|
||||
{
|
||||
Name: "hv2",
|
||||
DisplayName: "Hypervisor2",
|
||||
Status: "SYNCED",
|
||||
HypervisorStatus: "HEALTHY",
|
||||
SyncedAt: "2023-01-02T01:00:00Z",
|
||||
},
|
||||
ID: "rule2",
|
||||
DisplayName: "AdminRule1",
|
||||
Action: "DENY",
|
||||
Direction: "EGRESS",
|
||||
Enabled: true,
|
||||
Priority: 50,
|
||||
Type: "System",
|
||||
VersionID: 1,
|
||||
},
|
||||
},
|
||||
VersionID: 2,
|
||||
@@ -79,7 +55,7 @@ var testSecurityPolicies = SecurityPoliciesList{
|
||||
{
|
||||
ID: "policy3",
|
||||
DisplayName: "UsersPolicy",
|
||||
Description: "Third policy",
|
||||
AccessGroupName: "UsersGroup",
|
||||
CreatedAt: "2023-01-03T00:00:00Z",
|
||||
UpdatedAt: "2023-01-03T01:00:00Z",
|
||||
AccessGroupID: "group3",
|
||||
@@ -87,26 +63,14 @@ var testSecurityPolicies = SecurityPoliciesList{
|
||||
DefaultOpenSessionDrop: true,
|
||||
SecurityRules: []SecurityRule{
|
||||
{
|
||||
ID: "rule3",
|
||||
DisplayName: "UserRule1",
|
||||
Action: "ALLOW",
|
||||
Direction: "INGRESS",
|
||||
Enabled: false,
|
||||
Priority: 200,
|
||||
SecurityPolicyID: "policy3",
|
||||
VersionID: 1,
|
||||
},
|
||||
},
|
||||
Status: Status{
|
||||
Common: "PENDING",
|
||||
Hypervisors: []HypervisorStatus{
|
||||
{
|
||||
Name: "hv3",
|
||||
DisplayName: "Hypervisor3",
|
||||
Status: "SYNCING",
|
||||
HypervisorStatus: "HEALTHY",
|
||||
SyncedAt: "2023-01-03T01:00:00Z",
|
||||
},
|
||||
ID: "rule3",
|
||||
DisplayName: "UserRule1",
|
||||
Action: "ALLOW",
|
||||
Direction: "INGRESS",
|
||||
Enabled: false,
|
||||
Priority: 200,
|
||||
Type: "User",
|
||||
VersionID: 1,
|
||||
},
|
||||
},
|
||||
VersionID: 3,
|
||||
@@ -132,11 +96,11 @@ func TestFilterByDisplayName(t *testing.T) {
|
||||
|
||||
func TestFilterFunc(t *testing.T) {
|
||||
actual := testSecurityPolicies.FilterFunc(func(sp SecurityPolicy) bool {
|
||||
return sp.Description == "Second policy"
|
||||
return sp.AccessGroupName == "AdminsGroup"
|
||||
})
|
||||
|
||||
if len(actual.Policies) != 1 || actual.Policies[0].ID != "policy2" {
|
||||
t.Fatal("Expected 1 policy with description 'Second policy', found:", len(actual.Policies))
|
||||
t.Fatal("Expected 1 policy with access group name 'AdminsGroup', found:", len(actual.Policies))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,13 +156,18 @@ func TestFilterByDefaultOpenSessionDrop(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByStatus(t *testing.T) {
|
||||
func TestFilterByRuleType(t *testing.T) {
|
||||
actual := testSecurityPolicies.FilterFunc(func(sp SecurityPolicy) bool {
|
||||
return sp.Status.Common == "ACTIVE"
|
||||
for _, rule := range sp.SecurityRules {
|
||||
if rule.Type == "System" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
if len(actual.Policies) != 2 {
|
||||
t.Fatal("Expected 2 policies with ACTIVE status, found:", len(actual.Policies))
|
||||
t.Fatal("Expected 2 policies with System rules, found:", len(actual.Policies))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@ type SecurityPolicy struct {
|
||||
// Access group ID
|
||||
AccessGroupID string `json:"access_group_id"`
|
||||
|
||||
// Access group name
|
||||
AccessGroupName string `json:"access_group_name"`
|
||||
|
||||
// Created time
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
@@ -18,9 +21,6 @@ type SecurityPolicy struct {
|
||||
// Default open session drop flag
|
||||
DefaultOpenSessionDrop bool `json:"default_open_session_drop"`
|
||||
|
||||
// Description
|
||||
Description string `json:"description"`
|
||||
|
||||
// Display name
|
||||
DisplayName string `json:"display_name"`
|
||||
|
||||
@@ -30,12 +30,6 @@ type SecurityPolicy struct {
|
||||
// Security rules
|
||||
SecurityRules []SecurityRule `json:"security_rules"`
|
||||
|
||||
// Locked time
|
||||
LockedAt string `json:"locked_at"`
|
||||
|
||||
// Status information
|
||||
Status Status `json:"status"`
|
||||
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
|
||||
@@ -51,11 +45,11 @@ type SecurityRule struct {
|
||||
// Action
|
||||
Action string `json:"action"`
|
||||
|
||||
// Description
|
||||
Description string `json:"description"`
|
||||
// Applied network object groups
|
||||
AppliedNetObjectGroups []AppliedNetObjectGroup `json:"applied_net_object_groups"`
|
||||
|
||||
// Destination network object
|
||||
DestinationNetObject NetObject `json:"destination_net_object"`
|
||||
// Destination network object groups
|
||||
DestinationNetObjectGroups []NetObjectGroup `json:"destination_net_object_groups"`
|
||||
|
||||
// Direction
|
||||
Direction string `json:"direction"`
|
||||
@@ -66,8 +60,8 @@ type SecurityRule struct {
|
||||
// Enabled flag
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// Filter configuration
|
||||
Filter Filter `json:"filter"`
|
||||
// Filters configuration
|
||||
Filter []FilterParams `json:"filters"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
@@ -75,47 +69,152 @@ type SecurityRule struct {
|
||||
// Log enabled flag
|
||||
LogEnabled bool `json:"log_enabled"`
|
||||
|
||||
// Log name
|
||||
LogName string `json:"log_name"`
|
||||
// Logging profile
|
||||
LoggingProfile LoggingProfile `json:"logging_profile"`
|
||||
|
||||
// Log severity
|
||||
LogSeverity string `json:"log_severity"`
|
||||
// Logging profile ID
|
||||
LoggingProfileID string `json:"logging_profile_id"`
|
||||
|
||||
// Priority
|
||||
Priority int `json:"priority"`
|
||||
|
||||
// Security policy ID
|
||||
SecurityPolicyID string `json:"security_policy_id"`
|
||||
// Security rule condition groups
|
||||
SecurityRuleConditionGroups []SecurityRuleConditionGroup `json:"security_rule_condition_groups"`
|
||||
|
||||
// Source network object
|
||||
SourceNetObject NetObject `json:"source_net_object"`
|
||||
// Security rule conditions
|
||||
SecurityRuleConditions []SecurityRuleCondition `json:"security_rule_conditions"`
|
||||
|
||||
// Source network object groups
|
||||
SourceNetObjectGroups []NetObjectGroup `json:"source_net_object_groups"`
|
||||
|
||||
// Statistics enabled flag
|
||||
StatisticsEnabled bool `json:"statistics_enabled"`
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
}
|
||||
|
||||
// Network object information
|
||||
type NetObject struct {
|
||||
// Display name
|
||||
DisplayName string `json:"display_name"`
|
||||
|
||||
// Network address pool ID
|
||||
NetAddressPoolID string `json:"net_address_pool_id"`
|
||||
|
||||
// Network object group ID
|
||||
NetObjectGroupID string `json:"net_object_group_id"`
|
||||
}
|
||||
|
||||
// Filter configuration
|
||||
type Filter struct {
|
||||
// Filter parameters
|
||||
Filters FilterParams `json:"filters"`
|
||||
// Applied network object group information
|
||||
type AppliedNetObjectGroup struct {
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
}
|
||||
|
||||
// Network object group information
|
||||
type NetObjectGroup struct {
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Is positive flag
|
||||
IsPositive bool `json:"is_positive"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
}
|
||||
|
||||
// Logging profile information
|
||||
type LoggingProfile struct {
|
||||
// Access group ID
|
||||
AccessGroupID string `json:"access_group_id"`
|
||||
|
||||
// Access group name
|
||||
AccessGroupName string `json:"access_group_name"`
|
||||
|
||||
// Created time
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// Direction
|
||||
Direction string `json:"direction"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Security rules count
|
||||
SecurityRulesCount uint64 `json:"security_rules_count"`
|
||||
|
||||
// Session established sample rate
|
||||
SessionEstablishedSampleRate float64 `json:"session_established_sample_rate"`
|
||||
|
||||
// Session new sample rate
|
||||
SessionNewSampleRate float64 `json:"session_new_sample_rate"`
|
||||
|
||||
// Updated time
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
}
|
||||
|
||||
// Security rule condition group information
|
||||
type SecurityRuleConditionGroup struct {
|
||||
// Access group ID
|
||||
AccessGroupID string `json:"access_group_id"`
|
||||
|
||||
// Access group name
|
||||
AccessGroupName string `json:"access_group_name"`
|
||||
|
||||
// Created time
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Security rule conditions
|
||||
SecurityRuleConditions []SecurityRuleCondition `json:"security_rule_conditions"`
|
||||
|
||||
// Security rules count
|
||||
SecurityRulesCount uint64 `json:"security_rules_count"`
|
||||
|
||||
// Updated time
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
// Security rule condition information
|
||||
type SecurityRuleCondition struct {
|
||||
// Access group ID
|
||||
AccessGroupID string `json:"access_group_id"`
|
||||
|
||||
// Created time
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// Filters configuration
|
||||
Filters []FilterParams `json:"filters"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Read only flag
|
||||
ReadOnly bool `json:"read_only"`
|
||||
|
||||
// Security rule condition groups
|
||||
SecurityRuleConditionGroups []interface{} `json:"security_rule_condition_groups"`
|
||||
|
||||
// Security rules
|
||||
SecurityRules []interface{} `json:"security_rules"`
|
||||
|
||||
// Updated time
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
// Filter parameters
|
||||
@@ -126,8 +225,8 @@ type FilterParams struct {
|
||||
// ARP protocol flag
|
||||
ARP bool `json:"arp"`
|
||||
|
||||
// DHCP protocol flag
|
||||
DHCP bool `json:"dhcp"`
|
||||
// Ethernet type
|
||||
EthType string `json:"eth_type"`
|
||||
|
||||
// Filter expression
|
||||
Expression string `json:"expression"`
|
||||
@@ -138,6 +237,9 @@ type FilterParams struct {
|
||||
// IP protocol flag
|
||||
IP bool `json:"ip"`
|
||||
|
||||
// IP protocol number
|
||||
IPProto uint64 `json:"ip_proto"`
|
||||
|
||||
// IPv4 protocol flag
|
||||
IPv4 bool `json:"ip_v4"`
|
||||
|
||||
@@ -156,36 +258,15 @@ type FilterParams struct {
|
||||
// TCP destination ports
|
||||
TCPDstPorts []string `json:"tcp_dst_ports"`
|
||||
|
||||
// TCP source ports
|
||||
TCPSrcPorts []string `json:"tcp_src_ports"`
|
||||
|
||||
// UDP protocol flag
|
||||
UDP bool `json:"udp"`
|
||||
|
||||
// UDP destination ports
|
||||
UDPDstPorts []string `json:"udp_dst_ports"`
|
||||
}
|
||||
|
||||
// Status information
|
||||
type Status struct {
|
||||
// Common status
|
||||
Common string `json:"common"`
|
||||
|
||||
// Hypervisor statuses
|
||||
Hypervisors []HypervisorStatus `json:"hypervisors"`
|
||||
}
|
||||
|
||||
// Hypervisor status information
|
||||
type HypervisorStatus struct {
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Display name
|
||||
DisplayName string `json:"display_name"`
|
||||
|
||||
// Hypervisor status
|
||||
HypervisorStatus string `json:"hypervisor_status"`
|
||||
|
||||
// Last sync time
|
||||
SyncedAt string `json:"synced_at"`
|
||||
|
||||
// UDP source ports
|
||||
UDPSrcPorts []string `json:"udp_src_ports"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user