Openvpn get settings http route
This commit is contained in:
@@ -11,13 +11,13 @@ import (
|
||||
|
||||
// OpenVPN contains settings to configure the OpenVPN client
|
||||
type OpenVPN struct {
|
||||
User string
|
||||
Password string
|
||||
Verbosity int
|
||||
Root bool
|
||||
Cipher string
|
||||
Auth string
|
||||
Provider models.ProviderSettings
|
||||
User string `json:"user"`
|
||||
Password string `json:"-"`
|
||||
Verbosity int `json:"verbosity"`
|
||||
Root bool `json:"runAsRoot"`
|
||||
Cipher string `json:"cipher"`
|
||||
Auth string `json:"auth"`
|
||||
Provider models.ProviderSettings `json:"provider"`
|
||||
}
|
||||
|
||||
// GetOpenVPNSettings obtains the OpenVPN settings using the params functions
|
||||
|
||||
27
internal/settings/openvpn_test.go
Normal file
27
internal/settings/openvpn_test.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package settings
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/qdm12/private-internet-access-docker/internal/models"
|
||||
"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)
|
||||
assert.Equal(t, `{"user":"","verbosity":0,"runAsRoot":true,"cipher":"","auth":"","provider":{"name":"name","serverSelection":{"networkProtocol":"","region":"","group":"","country":"","city":"","isp":"","owned":false,"customPort":0,"number":0,"encryptionPreset":""},"extraConfig":{"encryptionPreset":""},"portForwarding":{"enabled":false,"filepath":""}}}`, string(data))
|
||||
var out OpenVPN
|
||||
err = json.Unmarshal(data, &out)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, in, out)
|
||||
}
|
||||
Reference in New Issue
Block a user