2020-07-19 14:26:24 +00:00
|
|
|
package settings
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"testing"
|
|
|
|
|
|
2020-07-26 12:07:06 +00:00
|
|
|
"github.com/qdm12/gluetun/internal/models"
|
2020-07-19 14:26:24 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func Test_OpenVPN_JSON(t *testing.T) {
|
|
|
|
|
t.Parallel()
|
|
|
|
|
in := OpenVPN{
|
|
|
|
|
Root: true,
|
|
|
|
|
Provider: models.ProviderSettings{
|
|
|
|
|
Name: "name",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
data, err := json.Marshal(in)
|
|
|
|
|
require.NoError(t, err)
|
2020-10-18 17:15:42 -04:00
|
|
|
assert.Equal(t, `{"user":"","verbosity":0,"runAsRoot":true,"cipher":"","auth":"","provider":{"name":"name","serverSelection":{"networkProtocol":"","regions":null,"group":"","countries":null,"cities":null,"isps":null,"owned":false,"customPort":0,"numbers":null,"encryptionPreset":""},"extraConfig":{"encryptionPreset":"","openvpnIPv6":false},"portForwarding":{"enabled":false,"filepath":""}}}`, string(data))
|
2020-07-19 14:26:24 +00:00
|
|
|
var out OpenVPN
|
|
|
|
|
err = json.Unmarshal(data, &out)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
assert.Equal(t, in, out)
|
|
|
|
|
}
|