Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions tests/async/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,76 +107,76 @@ def test_missing_auth(self):

@with_instrumented_server(auth=False)
def test_admin_connect_with_no_auth(self):
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin')
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin',
auth={'foo': 'bar'})

@with_instrumented_server(auth={'foo': 'bar'})
def test_admin_connect_with_dict_auth(self):
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin',
auth={'foo': 'bar'})
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
with pytest.raises(ConnectionError):
admin_client.connect(
'http://localhost:8900', namespace='/admin',
auth={'foo': 'baz'})
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
with pytest.raises(ConnectionError):
admin_client.connect(
'http://localhost:8900', namespace='/admin')

@with_instrumented_server(auth=[{'foo': 'bar'},
{'u': 'admin', 'p': 'secret'}])
def test_admin_connect_with_list_auth(self):
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin',
auth={'foo': 'bar'})
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin',
auth={'u': 'admin', 'p': 'secret'})
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
with pytest.raises(ConnectionError):
admin_client.connect('http://localhost:8900',
namespace='/admin', auth={'foo': 'baz'})
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
with pytest.raises(ConnectionError):
admin_client.connect('http://localhost:8900',
namespace='/admin')

@with_instrumented_server(auth=_custom_auth)
def test_admin_connect_with_function_auth(self):
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin',
auth={'foo': 'bar'})
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
with pytest.raises(ConnectionError):
admin_client.connect('http://localhost:8900',
namespace='/admin', auth={'foo': 'baz'})
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
with pytest.raises(ConnectionError):
admin_client.connect('http://localhost:8900',
namespace='/admin')

@with_instrumented_server(auth=_async_custom_auth)
def test_admin_connect_with_async_function_auth(self):
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin',
auth={'foo': 'bar'})
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
with pytest.raises(ConnectionError):
admin_client.connect('http://localhost:8900',
namespace='/admin', auth={'foo': 'baz'})
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
with pytest.raises(ConnectionError):
admin_client.connect('http://localhost:8900',
namespace='/admin')

@with_instrumented_server()
def test_admin_connect_only_admin(self):
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin')
sid = admin_client.sid
events = self._expect({'config': 1, 'all_sockets': 1,
Expand All @@ -201,10 +201,10 @@ def test_admin_connect_only_admin(self):

@with_instrumented_server()
def test_admin_connect_with_others(self):
with socketio.SimpleClient() as client1, \
socketio.SimpleClient() as client2, \
socketio.SimpleClient() as client3, \
socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as client1, \
socketio.SimpleClient(reconnection=False) as client2, \
socketio.SimpleClient(reconnection=False) as client3, \
socketio.SimpleClient(reconnection=False) as admin_client:
client1.connect('http://localhost:8900')
client1.emit('enter_room', 'room')
sid1 = client1.sid
Expand Down Expand Up @@ -251,7 +251,7 @@ def test_admin_connect_with_others(self):

@with_instrumented_server(mode='production', read_only=True)
def test_admin_connect_production(self):
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin')
events = self._expect({'config': 1, 'server_stats': 2},
admin_client)
Expand All @@ -272,9 +272,9 @@ def test_admin_connect_production(self):

@with_instrumented_server()
def test_admin_features(self):
with socketio.SimpleClient() as client1, \
socketio.SimpleClient() as client2, \
socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as client1, \
socketio.SimpleClient(reconnection=False) as client2, \
socketio.SimpleClient(reconnection=False) as admin_client:
client1.connect('http://localhost:8900')
client2.connect('http://localhost:8900')
admin_client.connect('http://localhost:8900', namespace='/admin')
Expand Down
42 changes: 21 additions & 21 deletions tests/common/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,62 +97,62 @@ def test_missing_auth(self):

@with_instrumented_server(auth=False)
def test_admin_connect_with_no_auth(self):
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin')
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin',
auth={'foo': 'bar'})

@with_instrumented_server(auth={'foo': 'bar'})
def test_admin_connect_with_dict_auth(self):
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin',
auth={'foo': 'bar'})
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
with pytest.raises(ConnectionError):
admin_client.connect(
'http://localhost:8900', namespace='/admin',
auth={'foo': 'baz'})
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
with pytest.raises(ConnectionError):
admin_client.connect(
'http://localhost:8900', namespace='/admin')

@with_instrumented_server(auth=[{'foo': 'bar'},
{'u': 'admin', 'p': 'secret'}])
def test_admin_connect_with_list_auth(self):
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin',
auth={'foo': 'bar'})
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin',
auth={'u': 'admin', 'p': 'secret'})
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
with pytest.raises(ConnectionError):
admin_client.connect('http://localhost:8900',
namespace='/admin', auth={'foo': 'baz'})
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
with pytest.raises(ConnectionError):
admin_client.connect('http://localhost:8900',
namespace='/admin')

@with_instrumented_server(auth=_custom_auth)
def test_admin_connect_with_function_auth(self):
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin',
auth={'foo': 'bar'})
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
with pytest.raises(ConnectionError):
admin_client.connect('http://localhost:8900',
namespace='/admin', auth={'foo': 'baz'})
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
with pytest.raises(ConnectionError):
admin_client.connect('http://localhost:8900',
namespace='/admin')

@with_instrumented_server()
def test_admin_connect_only_admin(self):
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin')
sid = admin_client.sid
events = self._expect({'config': 1, 'all_sockets': 1,
Expand All @@ -177,10 +177,10 @@ def test_admin_connect_only_admin(self):

@with_instrumented_server()
def test_admin_connect_with_others(self):
with socketio.SimpleClient() as client1, \
socketio.SimpleClient() as client2, \
socketio.SimpleClient() as client3, \
socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as client1, \
socketio.SimpleClient(reconnection=False) as client2, \
socketio.SimpleClient(reconnection=False) as client3, \
socketio.SimpleClient(reconnection=False) as admin_client:
client1.connect('http://localhost:8900')
client1.emit('enter_room', 'room')
sid1 = client1.sid
Expand Down Expand Up @@ -227,7 +227,7 @@ def test_admin_connect_with_others(self):

@with_instrumented_server(mode='production', read_only=True)
def test_admin_connect_production(self):
with socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin')
events = self._expect({'config': 1, 'server_stats': 2},
admin_client)
Expand All @@ -248,9 +248,9 @@ def test_admin_connect_production(self):

@with_instrumented_server()
def test_admin_features(self):
with socketio.SimpleClient() as client1, \
socketio.SimpleClient() as client2, \
socketio.SimpleClient() as admin_client:
with socketio.SimpleClient(reconnection=False) as client1, \
socketio.SimpleClient(reconnection=False) as client2, \
socketio.SimpleClient(reconnection=False) as admin_client:
client1.connect('http://localhost:8900')
client2.connect('http://localhost:8900')
admin_client.connect('http://localhost:8900', namespace='/admin')
Expand Down
2 changes: 1 addition & 1 deletion tests/web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def get_environ(self):
env['gunicorn.socket'] = self.connection
return env

self.httpd = make_server('', port, self._app_wrapper,
self.httpd = make_server('localhost', port, self._app_wrapper,
ThreadingWSGIServer, WebSocketRequestHandler)
self.thread = threading.Thread(target=self.httpd.serve_forever)
self.thread.start()
Expand Down
Loading