Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Opt-In Split Tunnel Overlapping IPs #1454

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/1454.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
devices_policy: add fields for Opt-In Split Tunnel Overlapping IPs feature.
```
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