summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-12-20 15:54:57 +0100
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-12-21 18:28:52 +0100
commitfeb5a34fcaefd30c764bd9aa9192f42c5a11b578 (patch)
treebbf47f6cf9805d05d3eab60eef308a923b8f88c5 /client
parent12838c19514459974cf0a71c42f1248b1cb9419c (diff)
Linting: Fix config arguments and results + comments
Diffstat (limited to 'client')
-rw-r--r--client/client_test.go23
-rw-r--r--client/fsm.go4
-rw-r--r--client/server.go4
3 files changed, 16 insertions, 15 deletions
diff --git a/client/client_test.go b/client/client_test.go
index 57196e4..64c0430 100644
--- a/client/client_test.go
+++ b/client/client_test.go
@@ -12,6 +12,7 @@ import (
httpw "github.com/eduvpn/eduvpn-common/internal/http"
"github.com/eduvpn/eduvpn-common/internal/util"
+ "github.com/eduvpn/eduvpn-common/internal/oauth"
"github.com/go-errors/errors"
)
@@ -93,7 +94,7 @@ func TestServer(t *testing.T) {
if addErr != nil {
t.Fatalf("Add error: %v", addErr)
}
- _, _, configErr := state.GetConfigCustomServer(serverURI, false)
+ _, configErr := state.GetConfigCustomServer(serverURI, false, oauth.Token{})
if configErr != nil {
t.Fatalf("Connect error: %v", configErr)
}
@@ -252,7 +253,7 @@ func TestTokenExpired(t *testing.T) {
t.Fatalf("Add error: %v", addErr)
}
- _, _, configErr := state.GetConfigCustomServer(serverURI, false)
+ _, configErr := state.GetConfigCustomServer(serverURI, false, oauth.Token{})
if configErr != nil {
t.Fatalf("Connect error before expired: %v", configErr)
@@ -273,7 +274,7 @@ func TestTokenExpired(t *testing.T) {
// Wait for TTL so that the tokens expire
time.Sleep(time.Duration(expiredInt) * time.Second)
- _, _, configErr = state.GetConfigCustomServer(serverURI, false)
+ _, configErr = state.GetConfigCustomServer(serverURI, false, oauth.Token{})
if configErr != nil {
t.Fatalf("Connect error after expiry: %v", configErr)
@@ -314,7 +315,7 @@ func TestInvalidProfileCorrected(t *testing.T) {
t.Fatalf("Add error: %v", addErr)
}
- _, _, configErr := state.GetConfigCustomServer(serverURI, false)
+ _, configErr := state.GetConfigCustomServer(serverURI, false, oauth.Token{})
if configErr != nil {
t.Fatalf("First connect error: %v", configErr)
@@ -333,7 +334,7 @@ func TestInvalidProfileCorrected(t *testing.T) {
previousProfile := base.Profiles.Current
base.Profiles.Current = "IDONOTEXIST"
- _, _, configErr = state.GetConfigCustomServer(serverURI, false)
+ _, configErr = state.GetConfigCustomServer(serverURI, false, oauth.Token{})
if configErr != nil {
t.Fatalf("Second connect error: %v", configErr)
@@ -373,10 +374,10 @@ func TestPreferTCP(t *testing.T) {
}
// get a config with preferTCP set to true
- config, configType, configErr := state.GetConfigCustomServer(serverURI, true)
+ config, configErr := state.GetConfigCustomServer(serverURI, true, oauth.Token{})
// Test server should accept prefer TCP!
- if configType != "openvpn" {
+ if config.Type != "openvpn" {
t.Fatalf("Invalid protocol for prefer TCP, got: WireGuard, want: OpenVPN")
}
@@ -384,18 +385,18 @@ func TestPreferTCP(t *testing.T) {
t.Fatalf("Config error: %v", configErr)
}
- if !strings.HasSuffix(config, "remote eduvpnserver 1194 tcp\nremote eduvpnserver 1194 udp") {
+ if !strings.HasSuffix(config.Config, "remote eduvpnserver 1194 tcp\nremote eduvpnserver 1194 udp") {
t.Fatalf("Suffix for prefer TCP is not in the right order for config: %s", config)
}
// get a config with preferTCP set to false
- config, configType, configErr = state.GetConfigCustomServer(serverURI, false)
+ config, configErr = state.GetConfigCustomServer(serverURI, false, oauth.Token{})
if configErr != nil {
t.Fatalf("Config error: %v", configErr)
}
- if configType == "openvpn" &&
- !strings.HasSuffix(config, "remote eduvpnserver 1194 udp\nremote eduvpnserver 1194 tcp") {
+ if config.Type == "openvpn" &&
+ !strings.HasSuffix(config.Config, "remote eduvpnserver 1194 udp\nremote eduvpnserver 1194 tcp") {
t.Fatalf("Suffix for disable prefer TCP is not in the right order for config: %s", config)
}
}
diff --git a/client/fsm.go b/client/fsm.go
index 76dee05..c156fba 100644
--- a/client/fsm.go
+++ b/client/fsm.go
@@ -212,7 +212,7 @@ func (c *Client) SetSearchServer() error {
return err
}
- //TODO(jwijenbergh): Should we handle `false` returned value here?
+ // TODO(jwijenbergh): Should we handle `false` returned value here?
c.FSM.GoTransition(StateSearchServer)
return nil
}
@@ -325,7 +325,7 @@ func (c *Client) SetDisconnected(cleanup bool) error {
func (c *Client) goBackInternal() {
err := c.GoBack()
if err != nil {
- //TODO(jwijenbergh): Bit suspicious - logging level INFO, yet stacktrace logged.
+ // TODO(jwijenbergh): Bit suspicious - logging level INFO, yet stacktrace logged.
c.Logger.Infof("failed going back: %s\nstacktrace:\n%s", err.Error(), err.(*errors.Error).ErrorStack())
}
}
diff --git a/client/server.go b/client/server.go
index 0bb37a8..27cb79b 100644
--- a/client/server.go
+++ b/client/server.go
@@ -86,8 +86,8 @@ func (c *Client) getConfig(srv server.Server, preferTCP bool, t oauth.Token) (*C
// Save the config
if err = c.Config.Save(&c); err != nil {
- //TODO(jwijenbergh): Not sure why INFO level, yet stacktrace...
- //TODO(jwijenbergh): Even worse, why logging it but then return nil? The calling code will think that everything went well.
+ // TODO(jwijenbergh): Not sure why INFO level, yet stacktrace...
+ // TODO(jwijenbergh): Even worse, why logging it but then return nil? The calling code will think that everything went well.
c.Logger.Infof("c.Config.Save failed: %s\nstacktrace:\n%s",
err.Error(), err.(*errors.Error).ErrorStack())
}