Files
gluetun/internal/openvpn/logs_test.go
Quentin McGaw ff9b56d6d8 docs(all): update to use newer wiki repository
- Update URLs logged by program
- Update README.md links
- Update contributing guide link
- Update issue templates links
- Replace Wiki issue template by link to Gluetun Wiki repository issue creation
- Set program announcement about Github wiki new location
2023-06-30 10:31:26 +00:00

87 lines
2.5 KiB
Go

package openvpn
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_processLogLine(t *testing.T) {
t.Parallel()
tests := map[string]struct {
s string
filtered string
level logLevel
}{
"empty string": {"", "", levelInfo},
"random string": {"asdasqdb", "asdasqdb", levelInfo},
"openvpn unknown": {
"message",
"message",
levelInfo},
"openvpn note": {
"NOTE: message",
"message",
levelInfo},
"openvpn warning": {
"WARNING: message",
"message",
levelWarn},
"openvpn options error": {
"Options error: message",
"message",
levelError},
"openvpn ignored message": {
"NOTE: UID/GID downgrade will be delayed because of --client, --pull, or --up-delay",
"",
levelInfo},
"openvpn success": {
"Initialization Sequence Completed",
"Initialization Sequence Completed",
levelInfo},
"openvpn auth failed": {
"AUTH: Received control message: AUTH_FAILED",
"AUTH: Received control message: AUTH_FAILED\n\nYour credentials might be wrong 🤨\n\n",
levelError},
"TLS key negotiation error": {
s: "TLS Error: TLS key negotiation failed to occur within " +
"60 seconds (check your network connectivity)",
filtered: "TLS Error: TLS key negotiation failed to occur within " +
"60 seconds (check your network connectivity)" + `
🚒🚒🚒🚒🚒🚨🚨🚨🚨🚨🚨🚒🚒🚒🚒🚒
That error usually happens because either:
1. The VPN server IP address you are trying to connect to is no longer valid 🔌
Check out https://github.com/qdm12/gluetun-wiki/blob/main/setup/servers.md#update-the-vpn-servers-list
2. The VPN server crashed 💥, try changing your VPN servers filtering options such as SERVER_REGIONS
3. Your Internet connection is not working 🤯, ensure it works
4. Something else ➡️ https://github.com/qdm12/gluetun/issues/new/choose
`,
level: levelWarn,
},
"RTNETLINK answers: File exists": {
s: "ERROR: RTNETLINK answers: File exists",
filtered: "OpenVPN tried to add an IP route which already exists " +
"(RTNETLINK answers: File exists)",
level: levelWarn,
},
"Linux route add command failed": {
s: "ERROR: Linux route add command failed: some error",
filtered: "Previous error details: Linux route add command failed: some error",
level: levelWarn,
},
}
for name, tc := range tests {
tc := tc
t.Run(name, func(t *testing.T) {
t.Parallel()
filtered, level := processLogLine(tc.s)
assert.Equal(t, tc.filtered, filtered)
assert.Equal(t, tc.level, level)
})
}
}