Improve osusers.models coverage

This commit adds tests for more corner cases of
SshPublicKeyManager.parse_keytext to raise the test coverage to 100%.
The method now handles invalid keys more thoroughly.
This commit is contained in:
Jan Dittberner 2015-12-06 17:47:27 +01:00
parent 8616b2d6c9
commit 28ff099df9
2 changed files with 46 additions and 1 deletions

View file

@ -468,6 +468,8 @@ class SshPublicKeyManager(models.Manager):
except TypeError:
raise ValueError('invalid SSH public key')
parts = keybytes.split(b'\x00' * 3)
if len(parts) < 2:
raise ValueError('invalid SSH public key')
alglength = six.byte2int(parts[1])
algname = parts[1][1:1+alglength]
return algname, data, comment