Changeset - 690e7a035521
[Not reviewed]
stable
0 1 0
Thomas De Schampheleire - 6 years ago 2019-12-06 21:13:41
thomas.de_schampheleire@nokia.com
ssh: add doctest showing incorrect handling of ed25519 keys

This doctest just demonstrates that ed25519 keys are not treated correctly
by parse_pub_key(). A subsequent commit will actually fix it.
1 file changed with 5 insertions and 0 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/ssh.py
Show inline comments
 
@@ -63,12 +63,17 @@ def parse_pub_key(ssh_key):
 
    Traceback (most recent call last):
 
    ...
 
    SshKeyParseError: Incorrect SSH key - unexpected characters in base64 part "AAAAB3NzaC1yc2EAAAA'LVGhpcyBpcyBmYWtlIQ"
 
    >>> parse_pub_key(''' ssh-rsa  AAAAB3NzaC1yc2EAAAALVGhpcyBpcyBmYWtlIQ== and a comment
 
    ... ''')
 
    ('ssh-rsa', '\x00\x00\x00\x07ssh-rsa\x00\x00\x00\x0bThis is fake!', 'and a comment\n')
 
    >>> # FIXME below test shows incorrect behavior -- to be fixed in a subsequent commit
 
    >>> parse_pub_key('''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP1NA2kBQIKe74afUXmIWD9ByDYQJqUwW44Y4gJOBRuo''')
 
    Traceback (most recent call last):
 
    ...
 
    SshKeyParseError: Incorrect SSH key - base64 part is not 'ssh-ed25519' as claimed but 'ssh-ed25519'
 
    """
 
    if not ssh_key:
 
        raise SshKeyParseError(_("SSH key is missing"))
 

	
 
    parts = ssh_key.split(None, 2)
 
    if len(parts) < 2:
0 comments (0 inline, 0 general)