Skip to content

Commit

Permalink
Fix 1566 (#1567)
Browse files Browse the repository at this point in the history
* add test for WebSocketServerProtocol.sendServerStatus

* fix string interpolation in _SERVER_STATUS_TEMPLATE (fixes #1566)
  • Loading branch information
oberstet committed May 11, 2022
1 parent 2e2ee5f commit 31d36af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 4 additions & 4 deletions autobahn/websocket/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -2499,16 +2499,16 @@ def prepareMessage(self, payload, isBinary=False, doNotCompress=False):
<head>
{}
<style>
body {
body {{
color: #fff;
background-color: #027eae;
font-family: "Segoe UI", "Lucida Grande", "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 16px;
}
}}
a, a:visited, a:hover {
a, a:visited, a:hover {{
color: #fff;
}
}}
</style>
</head>
<body>
Expand Down
9 changes: 9 additions & 0 deletions autobahn/websocket/test/test_websocket_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ def test_sendClose_invalid_code_value(self):
self.assertEqual(self.transport._written, b"")
self.assertEqual(self.protocol.state, self.protocol.STATE_OPEN)

def test_interpolate_server_status_template(self):
from autobahn.websocket.protocol import _SERVER_STATUS_TEMPLATE
s = _SERVER_STATUS_TEMPLATE.format(None, '0.0.0')
self.assertEqual(type(s), str)
self.assertTrue(len(s) > 0)


if os.environ.get('USE_TWISTED', False):
class TwistedProtocolTests(unittest.TestCase):
Expand Down Expand Up @@ -270,3 +276,6 @@ def test_loseConnection(self):
# that here
self.protocol._connectionLost(txaio.create_failure(RuntimeError("testing")))
self.assertTrue(self.protocol.openHandshakeTimeoutCall is None)

def test_send_server_status(self):
self.protocol.sendServerStatus()

0 comments on commit 31d36af

Please sign in to comment.