summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSolly Ross <sross@redhat.com>2015-08-25 16:44:24 -0400
committerSolly Ross <sross@redhat.com>2015-08-25 17:52:20 -0400
commit1e2b5c2256d31e34083935f8adb2c8433cd40f7f (patch)
tree6e445718408ab9bfd5290aafed21f288051586d3 /tests
parent6c1543c05b79ae8bef2d2f7d703002a432776baf (diff)
downloadwebsockify-1e2b5c2256d31e34083935f8adb2c8433cd40f7f.tar.gz
Rework Auth Plugins to Support HTTP Authfeature/http-auth-plugins
This commit reworks auth plugins slightly to enable support for HTTP authentication. By raising an AuthenticationError, auth plugins can now return HTTP responses to the upgrade request (such as 401). Related to kanaka/noVNC#522
Diffstat (limited to 'tests')
-rw-r--r--tests/test_websocketproxy.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/test_websocketproxy.py b/tests/test_websocketproxy.py
index 8103ef6..92fd5db 100644
--- a/tests/test_websocketproxy.py
+++ b/tests/test_websocketproxy.py
@@ -106,11 +106,11 @@ class ProxyRequestHandlerTestCase(unittest.TestCase):
def lookup(self, token):
return (self.source + token).split(',')
- self.stubs.Set(websocketproxy.ProxyRequestHandler, 'do_proxy',
- lambda *args, **kwargs: None)
+ self.stubs.Set(websocketproxy.ProxyRequestHandler, 'send_auth_error',
+ staticmethod(lambda *args, **kwargs: None))
self.handler.server.token_plugin = TestPlugin("somehost,")
- self.handler.new_websocket_client()
+ self.handler.validate_connection()
self.assertEqual(self.handler.server.target_host, "somehost")
self.assertEqual(self.handler.server.target_port, "blah")
@@ -119,9 +119,9 @@ class ProxyRequestHandlerTestCase(unittest.TestCase):
class TestPlugin(auth_plugins.BasePlugin):
def authenticate(self, headers, target_host, target_port):
if target_host == self.source:
- raise auth_plugins.AuthenticationError("some error")
+ raise auth_plugins.AuthenticationError(response_msg="some_error")
- self.stubs.Set(websocketproxy.ProxyRequestHandler, 'do_proxy',
+ self.stubs.Set(websocketproxy.ProxyRequestHandler, 'send_auth_error',
staticmethod(lambda *args, **kwargs: None))
self.handler.server.auth_plugin = TestPlugin("somehost")
@@ -129,8 +129,8 @@ class ProxyRequestHandlerTestCase(unittest.TestCase):
self.handler.server.target_port = "someport"
self.assertRaises(auth_plugins.AuthenticationError,
- self.handler.new_websocket_client)
+ self.handler.validate_connection)
self.handler.server.target_host = "someotherhost"
- self.handler.new_websocket_client()
+ self.handler.validate_connection()