Merge lp:~rvb/maas/bug-1270052 into lp:~maas-committers/maas/trunk

Proposed by Raphaël Badin
Status: Merged
Approved by: Graham Binns
Approved revision: no longer in the source branch.
Merged at revision: 1821
Proposed branch: lp:~rvb/maas/bug-1270052
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 45 lines (+11/-3)
3 files modified
src/maasserver/models/sshkey.py (+1/-1)
src/maasserver/models/tests/test_sshkey.py (+8/-0)
src/provisioningserver/pxe/config.py (+2/-2)
To merge this branch: bzr merge lp:~rvb/maas/bug-1270052
Reviewer Review Type Date Requested Status
Graham Binns (community) Approve
Review via email: mp+202052@code.launchpad.net

Commit message

Make sshkey.py:validate_ssh_public_key cope with UnicodeEncodeError.

Description of the change

Drive-by fix: fix lint.

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) wrote :

Nice work!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/maasserver/models/sshkey.py'
--- src/maasserver/models/sshkey.py 2013-10-07 09:12:40 +0000
+++ src/maasserver/models/sshkey.py 2014-01-17 08:45:45 +0000
@@ -52,7 +52,7 @@
52 if not key.isPublic():52 if not key.isPublic():
53 raise ValidationError(53 raise ValidationError(
54 "Invalid SSH public key (this key is a private key).")54 "Invalid SSH public key (this key is a private key).")
55 except (BadKeyError, binascii.Error):55 except (BadKeyError, binascii.Error, UnicodeEncodeError):
56 raise ValidationError("Invalid SSH public key.")56 raise ValidationError("Invalid SSH public key.")
5757
5858
5959
=== modified file 'src/maasserver/models/tests/test_sshkey.py'
--- src/maasserver/models/tests/test_sshkey.py 2013-10-07 09:12:40 +0000
+++ src/maasserver/models/tests/test_sshkey.py 2014-01-17 08:45:45 +0000
@@ -55,6 +55,14 @@
55 self.assertRaises(55 self.assertRaises(
56 ValidationError, validate_ssh_public_key, key_string)56 ValidationError, validate_ssh_public_key, key_string)
5757
58 def test_does_not_validate_non_ascii_key(self):
59 non_ascii_key = 'AAB3NzaC' + u'\u2502' + 'mN6Lo2I9w=='
60 key_string = 'ssh-rsa %s %s@%s' % (
61 non_ascii_key, factory.getRandomString(),
62 factory.getRandomString())
63 self.assertRaises(
64 ValidationError, validate_ssh_public_key, key_string)
65
58 def test_does_not_validate_rsa_private_key(self):66 def test_does_not_validate_rsa_private_key(self):
59 key_string = get_data('data/test_rsa')67 key_string = get_data('data/test_rsa')
60 self.assertRaises(68 self.assertRaises(
6169
=== modified file 'src/provisioningserver/pxe/config.py'
--- src/provisioningserver/pxe/config.py 2014-01-16 09:35:02 +0000
+++ src/provisioningserver/pxe/config.py 2014-01-17 08:45:45 +0000
@@ -77,8 +77,8 @@
77 "This can happen if you manually power up a node when its "77 "This can happen if you manually power up a node when its "
78 "state is not one that allows it. Is the node in the 'Declared' "78 "state is not one that allows it. Is the node in the 'Declared' "
79 "or 'Ready' states? It needs to be Enlisting, Commissioning or "79 "or 'Ready' states? It needs to be Enlisting, Commissioning or "
80 "Allocated."80 "Allocated." % (
81 % (pxe_templates_dir, purpose, arch, subarch))81 pxe_templates_dir, purpose, arch, subarch))
8282
83 raise AssertionError(error)83 raise AssertionError(error)
8484