summaryrefslogtreecommitdiff
path: root/src/server_test.go
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-04-20 16:46:52 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-04-20 16:46:52 +0200
commit1a311e1820852cb9ea6ce646c0880e6b6915c657 (patch)
treee087dc4e5d05b25715d9295faff5a668e7556e27 /src/server_test.go
parentb73e1489b06fd4546da6ba32697331584db02e71 (diff)
Server Test: Add back invalid token tests
Diffstat (limited to 'src/server_test.go')
-rw-r--r--src/server_test.go82
1 files changed, 43 insertions, 39 deletions
diff --git a/src/server_test.go b/src/server_test.go
index 6199884..84da6a3 100644
--- a/src/server_test.go
+++ b/src/server_test.go
@@ -159,42 +159,46 @@ func Test_token_expired(t *testing.T) {
}
}
-// FIXME:This needs to be uncommented when we can go to an oauth state in the fsm even if we're already authenticated
-//func Test_token_invalid(t *testing.T) {
-// state := GetVPNState()
-//
-// // Do not verify because during testing, the cert is self-signed
-// http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
-//
-// state.Deregister()
-//
-// state.Register("org.eduvpn.app.linux", "configsinvalid", func(old string, new string, data string) {
-// StateCallback(t, old, new, data)
-// }, false)
-//
-// _, configErr := state.Connect("https://eduvpnserver")
-//
-// if configErr != nil {
-// t.Errorf("Connect error before invalid: %v", configErr)
-// }
-//
-// dummy_value := "37"
-//
-// // Override tokens with invalid values
-// state.Server.OAuth.Token.Access = dummy_value
-// state.Server.OAuth.Token.Refresh = dummy_value
-//
-// infoErr := state.Server.APIInfo()
-//
-// if infoErr != nil {
-// t.Errorf("Info error after invalid: %v", infoErr)
-// }
-//
-// if state.Server.OAuth.Token.Access == dummy_value {
-// t.Errorf("Access token is equal to dummy value: %s", dummy_value)
-// }
-//
-// if state.Server.OAuth.Token.Refresh == dummy_value {
-// t.Errorf("Refresh token is equal to dummy value: %s", dummy_value)
-// }
-//}
+func Test_token_invalid(t *testing.T) {
+ state := GetVPNState()
+
+ // Do not verify because during testing, the cert is self-signed
+ http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
+
+ state.Deregister()
+
+ state.Register("org.eduvpn.app.linux", "configsinvalid", func(old string, new string, data string) {
+ StateCallback(t, old, new, data)
+ }, false)
+
+ _, configErr := state.Connect("https://eduvpnserver")
+
+ if configErr != nil {
+ t.Errorf("Connect error before invalid: %v", configErr)
+ }
+
+ // Fake connect and then back to authenticated so that we can re-authenticate
+ // Going to authenticated fakes a disconnect
+ state.GoTransition(CONNECTED, "")
+ state.GoTransition(AUTHENTICATED, "")
+
+ dummy_value := "37"
+
+ // Override tokens with invalid values
+ state.Server.OAuth.Token.Access = dummy_value
+ state.Server.OAuth.Token.Refresh = dummy_value
+
+ infoErr := state.Server.APIInfo()
+
+ if infoErr != nil {
+ t.Errorf("Info error after invalid: %v", infoErr)
+ }
+
+ if state.Server.OAuth.Token.Access == dummy_value {
+ t.Errorf("Access token is equal to dummy value: %s", dummy_value)
+ }
+
+ if state.Server.OAuth.Token.Refresh == dummy_value {
+ t.Errorf("Refresh token is equal to dummy value: %s", dummy_value)
+ }
+}