Merge lp:~sinzui/launchpad/newline-removal into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Gavin Panella on 2010-04-07 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | not available |
| Proposed branch: | lp:~sinzui/launchpad/newline-removal |
| Merge into: | lp:launchpad |
| Diff against target: |
190 lines (+59/-22) 3 files modified
lib/lp/registry/interfaces/distribution.py (+2/-1) lib/lp/registry/scripts/listteammembers.py (+21/-12) lib/lp/registry/tests/test_listteammembers.py (+36/-9) |
| To merge this branch: | bzr merge lp:~sinzui/launchpad/newline-removal |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Edwin Grubbs (community) | Approve on 2010-04-07 | ||
| Gavin Panella (community) | 2010-04-06 | Approve on 2010-04-07 | |
| Nick Moffitt | Approve on 2010-04-07 | ||
|
Review via email:
|
|||
Description of the Change
This is my branch to strip line breaks from listteammembers sshkeys.
This branch elaborates on the solution suggested by Nick Moffitt. Nick's
approach broke the existing tests, so I wrote a helper function that is
easy to test.
lp:~sinzui/launchpad/newline-removal
Diff size: 175 (50% lint)
Launchpad bug: https:/
Test command: ./bin/test -vv -t test_listteamme
Pre-
Target release: 10.04
Strip line breaks from listteammembers sshkeys
-------
The current report generation script preserves newlines in ssh key data as
input by a user. Often users will mis-paste their key from a terminal display
that inserted hard newlines (such as some configurations of less under certain
terminal types) and this will result in a key formatted such that it cannot be
used in an authorized_keys file.
In addition, any user can create a key such as the one at
https:/
another user. This is the more troublesome aspect of this behavior, and
constitutes a security risk for systems that make use of this ssh key data.
Rules
-----
* Using Nick's branch as a base, provide a test to verify that '\r\n\f'
characters are removed from sshkeys.
QA
--
* On staging, create a teeam named goat-boys
and add ~lp-test-outflux as a member.
* Run scripts/
* Verify that ~lp-test-outflux's key is on one line.
Lint
----
Lint hated these files.
Linting changed files:
lib/lp/
lib/lp/
Test
----
* lib/lp/
* Added a test for the new function.
Implementation
--------------
* lib/lp/
* Extracted the sshkey formatting to a function and added a rule to
remove '[\r\n\f]'
| Nick Moffitt (nick-moffitt) wrote : | # |
Also, pawing through the whitespace changes and all, perhaps "bad_ssh_patters" could be written as "bad_ssh_patterns"?
Oh, I just spotted your u'123badKeysMig
| Curtis Hovey (sinzui) wrote : | # |
Hi Nick.
Our lint checker hated the two files I edited. It reported that I had to wrap the long lines and fix the commas before submitt my changes for review. So all the line wrapping was done just to quiet lint.
I renamed bad_ssh_pattern and I added bad characters to the sshkey comment.
{{{
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -27,14 +27,14 @@
"""Used if non-existent team name is specified."""
-bad_ssh_patters = re.compile(
+bad_ssh_pattern = re.compile(
def make_sshkey_
sshkey = "%s %s %s" % (
type_name,
- bad_ssh_
- bad_ssh_
+ bad_ssh_
+ bad_ssh_
return dict(name=
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -98,7 +98,7 @@
sshkey = self.factory.
- sshkey.comment = 'comment'
+ sshkey.comment = 'co\rmm\ne\f\fnt'
expected = dict(
}}}
| Gavin Panella (allenap) wrote : | # |
Some of the tests that you've folded the lines for are (result, expected) rather than (expected, result), so drive-by those if that knowledge now bothers you. Other than that, all's cool.
| Edwin Grubbs (edwin-grubbs) wrote : | # |
Hi Curtis,
This branch looks good. I just have a couple of minor comments below.
merge-conditional
-Edwin
>=== modified file 'lib/lp/
>--- lib/lp/
>+++ lib/lp/
>@@ -48,14 +52,22 @@
> ])
>
> ubuntuteam_sshkeys = [
>- u'mark: ssh-dss AAAAB3NzaC1kc3M
>+ u'mark: ssh-dss AAAAB3NzaC1kc3M
>+ u'B7c2Z1ktFPcEa
>+ u'eVYHVEBGFGfVA
>+ u'GXaRIsBdaQamH
>+ u'Xd5KdUWWwqwGd
>+ u'lib/lp/
> ]
>
>
>-class ListTeamMembers
>+class ListTeamMembers
> """Test listing team members."""
> layer = LaunchpadZopele
>
>+ def setUp(self):
>+ super(ListTeamM
Why is this necessary?
> def test_listteamme
> """Test the default option."""
> self.assertEqual(
>@@ -64,22 +76,40 @@
> def test_listteamme
> """Test the email only option."""
> self.assertEqual(
>- listteammembers
>+ listteammembers
>+ ubuntuteam_email)
>
> def test_listteamme
> """Test the full details option."""
> self.assertEqual(
>- listteammembers
>+ listteammembers
>+ ubuntuteam_full)
>
> def test_listteamme
> """Test the ssh keys option."""
> self.assertEqual(
>- listteammembers
>+ listteammembers
>+ ubuntuteam_sshkeys)
>+
>+ def test_make_
>+ """Test that ssh keys ."""
Incomplete docstring.
>+ member = self.factory.
>+ team = self.factory.
>+ team.addMember(
>+ sshkey = self.factory.
>+ sshkey.keytext = u'123badKeysMig
>+ sshkey.comment = 'co\rmm\ne\f\fnt'
>+ expected = dict(
>+ name=u'biggles',
>+ sshkey=u'ssh-rsa 123badKeysMight
>+ ...
| Curtis Hovey (sinzui) wrote : | # |
On Wed, 2010-04-07 at 15:50 +0000, Gavin Panella wrote:
> Review: Approve
> Some of the tests that you've folded the lines for are (result,
> expected) rather than (expected, result), so drive-by those if that
> knowledge now bothers you. Other than that, all's cool.
Oh that is so cruel. How can I sleep knowing this? I cannot. Fixed.
On Wed, 2010-04-07 at 16:04 +0000, Edwin Grubbs wrote:
> Review: Approve
> Hi Curtis,
>
> This branch looks good. I just have a couple of minor comments below.
>
> merge-conditional
...
> >+class ListTeamMembers
> > """Test listing team members."""
> > layer = LaunchpadZopele
> >
> >+ def setUp(self):
> >+ super(ListTeamM
>
>
> Why is this necessary?
It is not. I assumed for a moment that I needs to do some setup for
everything. I Removed this.
...
> >+ def test_make_
> >+ """Test that ssh keys ."""
>
>
> Incomplete docstring.
Indeed:
"""Test that ssh keys are rendered as a single line."""
{{{
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -65,34 +65,31 @@
"""Test listing team members."""
layer = LaunchpadZopele
- def setUp(self):
- super(ListTeamM
-
def test_listteamme
"""Test the default option."""
- listteammembers
+ ubuntuteam_default, listteammembers
def test_listteamme
"""Test the email only option."""
- listteammembers
- ubuntuteam_email)
+ ubuntuteam_email,
+ listteammembers
def test_listteamme
"""Test the full details option."""
- listteammembers
- ubuntuteam_full)
+ ubuntuteam_full,
+ listteammembers
def test_listteamme
"""Test the ssh keys option."""
- listteammembers
- ubuntuteam_sshkeys)
+ ubuntuteam_sshkeys,
+ listteammembers
def test_make_
- """Test that ssh keys ."""
+ """Test that ssh keys are rendered as a single line."""
member = self.factory.
team = self.factory.
}}}
--
__Curtis C. Hovey_________
http://

Is your multi-line break-up of the key on line 108 meant to be part of the test for this functionality? It would appear to me that no newlines would be inserted using that syntax.