Skip to content

Commit

Permalink
misc fixes (#1543)
Browse files Browse the repository at this point in the history
* fix TransportDetails string formatting (fixes #1486)
* reading private ssh key for cryptosign (fixes #932)
  • Loading branch information
oberstet committed Apr 9, 2022
1 parent b8b9096 commit 8d4d788
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,7 @@ test_tx_cryptobox:
test_tx_choosereactor:
USE_TWISTED=1 trial autobahn.twisted.test.test_choosereactor

test_tx_cryptosign:
#USE_ASYNCIO=1 trial autobahn.wamp.test.test_wamp_cryptosign.TestAuth.test_testvectors
#USE_TWISTED=1 trial autobahn.wamp.test.test_wamp_cryptosign.TestAuth.test_testvectors
test_cryptosign:
USE_ASYNCIO=1 trial autobahn.wamp.test.test_wamp_cryptosign
USE_TWISTED=1 trial autobahn.wamp.test.test_wamp_cryptosign

Expand Down
2 changes: 1 addition & 1 deletion autobahn/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
#
###############################################################################

__version__ = '22.4.1.dev2'
__version__ = '22.4.1.dev3'

__build__ = '00000000-0000000'
5 changes: 3 additions & 2 deletions autobahn/wamp/cryptosign.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ def get_string(self):
return self.get_bytes(self.get_uint32())


def _makepad(size):
return ''.join(chr(x) for x in range(1, size + 1))
def _makepad(size: int) -> bytes:
assert 0 <= size < 255
return b''.join(x.to_bytes(1, byteorder='big') for x in range(1, size + 1))


def _read_ssh_ed25519_privkey(keydata):
Expand Down
8 changes: 5 additions & 3 deletions autobahn/wamp/test/test_wamp_cryptosign.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,11 @@ def failed(err):
class TestKey(unittest.TestCase):

def test_pad(self):
self.assertEqual(_makepad(0), '')
self.assertEqual(_makepad(2), '\x01\x02')
self.assertEqual(_makepad(3), '\x01\x02\x03')
self.assertEqual(_makepad(0), b'')
self.assertEqual(_makepad(2), b'\x01\x02')
self.assertEqual(_makepad(3), b'\x01\x02\x03')
self.assertEqual(_makepad(30), b'\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e')
self.assertEqual(binascii.b2a_hex(_makepad(30)).decode(), '0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e')

def test_key(self):
with tempfile.NamedTemporaryFile('w+t') as fp:
Expand Down
11 changes: 5 additions & 6 deletions autobahn/websocket/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
#
###############################################################################

from pprint import pformat
from autobahn.util import public

import json

__all__ = (
'ConnectionRequest',
'ConnectionResponse',
Expand Down Expand Up @@ -121,7 +120,7 @@ def __json__(self):
'extensions': self.extensions}

def __str__(self):
return json.dumps(self.__json__())
return pformat(self.__json__())


@public
Expand Down Expand Up @@ -185,7 +184,7 @@ def __json__(self):
}

def __str__(self):
return json.dumps(self.__json__())
return pformat(self.__json__())


@public
Expand Down Expand Up @@ -226,7 +225,7 @@ def __json__(self):
}

def __str__(self):
return json.dumps(self.__json__())
return pformat(self.__json__())


@public
Expand Down Expand Up @@ -278,7 +277,7 @@ def __json__(self):
'extensions': self.extensions}

def __str__(self):
return json.dumps(self.__json__())
return pformat(self.__json__())


@public
Expand Down
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Changelog
22.4.1.devX
-----------

* fix: string formatting with binary values in TransportDetails.secure_channel_id (#1483)
* fix: never default set authid/authrole in component authenticators
* fix: do not throw (but log) when leaving a session not joined
* fix: store WAMP authextra received
Expand Down

0 comments on commit 8d4d788

Please sign in to comment.