diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-05-06 13:49:48 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-05-06 13:49:48 +0200 |
| commit | 851d2e331cb2a8313529254d119fb0c9ae78c873 (patch) | |
| tree | 77e082e8830958051bc6c21057ff78fc505a35a4 /state_test.go | |
| parent | f82f65084b77d2e8f9e8be323fedf169270a9824 (diff) | |
Well known: Add override for local server path using env var
Diffstat (limited to 'state_test.go')
| -rw-r--r-- | state_test.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/state_test.go b/state_test.go index 6b05091..59b4f02 100644 --- a/state_test.go +++ b/state_test.go @@ -14,6 +14,14 @@ import ( "github.com/jwijenbergh/eduvpn-common/internal" ) +func ensureLocalWellKnown() { + wellKnown := os.Getenv("SERVER_IS_LOCAL") + + if wellKnown == "1" { + internal.WellKnownPath = "well-known.php" + } +} + func getServerURI(t *testing.T) string { serverURI := os.Getenv("SERVER_URI") if serverURI == "" { @@ -54,6 +62,7 @@ func stateCallback(t *testing.T, oldState string, newState string, data string, func Test_server(t *testing.T) { serverURI := getServerURI(t) state := &VPNState{} + ensureLocalWellKnown() state.Register("org.eduvpn.app.linux", "configstest", func(old string, new string, data string) { stateCallback(t, old, new, data, state) @@ -132,6 +141,8 @@ func Test_connect_oauth_parameters(t *testing.T) { {&failedCallbackStateMatchError, internal.URLParameters{"code": "42", "state": "21"}}, } + ensureLocalWellKnown() + for _, test := range tests { test_connect_oauth_parameter(t, test.parameters, test.expectedErr) } @@ -145,6 +156,8 @@ func Test_token_expired(t *testing.T) { return } + ensureLocalWellKnown() + // Convert the env variable to an int and signal error if it is not possible expiredInt, expiredErr := strconv.Atoi(expiredTTL) if expiredErr != nil { @@ -200,6 +213,8 @@ func Test_token_invalid(t *testing.T) { serverURI := getServerURI(t) state := &VPNState{} + ensureLocalWellKnown() + state.Register("org.eduvpn.app.linux", "configsinvalid", func(old string, new string, data string) { stateCallback(t, old, new, data, state) }, false) |
