Skip to content

Commit

Permalink
Websocket origin use port returned by bind_sockets (#10178)
Browse files Browse the repository at this point in the history
  • Loading branch information
xavArtley committed Jun 16, 2020
1 parent 5bcb525 commit bd947ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bokeh/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def __init__(self, applications, io_loop=None, http_server_kwargs=None, **kwargs
sockets, self._port = bind_sockets(opts.address, opts.port)
self._address = opts.address

extra_websocket_origins = create_hosts_allowlist(opts.allow_websocket_origin, opts.port)
extra_websocket_origins = create_hosts_allowlist(opts.allow_websocket_origin, self.port)
try:
tornado_app = BokehTornado(applications,
extra_websocket_origins=extra_websocket_origins,
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/bokeh/test_client_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ async def check_http_blocked_socket_blocked(self, server, origin=None):
async def test_allow_websocket_origin(self, ManagedServerLoop) -> None:
application = Application()

# allow good local origin with random port
with ManagedServerLoop(application, port=0) as server:
await self.check_http_ok_socket_ok(server, origin="http://localhost:%s" % server.port)

# allow good origin
with ManagedServerLoop(application, allow_websocket_origin=["example.com"]) as server:
await self.check_http_ok_socket_ok(server, origin="http://example.com:80")
Expand Down

0 comments on commit bd947ea

Please sign in to comment.