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
=== modified file 'src/webui/forms.py'
--- src/webui/forms.py 2020-01-30 21:14:27 +0000
+++ src/webui/forms.py 2020-01-31 20:54:26 +0000
@@ -96,7 +96,7 @@
96 being displayed to the user.96 being displayed to the user.
97 """97 """
98 try:98 try:
99 key_type, key_text, comment = ssh_key.split(' ', 2)99 key_type, key_text, comment = ssh_key.strip().split(None, 2)
100 except ValueError:100 except ValueError:
101 # This should never happen, as launchpad is supposed to guarantee a101 # This should never happen, as launchpad is supposed to guarantee a
102 # valid ssh key format. However, we need to exercise this code path102 # valid ssh key format. However, we need to exercise this code path
103103
=== modified file 'src/webui/templates/account/ssh_keys.html'
--- src/webui/templates/account/ssh_keys.html 2020-01-30 21:14:27 +0000
+++ src/webui/templates/account/ssh_keys.html 2020-01-31 20:54:26 +0000
@@ -31,7 +31,7 @@
31 <dt>Type</dt>31 <dt>Type</dt>
32 <dd>{{ key_info.type }}</dd>32 <dd>{{ key_info.type }}</dd>
33 <dt>Text</dt>33 <dt>Text</dt>
34 <dd><code>{{ key_info.text }}</code></dd>34 <dd><code style="word-break: keep-all;">{{ key_info.text }}</code></dd>
35 </dl>35 </dl>
36 </section>36 </section>
37 </li>37 </li>
3838
=== modified file 'src/webui/tests/test_forms.py'
--- src/webui/tests/test_forms.py 2020-01-30 21:14:27 +0000
+++ src/webui/tests/test_forms.py 2020-01-31 20:54:26 +0000
@@ -266,6 +266,19 @@
266 formatted_key = format_ssh_key(keytext)266 formatted_key = format_ssh_key(keytext)
267 self.assertIn('¿ʇuǝɯɯoɔ', formatted_key['label'])267 self.assertIn('¿ʇuǝɯɯoɔ', formatted_key['label'])
268268
269 def test_multiple_whitespace(self):
270 keytext = ' ssh-rsa keytext\t\t\t\t\tcomment '
271 result = format_ssh_key(keytext)
272 self.assertEqual(
273 {
274 'ssh_key': keytext,
275 'label': 'comment',
276 'type': 'ssh-rsa',
277 'text': 'keytext',
278 },
279 result
280 )
281
269 def test_invalid_keys(self):282 def test_invalid_keys(self):
270 invalid_key_text = "INVALID"283 invalid_key_text = "INVALID"
271 formatted_key = format_ssh_key(invalid_key_text)284 formatted_key = format_ssh_key(invalid_key_text)
272285
=== removed directory 'tools'
=== removed file 'tools/pyflakes.txt'