diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-08-15 14:41:28 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-08-15 14:41:28 +0200 |
| commit | fec6ea1eba9cee325bbd9d82aa71b8ebf5ef90b0 (patch) | |
| tree | dec0894380a2de8721a1e7733d75053bcc5181fc /state_test.go | |
| parent | c5e85ba79d4d091af9873f1fb0e7415c3b17b9f8 (diff) | |
Refactor: Use constants for state callbacks instead of strings
Diffstat (limited to 'state_test.go')
| -rw-r--r-- | state_test.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/state_test.go b/state_test.go index c42b314..082a93c 100644 --- a/state_test.go +++ b/state_test.go @@ -57,8 +57,8 @@ func loginOAuthSelenium(t *testing.T, url string, state *VPNState) { } } -func stateCallback(t *testing.T, oldState string, newState string, data string, state *VPNState) { - if newState == "OAuth_Started" { +func stateCallback(t *testing.T, oldState VPNStateID, newState VPNStateID, data string, state *VPNState) { + if newState == fsm.OAUTH_STARTED { loginOAuthSelenium(t, data, state) } } @@ -68,7 +68,7 @@ func Test_server(t *testing.T) { state := &VPNState{} ensureLocalWellKnown() - state.Register("org.eduvpn.app.linux", "configstest", func(old string, new string, data string) { + state.Register("org.eduvpn.app.linux", "configstest", func(old VPNStateID, new VPNStateID, data string) { stateCallback(t, old, new, data, state) }, false) @@ -84,8 +84,8 @@ func test_connect_oauth_parameter(t *testing.T, parameters httpw.URLParameters, state := &VPNState{} configDirectory := "test_oauth_parameters" - state.Register("org.eduvpn.app.linux", configDirectory, func(oldState string, newState string, data string) { - if newState == "OAuth_Started" { + state.Register("org.eduvpn.app.linux", configDirectory, func(oldState VPNStateID, newState VPNStateID, data string) { + if newState == fsm.OAUTH_STARTED { baseURL := "http://127.0.0.1:8000/callback" url, err := httpw.HTTPConstructURL(baseURL, parameters) if err != nil { @@ -153,7 +153,7 @@ func Test_token_expired(t *testing.T) { // Get a vpn state state := &VPNState{} - state.Register("org.eduvpn.app.linux", "configsexpired", func(old string, new string, data string) { + state.Register("org.eduvpn.app.linux", "configsexpired", func(old VPNStateID, new VPNStateID, data string) { stateCallback(t, old, new, data, state) }, false) @@ -201,7 +201,7 @@ func Test_token_invalid(t *testing.T) { ensureLocalWellKnown() - state.Register("org.eduvpn.app.linux", "configsinvalid", func(old string, new string, data string) { + state.Register("org.eduvpn.app.linux", "configsinvalid", func(old VPNStateID, new VPNStateID, data string) { stateCallback(t, old, new, data, state) }, false) @@ -251,7 +251,7 @@ func Test_invalid_profile_corrected(t *testing.T) { ensureLocalWellKnown() - state.Register("org.eduvpn.app.linux", "configscancelprofile", func(old string, new string, data string) { + state.Register("org.eduvpn.app.linux", "configscancelprofile", func(old VPNStateID, new VPNStateID, data string) { stateCallback(t, old, new, data, state) }, false) |
