diff options
| -rw-r--r-- | client/client_test.go | 13 | ||||
| -rw-r--r-- | internal/discovery/discovery_test.go | 2 | ||||
| -rw-r--r-- | internal/http/http.go | 1 | ||||
| -rw-r--r-- | internal/oauth/oauth.go | 2 | ||||
| -rw-r--r-- | internal/server/api_test.go | 28 | ||||
| -rw-r--r-- | internal/server/base.go | 1 | ||||
| -rw-r--r-- | internal/server/server.go | 2 | ||||
| -rw-r--r-- | internal/test/handler.go | 2 | ||||
| -rw-r--r-- | internal/test/server.go | 1 |
9 files changed, 25 insertions, 27 deletions
diff --git a/client/client_test.go b/client/client_test.go index 5a5a39e..295cce5 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -3,9 +3,9 @@ package client import ( "fmt" "net/http" + "net/url" "os" "os/exec" - "net/url" "strconv" "strings" "testing" @@ -409,12 +409,12 @@ func TestPreferTCP(t *testing.T) { } func TestInvalidClientID(t *testing.T) { - tests := map[string]bool { - "test": false, + tests := map[string]bool{ + "test": false, "org.letsconnect-vpn.app.linux": true, - "org.letsconnect-vpn": false, - "org.letsconnect-vpn.app": false, - "org.letsconnect-vpn.linuxsd": false, + "org.letsconnect-vpn": false, + "org.letsconnect-vpn.app": false, + "org.letsconnect-vpn.linuxsd": false, "org.letsconnect-vpn.app.macos": true, } @@ -443,5 +443,4 @@ func TestInvalidClientID(t *testing.T) { t.Fatalf("register error has invalid prefix: %v", registerErr.Error()) } } - } diff --git a/internal/discovery/discovery_test.go b/internal/discovery/discovery_test.go index 3422864..ec10ef0 100644 --- a/internal/discovery/discovery_test.go +++ b/internal/discovery/discovery_test.go @@ -6,8 +6,8 @@ import ( "testing" "time" - "github.com/eduvpn/eduvpn-common/types" "github.com/eduvpn/eduvpn-common/internal/test" + "github.com/eduvpn/eduvpn-common/types" ) // TestServers tests whether or not we can obtain discovery servers diff --git a/internal/http/http.go b/internal/http/http.go index c5939b5..9b45733 100644 --- a/internal/http/http.go +++ b/internal/http/http.go @@ -161,7 +161,6 @@ func (c *Client) PostWithOpts(url string, opts *OptionalParams) (http.Header, [] return c.Do(http.MethodPost, url, opts) } - // MethodWithOpts Do send a HTTP request using a method (e.g. GET, POST), an url and optional parameters // It returns the HTTP headers, the body and an error if there is one. func (c *Client) Do(method string, urlStr string, opts *OptionalParams) (http.Header, []byte, error) { diff --git a/internal/oauth/oauth.go b/internal/oauth/oauth.go index c11179c..7200a95 100644 --- a/internal/oauth/oauth.go +++ b/internal/oauth/oauth.go @@ -281,7 +281,7 @@ func (oauth *OAuth) refreshResponse(r string) (*TokenResponse, time.Time, error) return nil, time.Time{}, errors.New("No client ID was cached for refresh") } data := url.Values{ - "client_id": {oauth.ClientID}, + "client_id": {oauth.ClientID}, "refresh_token": {r}, "grant_type": {"refresh_token"}, } diff --git a/internal/server/api_test.go b/internal/server/api_test.go index 00fba3d..b1e3550 100644 --- a/internal/server/api_test.go +++ b/internal/server/api_test.go @@ -10,7 +10,6 @@ import ( "github.com/go-errors/errors" ) - func getErrorMsg(err error) string { if err == nil { return "" @@ -44,49 +43,49 @@ func Test_APIGetEndpoints(t *testing.T) { }{ { epl: EndpointList{ - API: "https://example.com/1", + API: "https://example.com/1", Authorization: "https://example.com/2", - Token: "https://example.com/3", + Token: "https://example.com/3", }, err: nil, }, { epl: EndpointList{ - API: "http://example.com/1", + API: "http://example.com/1", Authorization: "https://example.com/2", - Token: "https://example.com/3", + Token: "https://example.com/3", }, err: errors.New("API scheme: 'http', is not equal to authorization scheme: 'https'"), }, { epl: EndpointList{ - API: "https://example.com/1", + API: "https://example.com/1", Authorization: "https://example.com/2", - Token: "ftp://example.com/3", + Token: "ftp://example.com/3", }, err: errors.New("API scheme: 'https', is not equal to token scheme: 'ftp'"), }, { epl: EndpointList{ - API: "https://malicious.com/1", + API: "https://malicious.com/1", Authorization: "https://example.com/2", - Token: "https://example.com/3", + Token: "https://example.com/3", }, err: errors.New("API host: 'malicious.com', is not equal to authorization host: 'example.com'"), }, { epl: EndpointList{ - API: "https://example.com/1", + API: "https://example.com/1", Authorization: "https://example.com/2", - Token: "https://malicious.com/3", + Token: "https://malicious.com/3", }, err: errors.New("API host: 'example.com', is not equal to token host: 'malicious.com'"), }, { epl: EndpointList{ - API: "https://example.com/1", + API: "https://example.com/1", Authorization: "https://malicious.com/2", - Token: "https://example.com/3", + Token: "https://example.com/3", }, err: errors.New("API host: 'example.com', is not equal to authorization host: 'malicious.com'"), }, @@ -99,7 +98,7 @@ func Test_APIGetEndpoints(t *testing.T) { }, } // Update the handler - hs.SetHandler(http.HandlerFunc(func (w http.ResponseWriter, r *http.Request) { + hs.SetHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") jsonStr, err := json.Marshal(ep) @@ -108,7 +107,6 @@ func Test_APIGetEndpoints(t *testing.T) { } fmt.Fprintln(w, string(jsonStr)) - })) gotEP, err := APIGetEndpoints(s.URL, c) if getErrorMsg(err) != getErrorMsg(tc.err) { diff --git a/internal/server/base.go b/internal/server/base.go index 87bb488..bfa0d73 100644 --- a/internal/server/base.go +++ b/internal/server/base.go @@ -2,6 +2,7 @@ package server import ( "time" + "github.com/eduvpn/eduvpn-common/internal/http" ) diff --git a/internal/server/server.go b/internal/server/server.go index c68916e..ef02612 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -41,7 +41,7 @@ type EndpointsVersions struct { // Endpoints defines the json format for /.well-known/vpn-user-portal". type Endpoints struct { API EndpointsVersions `json:"api"` - V string `json:"v"` + V string `json:"v"` } // ShouldRenewButton returns whether or not the renew button should be shown for the server diff --git a/internal/test/handler.go b/internal/test/handler.go index 5c02629..3991c6a 100644 --- a/internal/test/handler.go +++ b/internal/test/handler.go @@ -7,7 +7,7 @@ import ( // HandlerSet is a struct with a mutex that allows us to swap handlers while a test server is running type HandlerSet struct { - mu sync.Mutex + mu sync.Mutex handler http.Handler } diff --git a/internal/test/server.go b/internal/test/server.go index e020d69..841b565 100644 --- a/internal/test/server.go +++ b/internal/test/server.go @@ -6,6 +6,7 @@ import ( "crypto/x509" "net/http" "net/http/httptest" + httpw "github.com/eduvpn/eduvpn-common/internal/http" "github.com/go-errors/errors" ) |
