diff options
| author | Jeroen Wijenbergh <jeroenwijenbergh@protonmail.com> | 2022-04-25 16:42:38 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-04-25 16:42:38 +0200 |
| commit | a20beedd3b35b974d7bce325cc3f1959489e7443 (patch) | |
| tree | 3a394632b9f3cea3d4db0641c01a7ed9bf8be4a3 | |
| parent | 44df9cb92abe66cf12e887ef19e60a01461b3558 (diff) | |
Tests: Skip server tests if no SERVER_URI is passed
| -rw-r--r-- | ci/docker/docker-compose.yml | 2 | ||||
| -rw-r--r-- | state_test.go | 16 |
2 files changed, 12 insertions, 6 deletions
diff --git a/ci/docker/docker-compose.yml b/ci/docker/docker-compose.yml index 60bd21d..7e102e4 100644 --- a/ci/docker/docker-compose.yml +++ b/ci/docker/docker-compose.yml @@ -2,10 +2,12 @@ version: '3' # Common environment vars # These are the credentials for the portal +# And the URI of the server x-common-env: &common-env PORTAL_USER: ${PORTAL_USER} PORTAL_PASS: ${PORTAL_PASS} OAUTH_EXPIRED_TTL: ${OAUTH_EXPIRED_TTL} + SERVER_URI: "https://eduvpnserver" # Define a network so that the containers can talk with eachother using their service name networks: diff --git a/state_test.go b/state_test.go index ce81ba8..9527528 100644 --- a/state_test.go +++ b/state_test.go @@ -14,10 +14,10 @@ import ( "github.com/jwijenbergh/eduvpn-common/internal" ) -func getServerURI() string { +func getServerURI(t *testing.T) string { serverURI := os.Getenv("SERVER_URI") if serverURI == "" { - serverURI = "https://eduvpnserver" + t.Skip("Skipping server test as no SERVER_URI env var has been passed") } return serverURI } @@ -51,13 +51,14 @@ func stateCallback(t *testing.T, oldState string, newState string, data string) } func Test_server(t *testing.T) { + serverURI := getServerURI(t) state := &VPNState{} state.Register("org.eduvpn.app.linux", "configstest", func(old string, new string, data string) { stateCallback(t, old, new, data) }, false) - _, configErr := state.Connect(getServerURI()) + _, configErr := state.Connect(serverURI) if configErr != nil { t.Errorf("Connect error: %v", configErr) @@ -65,6 +66,7 @@ func Test_server(t *testing.T) { } func test_connect_oauth_parameter(t *testing.T, parameters internal.URLParameters, expectedErr interface{}) { + serverURI := getServerURI(t) state := &VPNState{} configDirectory := "test_oauth_parameters" @@ -79,7 +81,7 @@ func test_connect_oauth_parameter(t *testing.T, parameters internal.URLParameter } }, false) - _, configErr := state.Connect(getServerURI()) + _, configErr := state.Connect(serverURI) if !errors.As(configErr, expectedErr) { t.Errorf("error %T = %v, wantErr %T", configErr, configErr, expectedErr) @@ -107,6 +109,7 @@ func Test_connect_oauth_parameters(t *testing.T) { } func Test_token_expired(t *testing.T) { + serverURI := getServerURI(t) expiredTTL := os.Getenv("OAUTH_EXPIRED_TTL") if expiredTTL == "" { t.Log("No expired TTL present, skipping this test. Set EXPIRED_TTL env variable to run it") @@ -126,7 +129,7 @@ func Test_token_expired(t *testing.T) { stateCallback(t, old, new, data) }, false) - _, configErr := state.Connect(getServerURI()) + _, configErr := state.Connect(serverURI) if configErr != nil { t.Errorf("Connect error before expired: %v", configErr) @@ -163,13 +166,14 @@ func Test_token_expired(t *testing.T) { } func Test_token_invalid(t *testing.T) { + serverURI := getServerURI(t) state := &VPNState{} state.Register("org.eduvpn.app.linux", "configsinvalid", func(old string, new string, data string) { stateCallback(t, old, new, data) }, false) - _, configErr := state.Connect(getServerURI()) + _, configErr := state.Connect(serverURI) if configErr != nil { t.Errorf("Connect error before invalid: %v", configErr) |
