diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-04-26 15:43:35 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-04-26 15:43:35 +0200 |
| commit | 75aa163ccf407e9690f9ea0e548f8fed70073722 (patch) | |
| tree | dd68386a24c8c479149d094bb209fb0a78071c06 /state_test.go | |
| parent | a5d33f95ba68263e6c0ca758c5b854530332d9ae (diff) | |
OAuth: Add a Cancel method
Diffstat (limited to 'state_test.go')
| -rw-r--r-- | state_test.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/state_test.go b/state_test.go index 9527528..9578307 100644 --- a/state_test.go +++ b/state_test.go @@ -34,19 +34,20 @@ func runCommand(t *testing.T, errBuffer *strings.Builder, name string, args ...s return cmd.Wait() } -func loginOAuthSelenium(t *testing.T, url string) { +func loginOAuthSelenium(t *testing.T, url string, state *VPNState) { // We could use the go selenium library // But it does not support the latest selenium v4 just yet var errBuffer strings.Builder err := runCommand(t, &errBuffer, "python3", "selenium_eduvpn.py", url) if err != nil { t.Errorf("Login OAuth with selenium script failed with error %v and stderr %s", err, errBuffer.String()) + state.CancelOAuth() } } -func stateCallback(t *testing.T, oldState string, newState string, data string) { +func stateCallback(t *testing.T, oldState string, newState string, data string, state *VPNState) { if newState == "OAuth_Started" { - go loginOAuthSelenium(t, data) + loginOAuthSelenium(t, data, state) } } @@ -55,7 +56,7 @@ func Test_server(t *testing.T) { state := &VPNState{} state.Register("org.eduvpn.app.linux", "configstest", func(old string, new string, data string) { - stateCallback(t, old, new, data) + stateCallback(t, old, new, data, state) }, false) _, configErr := state.Connect(serverURI) @@ -126,7 +127,7 @@ func Test_token_expired(t *testing.T) { state := &VPNState{} state.Register("org.eduvpn.app.linux", "configsexpired", func(old string, new string, data string) { - stateCallback(t, old, new, data) + stateCallback(t, old, new, data, state) }, false) _, configErr := state.Connect(serverURI) @@ -170,7 +171,7 @@ func Test_token_invalid(t *testing.T) { state := &VPNState{} state.Register("org.eduvpn.app.linux", "configsinvalid", func(old string, new string, data string) { - stateCallback(t, old, new, data) + stateCallback(t, old, new, data, state) }, false) _, configErr := state.Connect(serverURI) |
