Merge lp:~maxiberta/canonical-identity-provider/ssh-form-improvements into lp:canonical-identity-provider/release

Proposed by Maximiliano Bertacchini
Status: Merged
Approved by: Maximiliano Bertacchini
Approved revision: no longer in the source branch.
Merged at revision: 1716
Proposed branch: lp:~maxiberta/canonical-identity-provider/ssh-form-improvements
Merge into: lp:canonical-identity-provider/release
Diff against target: 52 lines (+15/-2)
3 files modified
src/webui/forms.py (+1/-1)
src/webui/templates/account/ssh_keys.html (+1/-1)
src/webui/tests/test_forms.py (+13/-0)
To merge this branch: bzr merge lp:~maxiberta/canonical-identity-provider/ssh-form-improvements
Reviewer Review Type Date Requested Status
Daniel Manrique (community) Approve
Review via email: mp+378425@code.launchpad.net

Commit message

Assorted improvements to the SSH keys form.

- Prevent extraneous line breaks when showing SSH keys.
- Improve parsing of SSH keys with multiple white spaces.

Description of the change

Additionally, drop unused ./tools/ and ./tools/pyflakes.txt.

I admit the CSS machinery seemed too complicated for such a small change, README didn't help much and I ran out of patience, so ended up inlining it. Happy to revisit if we're against that.

To post a comment you must log in.
Revision history for this message
Daniel Manrique (roadmr) wrote :

Let's go with this, we need to check with Karl to refine the CSS hacking story later, then we can decide whether to tweak this to use non-inlined style.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/webui/forms.py'
2--- src/webui/forms.py 2020-01-30 21:14:27 +0000
3+++ src/webui/forms.py 2020-01-31 20:54:26 +0000
4@@ -96,7 +96,7 @@
5 being displayed to the user.
6 """
7 try:
8- key_type, key_text, comment = ssh_key.split(' ', 2)
9+ key_type, key_text, comment = ssh_key.strip().split(None, 2)
10 except ValueError:
11 # This should never happen, as launchpad is supposed to guarantee a
12 # valid ssh key format. However, we need to exercise this code path
13
14=== modified file 'src/webui/templates/account/ssh_keys.html'
15--- src/webui/templates/account/ssh_keys.html 2020-01-30 21:14:27 +0000
16+++ src/webui/templates/account/ssh_keys.html 2020-01-31 20:54:26 +0000
17@@ -31,7 +31,7 @@
18 <dt>Type</dt>
19 <dd>{{ key_info.type }}</dd>
20 <dt>Text</dt>
21- <dd><code>{{ key_info.text }}</code></dd>
22+ <dd><code style="word-break: keep-all;">{{ key_info.text }}</code></dd>
23 </dl>
24 </section>
25 </li>
26
27=== modified file 'src/webui/tests/test_forms.py'
28--- src/webui/tests/test_forms.py 2020-01-30 21:14:27 +0000
29+++ src/webui/tests/test_forms.py 2020-01-31 20:54:26 +0000
30@@ -266,6 +266,19 @@
31 formatted_key = format_ssh_key(keytext)
32 self.assertIn('¿ʇuǝɯɯoɔ', formatted_key['label'])
33
34+ def test_multiple_whitespace(self):
35+ keytext = ' ssh-rsa keytext\t\t\t\t\tcomment '
36+ result = format_ssh_key(keytext)
37+ self.assertEqual(
38+ {
39+ 'ssh_key': keytext,
40+ 'label': 'comment',
41+ 'type': 'ssh-rsa',
42+ 'text': 'keytext',
43+ },
44+ result
45+ )
46+
47 def test_invalid_keys(self):
48 invalid_key_text = "INVALID"
49 formatted_key = format_ssh_key(invalid_key_text)
50
51=== removed directory 'tools'
52=== removed file 'tools/pyflakes.txt'