Files
gluetun/internal/configuration/openvpn_test.go

41 lines
740 B
Go
Raw Normal View History

2021-02-06 11:05:50 -05:00
package configuration
2020-07-19 14:26:24 +00:00
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func Test_OpenVPN_JSON(t *testing.T) {
t.Parallel()
in := OpenVPN{
Root: true,
Flags: []string{},
Ciphers: []string{},
2020-07-19 14:26:24 +00:00
}
data, err := json.MarshalIndent(in, "", " ")
2020-07-19 14:26:24 +00:00
require.NoError(t, err)
assert.Equal(t, `{
"user": "",
"password": "",
"verbosity": 0,
"flags": [],
"mssfix": 0,
"run_as_root": true,
"ciphers": [],
"auth": "",
"conf_file": "",
"version": "",
"encryption_preset": "",
"ipv6": false,
"procuser": "",
"interface": ""
}`, 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)
}