chore(constants): internal/constants/vpn package
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||
"github.com/qdm12/gluetun/internal/constants/vpn"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -29,13 +30,13 @@ func Test_Mullvad_GetConnection(t *testing.T) {
|
||||
},
|
||||
"no filter": {
|
||||
servers: []models.Server{
|
||||
{VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(1, 1, 1, 1)}},
|
||||
{VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(2, 2, 2, 2)}},
|
||||
{VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(3, 3, 3, 3)}},
|
||||
{VPN: vpn.OpenVPN, IPs: []net.IP{net.IPv4(1, 1, 1, 1)}},
|
||||
{VPN: vpn.OpenVPN, IPs: []net.IP{net.IPv4(2, 2, 2, 2)}},
|
||||
{VPN: vpn.OpenVPN, IPs: []net.IP{net.IPv4(3, 3, 3, 3)}},
|
||||
},
|
||||
selection: settings.ServerSelection{}.WithDefaults(providers.Mullvad),
|
||||
connection: models.Connection{
|
||||
Type: constants.OpenVPN,
|
||||
Type: vpn.OpenVPN,
|
||||
IP: net.IPv4(1, 1, 1, 1),
|
||||
Port: 1194,
|
||||
Protocol: constants.UDP,
|
||||
@@ -46,12 +47,12 @@ func Test_Mullvad_GetConnection(t *testing.T) {
|
||||
TargetIP: net.IPv4(2, 2, 2, 2),
|
||||
}.WithDefaults(providers.Mullvad),
|
||||
servers: []models.Server{
|
||||
{VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(1, 1, 1, 1)}},
|
||||
{VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(2, 2, 2, 2)}},
|
||||
{VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(3, 3, 3, 3)}},
|
||||
{VPN: vpn.OpenVPN, IPs: []net.IP{net.IPv4(1, 1, 1, 1)}},
|
||||
{VPN: vpn.OpenVPN, IPs: []net.IP{net.IPv4(2, 2, 2, 2)}},
|
||||
{VPN: vpn.OpenVPN, IPs: []net.IP{net.IPv4(3, 3, 3, 3)}},
|
||||
},
|
||||
connection: models.Connection{
|
||||
Type: constants.OpenVPN,
|
||||
Type: vpn.OpenVPN,
|
||||
IP: net.IPv4(2, 2, 2, 2),
|
||||
Port: 1194,
|
||||
Protocol: constants.UDP,
|
||||
@@ -62,12 +63,12 @@ func Test_Mullvad_GetConnection(t *testing.T) {
|
||||
Hostnames: []string{"b"},
|
||||
}.WithDefaults(providers.Mullvad),
|
||||
servers: []models.Server{
|
||||
{VPN: constants.OpenVPN, Hostname: "a", IPs: []net.IP{net.IPv4(1, 1, 1, 1)}},
|
||||
{VPN: constants.OpenVPN, Hostname: "b", IPs: []net.IP{net.IPv4(2, 2, 2, 2)}},
|
||||
{VPN: constants.OpenVPN, Hostname: "a", IPs: []net.IP{net.IPv4(3, 3, 3, 3)}},
|
||||
{VPN: vpn.OpenVPN, Hostname: "a", IPs: []net.IP{net.IPv4(1, 1, 1, 1)}},
|
||||
{VPN: vpn.OpenVPN, Hostname: "b", IPs: []net.IP{net.IPv4(2, 2, 2, 2)}},
|
||||
{VPN: vpn.OpenVPN, Hostname: "a", IPs: []net.IP{net.IPv4(3, 3, 3, 3)}},
|
||||
},
|
||||
connection: models.Connection{
|
||||
Type: constants.OpenVPN,
|
||||
Type: vpn.OpenVPN,
|
||||
IP: net.IPv4(2, 2, 2, 2),
|
||||
Port: 1194,
|
||||
Protocol: constants.UDP,
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||
"github.com/qdm12/gluetun/internal/constants/vpn"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -30,28 +30,28 @@ func Test_Mullvad_filterServers(t *testing.T) {
|
||||
},
|
||||
"no filter": {
|
||||
servers: []models.Server{
|
||||
{VPN: constants.OpenVPN, Hostname: "a"},
|
||||
{VPN: constants.OpenVPN, Hostname: "b"},
|
||||
{VPN: constants.OpenVPN, Hostname: "c"},
|
||||
{VPN: vpn.OpenVPN, Hostname: "a"},
|
||||
{VPN: vpn.OpenVPN, Hostname: "b"},
|
||||
{VPN: vpn.OpenVPN, Hostname: "c"},
|
||||
},
|
||||
selection: settings.ServerSelection{}.WithDefaults(providers.Mullvad),
|
||||
filtered: []models.Server{
|
||||
{VPN: constants.OpenVPN, Hostname: "a"},
|
||||
{VPN: constants.OpenVPN, Hostname: "b"},
|
||||
{VPN: constants.OpenVPN, Hostname: "c"},
|
||||
{VPN: vpn.OpenVPN, Hostname: "a"},
|
||||
{VPN: vpn.OpenVPN, Hostname: "b"},
|
||||
{VPN: vpn.OpenVPN, Hostname: "c"},
|
||||
},
|
||||
},
|
||||
"filter OpenVPN out": {
|
||||
selection: settings.ServerSelection{
|
||||
VPN: constants.Wireguard,
|
||||
VPN: vpn.Wireguard,
|
||||
}.WithDefaults(providers.Mullvad),
|
||||
servers: []models.Server{
|
||||
{VPN: constants.OpenVPN, Hostname: "a"},
|
||||
{VPN: constants.Wireguard, Hostname: "b"},
|
||||
{VPN: constants.OpenVPN, Hostname: "c"},
|
||||
{VPN: vpn.OpenVPN, Hostname: "a"},
|
||||
{VPN: vpn.Wireguard, Hostname: "b"},
|
||||
{VPN: vpn.OpenVPN, Hostname: "c"},
|
||||
},
|
||||
filtered: []models.Server{
|
||||
{VPN: constants.Wireguard, Hostname: "b"},
|
||||
{VPN: vpn.Wireguard, Hostname: "b"},
|
||||
},
|
||||
},
|
||||
"filter by country": {
|
||||
@@ -59,12 +59,12 @@ func Test_Mullvad_filterServers(t *testing.T) {
|
||||
Countries: []string{"b"},
|
||||
}.WithDefaults(providers.Mullvad),
|
||||
servers: []models.Server{
|
||||
{VPN: constants.OpenVPN, Country: "a"},
|
||||
{VPN: constants.OpenVPN, Country: "b"},
|
||||
{VPN: constants.OpenVPN, Country: "c"},
|
||||
{VPN: vpn.OpenVPN, Country: "a"},
|
||||
{VPN: vpn.OpenVPN, Country: "b"},
|
||||
{VPN: vpn.OpenVPN, Country: "c"},
|
||||
},
|
||||
filtered: []models.Server{
|
||||
{VPN: constants.OpenVPN, Country: "b"},
|
||||
{VPN: vpn.OpenVPN, Country: "b"},
|
||||
},
|
||||
},
|
||||
"filter by city": {
|
||||
@@ -72,12 +72,12 @@ func Test_Mullvad_filterServers(t *testing.T) {
|
||||
Cities: []string{"b"},
|
||||
}.WithDefaults(providers.Mullvad),
|
||||
servers: []models.Server{
|
||||
{VPN: constants.OpenVPN, City: "a"},
|
||||
{VPN: constants.OpenVPN, City: "b"},
|
||||
{VPN: constants.OpenVPN, City: "c"},
|
||||
{VPN: vpn.OpenVPN, City: "a"},
|
||||
{VPN: vpn.OpenVPN, City: "b"},
|
||||
{VPN: vpn.OpenVPN, City: "c"},
|
||||
},
|
||||
filtered: []models.Server{
|
||||
{VPN: constants.OpenVPN, City: "b"},
|
||||
{VPN: vpn.OpenVPN, City: "b"},
|
||||
},
|
||||
},
|
||||
"filter by ISP": {
|
||||
@@ -85,12 +85,12 @@ func Test_Mullvad_filterServers(t *testing.T) {
|
||||
ISPs: []string{"b"},
|
||||
}.WithDefaults(providers.Mullvad),
|
||||
servers: []models.Server{
|
||||
{VPN: constants.OpenVPN, ISP: "a"},
|
||||
{VPN: constants.OpenVPN, ISP: "b"},
|
||||
{VPN: constants.OpenVPN, ISP: "c"},
|
||||
{VPN: vpn.OpenVPN, ISP: "a"},
|
||||
{VPN: vpn.OpenVPN, ISP: "b"},
|
||||
{VPN: vpn.OpenVPN, ISP: "c"},
|
||||
},
|
||||
filtered: []models.Server{
|
||||
{VPN: constants.OpenVPN, ISP: "b"},
|
||||
{VPN: vpn.OpenVPN, ISP: "b"},
|
||||
},
|
||||
},
|
||||
"filter by hostname": {
|
||||
@@ -98,12 +98,12 @@ func Test_Mullvad_filterServers(t *testing.T) {
|
||||
Hostnames: []string{"b"},
|
||||
}.WithDefaults(providers.Mullvad),
|
||||
servers: []models.Server{
|
||||
{VPN: constants.OpenVPN, Hostname: "a"},
|
||||
{VPN: constants.OpenVPN, Hostname: "b"},
|
||||
{VPN: constants.OpenVPN, Hostname: "c"},
|
||||
{VPN: vpn.OpenVPN, Hostname: "a"},
|
||||
{VPN: vpn.OpenVPN, Hostname: "b"},
|
||||
{VPN: vpn.OpenVPN, Hostname: "c"},
|
||||
},
|
||||
filtered: []models.Server{
|
||||
{VPN: constants.OpenVPN, Hostname: "b"},
|
||||
{VPN: vpn.OpenVPN, Hostname: "b"},
|
||||
},
|
||||
},
|
||||
"filter by owned": {
|
||||
@@ -111,12 +111,12 @@ func Test_Mullvad_filterServers(t *testing.T) {
|
||||
OwnedOnly: boolPtr(true),
|
||||
}.WithDefaults(providers.Mullvad),
|
||||
servers: []models.Server{
|
||||
{VPN: constants.OpenVPN, Hostname: "a"},
|
||||
{VPN: constants.OpenVPN, Hostname: "b", Owned: true},
|
||||
{VPN: constants.OpenVPN, Hostname: "c"},
|
||||
{VPN: vpn.OpenVPN, Hostname: "a"},
|
||||
{VPN: vpn.OpenVPN, Hostname: "b", Owned: true},
|
||||
{VPN: vpn.OpenVPN, Hostname: "c"},
|
||||
},
|
||||
filtered: []models.Server{
|
||||
{VPN: constants.OpenVPN, Hostname: "b", Owned: true},
|
||||
{VPN: vpn.OpenVPN, Hostname: "b", Owned: true},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user