Skip to content

Commit

Permalink
Add support for Opt-In Split Tunnel
Browse files Browse the repository at this point in the history
  • Loading branch information
da-cf committed Dec 1, 2023
1 parent 182ec79 commit e03a441
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 37 deletions.
8 changes: 8 additions & 0 deletions devices_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ type DeviceSettingsPolicy struct {
Default bool `json:"default"`
ExcludeOfficeIps *bool `json:"exclude_office_ips"`
Description *string `json:"description"`
LanAllowMinutes *uint `json:"lan_allow_minutes"`
LanAllowSubnetSize *uint `json:"lan_allow_subnet_size"`
}

type DeviceSettingsPolicyResponse struct {
Expand Down Expand Up @@ -85,6 +87,8 @@ type CreateDeviceSettingsPolicyParams struct {
Enabled *bool `json:"enabled,omitempty"`
ExcludeOfficeIps *bool `json:"exclude_office_ips"`
Description *string `json:"description,omitempty"`
LanAllowMinutes *uint `json:"lan_allow_minutes,omitempty"`
LanAllowSubnetSize *uint `json:"lan_allow_subnet_size,omitempty"`
}

type UpdateDefaultDeviceSettingsPolicyParams struct {
Expand All @@ -103,6 +107,8 @@ type UpdateDefaultDeviceSettingsPolicyParams struct {
Enabled *bool `json:"enabled,omitempty"`
ExcludeOfficeIps *bool `json:"exclude_office_ips"`
Description *string `json:"description,omitempty"`
LanAllowMinutes *uint `json:"lan_allow_minutes,omitempty"`
LanAllowSubnetSize *uint `json:"lan_allow_subnet_size,omitempty"`
}

type UpdateDeviceSettingsPolicyParams struct {
Expand All @@ -122,6 +128,8 @@ type UpdateDeviceSettingsPolicyParams struct {
Enabled *bool `json:"enabled,omitempty"`
ExcludeOfficeIps *bool `json:"exclude_office_ips"`
Description *string `json:"description,omitempty"`
LanAllowMinutes *uint `json:"lan_allow_minutes,omitempty"`
LanAllowSubnetSize *uint `json:"lan_allow_subnet_size,omitempty"`
}

type ListDeviceSettingsPoliciesResponse struct {
Expand Down
82 changes: 45 additions & 37 deletions devices_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,24 @@ var (
{Address: "10.0.0.0/8"},
{Address: "100.64.0.0/10"},
},
GatewayUniqueID: StringPtr("t1235"),
SupportURL: StringPtr(""),
CaptivePortal: IntPtr(180),
AllowModeSwitch: BoolPtr(false),
SwitchLocked: BoolPtr(false),
AllowUpdates: BoolPtr(false),
AutoConnect: IntPtr(0),
AllowedToLeave: BoolPtr(true),
Enabled: BoolPtr(true),
PolicyID: nil,
Name: nil,
Match: nil,
Precedence: nil,
Default: true,
ExcludeOfficeIps: BoolPtr(false),
Description: nil,
GatewayUniqueID: StringPtr("t1235"),
SupportURL: StringPtr(""),
CaptivePortal: IntPtr(180),
AllowModeSwitch: BoolPtr(false),
SwitchLocked: BoolPtr(false),
AllowUpdates: BoolPtr(false),
AutoConnect: IntPtr(0),
AllowedToLeave: BoolPtr(true),
Enabled: BoolPtr(true),
PolicyID: nil,
Name: nil,
Match: nil,
Precedence: nil,
Default: true,
ExcludeOfficeIps: BoolPtr(false),
Description: nil,
LanAllowMinutes: nil,
LanAllowSubnetSize: nil,
}

nonDefaultDeviceSettingsPolicy = DeviceSettingsPolicy{
Expand All @@ -58,22 +60,24 @@ var (
{Address: "10.0.0.0/8"},
{Address: "100.64.0.0/10"},
},
GatewayUniqueID: StringPtr("t1235"),
SupportURL: StringPtr(""),
CaptivePortal: IntPtr(180),
AllowModeSwitch: BoolPtr(false),
SwitchLocked: BoolPtr(false),
AllowUpdates: BoolPtr(false),
AutoConnect: IntPtr(0),
AllowedToLeave: BoolPtr(true),
PolicyID: &deviceSettingsPolicyID,
Enabled: BoolPtr(true),
Name: StringPtr("test"),
Match: &deviceSettingsPolicyMatch,
Precedence: &deviceSettingsPolicyPrecedence,
Default: false,
ExcludeOfficeIps: BoolPtr(true),
Description: StringPtr("Test Description"),
GatewayUniqueID: StringPtr("t1235"),
SupportURL: StringPtr(""),
CaptivePortal: IntPtr(180),
AllowModeSwitch: BoolPtr(false),
SwitchLocked: BoolPtr(false),
AllowUpdates: BoolPtr(false),
AutoConnect: IntPtr(0),
AllowedToLeave: BoolPtr(true),
PolicyID: &deviceSettingsPolicyID,
Enabled: BoolPtr(true),
Name: StringPtr("test"),
Match: &deviceSettingsPolicyMatch,
Precedence: &deviceSettingsPolicyPrecedence,
Default: false,
ExcludeOfficeIps: BoolPtr(true),
Description: StringPtr("Test Description"),
LanAllowMinutes: UintPtr(120),
LanAllowSubnetSize: UintPtr(31),
}

defaultDeviceSettingsPolicyJson = `{
Expand Down Expand Up @@ -146,7 +150,9 @@ var (
"precedence": 10,
"default": false,
"exclude_office_ips":true,
"description":"Test Description"
"description":"Test Description",
"lan_allow_minutes": 120,
"lan_allow_subnet_size": 31
}`, deviceSettingsPolicyID, deviceSettingsPolicyMatch)
)

Expand Down Expand Up @@ -234,10 +240,12 @@ func TestCreateDeviceSettingsPolicy(t *testing.T) {
mux.HandleFunc("/accounts/"+testAccountID+"/devices/policy", handler)

actual, err := client.CreateDeviceSettingsPolicy(context.Background(), AccountIdentifier(testAccountID), CreateDeviceSettingsPolicyParams{
Precedence: IntPtr(10),
Match: &deviceSettingsPolicyMatch,
Name: StringPtr("test"),
Description: StringPtr("Test Description"),
Precedence: IntPtr(10),
Match: &deviceSettingsPolicyMatch,
Name: StringPtr("test"),
Description: StringPtr("Test Description"),
LanAllowMinutes: UintPtr(120),
LanAllowSubnetSize: UintPtr(31),
})

if assert.NoError(t, err) {
Expand Down

0 comments on commit e03a441

Please sign in to comment.