Merge lp:~maxiberta/canonical-identity-provider/handle-add-lp-ssh-key-errors into lp:canonical-identity-provider

Proposed by Maximiliano Bertacchini on 2018-06-18
Status: Merged
Approved by: Maximiliano Bertacchini on 2018-06-18
Approved revision: 1642
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: lp:~maxiberta/canonical-identity-provider/handle-add-lp-ssh-key-errors
Merge into: lp:canonical-identity-provider
Diff against target: 59 lines (+6/-6)
2 files modified
src/webservices/launchpad.py (+2/-2)
src/webservices/tests/test_launchpad.py (+4/-4)
To merge this branch: bzr merge lp:~maxiberta/canonical-identity-provider/handle-add-lp-ssh-key-errors
Reviewer Review Type Date Requested Status
Daniel Manrique 2018-06-18 Approve on 2018-06-18
Review via email: mp+348185@code.launchpad.net

Commit message

Improve handling of errors when attempting to add an ssh key via Launchpad.

Description of the change

Improve handling of errors when attempting to add an ssh key via Launchpad.

To post a comment you must log in.
Daniel Manrique (roadmr) wrote :

LGTM :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/webservices/launchpad.py'
2--- src/webservices/launchpad.py 2018-05-25 21:47:30 +0000
3+++ src/webservices/launchpad.py 2018-06-18 21:27:37 +0000
4@@ -53,13 +53,13 @@
5 """Something was wrong with the specified SSH key text."""
6
7 MATCH = re.compile(
8- r"^Invalid SSH key type: '.*?'$")
9+ r"^Invalid SSH key type:.*$")
10
11
12 class SSHKeyAdditionDataError(LaunchpadAPIError):
13
14 MATCH = re.compile(
15- r"^Invalid SSH key data: '.*?'$")
16+ r"^Invalid SSH key data:.*$")
17
18
19 class SSHKeyCompromisedError(LaunchpadAPIError):
20
21=== modified file 'src/webservices/tests/test_launchpad.py'
22--- src/webservices/tests/test_launchpad.py 2016-07-25 01:25:41 +0000
23+++ src/webservices/tests/test_launchpad.py 2018-06-18 21:27:37 +0000
24@@ -157,7 +157,7 @@
25
26 def test_add_ssh_key_with_bad_key_type(self):
27 self.lp_api_handler.set_next_response(
28- 400, "Invalid SSH key type: 'flub'")
29+ 400, "Invalid SSH key type: 'flub' (Unknown type)")
30 self.assertRaises(
31 SSHKeyAdditionTypeError,
32 add_lp_ssh_key,
33@@ -169,7 +169,7 @@
34
35 def test_add_ssh_key_with_bad_key_data(self):
36 self.lp_api_handler.set_next_response(
37- 400, "Invalid SSH key data: 'keywithnospaces'")
38+ 400, "Invalid SSH key data: 'keywithnospaces' (Incorrect padding)")
39 self.assertRaises(
40 SSHKeyAdditionDataError,
41 add_lp_ssh_key,
42@@ -213,7 +213,7 @@
43
44 def test_delete_ssh_key_with_bad_key_type(self):
45 self.lp_api_handler.set_next_response(
46- 400, "Invalid SSH key type: 'flub'")
47+ 400, "Invalid SSH key type: 'flub' (Unknown type)")
48 self.assertRaises(
49 SSHKeyAdditionTypeError,
50 delete_lp_ssh_key,
51@@ -225,7 +225,7 @@
52
53 def test_delete_ssh_key_with_bad_key_data(self):
54 self.lp_api_handler.set_next_response(
55- 400, "Invalid SSH key data: 'keywithnospaces'")
56+ 400, "Invalid SSH key data: 'keywithnospaces' (Incorrect padding)")
57 self.assertRaises(
58 SSHKeyAdditionDataError,
59 delete_lp_ssh_key,