2022-01-06 06:40:23 -05:00
|
|
|
package settings
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func Test_Settings_String(t *testing.T) {
|
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
|
|
withDefaults := func(s Settings) Settings {
|
|
|
|
|
s.SetDefaults()
|
|
|
|
|
return s
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
testCases := map[string]struct {
|
|
|
|
|
settings Settings
|
|
|
|
|
s string
|
|
|
|
|
}{
|
|
|
|
|
"default settings": {
|
|
|
|
|
settings: withDefaults(Settings{}),
|
|
|
|
|
s: `Settings summary:
|
|
|
|
|
├── VPN settings:
|
|
|
|
|
| ├── VPN provider settings:
|
|
|
|
|
| | ├── Name: private internet access
|
|
|
|
|
| | └── Server selection settings:
|
|
|
|
|
| | ├── VPN type: openvpn
|
|
|
|
|
| | └── OpenVPN server selection settings:
|
|
|
|
|
| | ├── Protocol: UDP
|
|
|
|
|
| | └── Private Internet Access encryption preset: strong
|
2022-01-07 15:12:49 +00:00
|
|
|
| └── OpenVPN settings:
|
2024-05-02 08:13:51 +00:00
|
|
|
| ├── OpenVPN version: 2.6
|
2022-01-06 06:40:23 -05:00
|
|
|
| ├── User: [not set]
|
|
|
|
|
| ├── Password: [not set]
|
|
|
|
|
| ├── Private Internet Access encryption preset: strong
|
|
|
|
|
| ├── Network interface: tun0
|
|
|
|
|
| ├── Run OpenVPN as: root
|
|
|
|
|
| └── Verbosity level: 1
|
|
|
|
|
├── DNS settings:
|
|
|
|
|
| ├── Keep existing nameserver(s): no
|
2023-08-11 10:42:44 +00:00
|
|
|
| ├── DNS server address to use: 127.0.0.1
|
2025-11-05 20:41:19 +00:00
|
|
|
| ├── DNS forwarder server enabled: yes
|
|
|
|
|
| ├── Upstream resolver type: dot
|
2025-11-05 20:14:25 +00:00
|
|
|
| ├── Upstream resolvers:
|
|
|
|
|
| | └── Cloudflare
|
|
|
|
|
| ├── Caching: yes
|
|
|
|
|
| ├── IPv6: no
|
2025-11-05 20:41:19 +00:00
|
|
|
| ├── Update period: every 24h0m0s
|
2025-11-05 20:14:25 +00:00
|
|
|
| └── DNS filtering settings:
|
|
|
|
|
| ├── Block malicious: yes
|
|
|
|
|
| ├── Block ads: no
|
|
|
|
|
| └── Block surveillance: yes
|
2022-01-06 06:40:23 -05:00
|
|
|
├── Firewall settings:
|
|
|
|
|
| └── Enabled: yes
|
|
|
|
|
├── Log settings:
|
|
|
|
|
| └── Log level: INFO
|
|
|
|
|
├── Health settings:
|
|
|
|
|
| ├── Server listening address: 127.0.0.1:9999
|
2022-04-11 20:21:03 +00:00
|
|
|
| ├── Target address: cloudflare.com:443
|
2025-10-21 15:36:15 +00:00
|
|
|
| ├── ICMP target IP: VPN server IP
|
|
|
|
|
| └── Restart VPN on healthcheck failure: yes
|
2022-01-06 06:40:23 -05:00
|
|
|
├── Shadowsocks server settings:
|
|
|
|
|
| └── Enabled: no
|
|
|
|
|
├── HTTP proxy settings:
|
|
|
|
|
| └── Enabled: no
|
|
|
|
|
├── Control server settings:
|
2022-01-27 23:15:08 +00:00
|
|
|
| ├── Listening address: :8000
|
2024-09-18 13:29:36 +02:00
|
|
|
| ├── Logging: yes
|
|
|
|
|
| └── Authentication file path: /gluetun/auth/config.toml
|
2024-08-19 01:00:30 +00:00
|
|
|
├── Storage settings:
|
|
|
|
|
| └── Filepath: /gluetun/servers.json
|
2022-01-06 06:40:23 -05:00
|
|
|
├── OS Alpine settings:
|
|
|
|
|
| ├── Process UID: 1000
|
|
|
|
|
| └── Process GID: 1000
|
|
|
|
|
├── Public IP settings:
|
2024-02-14 07:35:39 +00:00
|
|
|
| ├── IP file path: /tmp/gluetun/ip
|
2024-10-19 15:21:14 +02:00
|
|
|
| ├── Public IP data base API: ipinfo
|
|
|
|
|
| └── Public IP data backup APIs:
|
|
|
|
|
| ├── cloudflare
|
|
|
|
|
| ├── ifconfigco
|
|
|
|
|
| └── ip2location
|
2022-01-06 06:40:23 -05:00
|
|
|
└── Version settings:
|
|
|
|
|
└── Enabled: yes`,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for name, testCase := range testCases {
|
|
|
|
|
t.Run(name, func(t *testing.T) {
|
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
|
|
s := testCase.settings.String()
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, testCase.s, s)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|