Merge lp://qastaging/~salgado/offspring/ssh_ui_mods into lp://qastaging/~linaro-automation/offspring/private-builds

Proposed by Guilherme Salgado
Status: Merged
Approved by: James Tunnicliffe
Approved revision: 92
Merged at revision: 75
Proposed branch: lp://qastaging/~salgado/offspring/ssh_ui_mods
Merge into: lp://qastaging/~linaro-automation/offspring/private-builds
Diff against target: 705 lines (+479/-34)
10 files modified
lib/offspring/web/media/js/jquery.placeholder.js (+106/-0)
lib/offspring/web/queuemanager/admin.py (+5/-3)
lib/offspring/web/queuemanager/forms.py (+35/-7)
lib/offspring/web/queuemanager/models.py (+38/-3)
lib/offspring/web/queuemanager/tests/test_views.py (+107/-1)
lib/offspring/web/queuemanager/views.py (+43/-0)
lib/offspring/web/templates/queuemanager/project_create.html (+58/-18)
lib/offspring/web/templates/queuemanager/project_edit.html (+16/-2)
lib/offspring/web/templates/queuemanager/project_edit_credentials.html (+70/-0)
lib/offspring/web/urls.py (+1/-0)
To merge this branch: bzr merge lp://qastaging/~salgado/offspring/ssh_ui_mods
Reviewer Review Type Date Requested Status
James Tunnicliffe (community) Approve
Review via email: mp+81641@code.qastaging.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
James Tunnicliffe (dooferlad) wrote :
Download full text (3.8 KiB)

=== modified file 'lib/offspring/web/queuemanager/forms.py'
--- lib/offspring/web/queuemanager/forms.py 2011-10-19 20:23:49 +0000
+++ lib/offspring/web/queuemanager/forms.py 2011-11-08 21:32:23 +0000
@@ -1,11 +1,9 @@
-# Copyright 2010 Canonical Ltd. This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
+# Copyright 2010 Canonical Ltd. This software is licensed under the # GNU Affero General Public License version 3 (see the file LICENSE).

Seem to have lost a newline here.

=== modified file 'lib/offspring/web/queuemanager/models.py'
--- lib/offspring/web/queuemanager/models.py 2011-10-21 16:44:19 +0000
+++ lib/offspring/web/queuemanager/models.py 2011-11-08 21:32:23 +0000
@@ -11,8 +11,10 @@
    timedelta
 )
 import math
+import re

 from django.contrib.auth.models import AnonymousUser, User
+from django.core.exceptions import ValidationError
 from django.db import (
    connection,
    models
@@ -199,6 +201,25 @@
        return is_visible_to(user)

+def validate_lp_ssh_key(value):
+ """Check to see if the value looks like an SSH private key"""
+ if not value:
+ return
+
+ key_search_regexp = (r"-----BEGIN \w+ PRIVATE KEY-----"+
+ r".*"+
+ r"-----END \w+ PRIVATE KEY-----")
+ is_key = re.search(key_search_regexp, value, re.DOTALL | re.MULTILINE)
+
+ if not is_key:
+ msg = ("The key you entered doesn't appear to be valid. I am "+
+ "expecting a key in the form:\n "+
+ "-----BEGIN <type> PRIVATE KEY-----\n"+
+ "<ASCII key>\n"+
+ "-----END <type> PRIVATE KEY-----\n")
+ raise ValidationError(msg)
+
+
 class Project(AccessGroupMixin, MaybePrivateMixin):
    #XXX: This should probably be managed in the database.
    STATUS_CHOICES = (
@@ -233,10 +254,13 @@
    # The Launchpad User and SSH key are stored per project. If we stored them
    # per LauncpadProject, anyone who could create a Project referencing that
    # LaunchpadProject could get access to the private data in it.
- lp_user = models.TextField('Launchpad User', null=True, editable=False,
+ lp_user = models.TextField('Launchpad User', null=True,
                               blank=True)
- lp_ssh_key = models.TextField("Launchpad User's SSH Key", blank=True,
- null=True, editable=False)
+ lp_ssh_key = models.TextField(
+ "Launchpad User's SSH Key", blank=True, null=True, editable=True,
+ validators=[validate_lp_ssh_key],
+ help_text=("Enter a private SSH ASCII key block, complete with begin "
+ "and end markers."))

    notes = models.TextField(blank=True, null=True)

@@ -249,6 +273,17 @@
    def __unicode__(self):
        return self.display_name()

+ def clean(self):
+ if self.lp_user and not self.lp_ssh_key:
+ raise ValidationError(
+ "You must specify the SSH key for the given Launchpad user")
+ elif self.lp_ssh_key and not self.lp_user:
+ raise ValidationError(
+ "You must specify the Launchpad user for the given SSH key")
+ ...

Read more...

Revision history for this message
Guilherme Salgado (salgado) wrote :
Download full text (4.6 KiB)

On Wed, 2011-11-09 at 13:03 +0000, James Tunnicliffe wrote:
> === modified file 'lib/offspring/web/queuemanager/forms.py'
> --- lib/offspring/web/queuemanager/forms.py 2011-10-19 20:23:49 +0000
> +++ lib/offspring/web/queuemanager/forms.py 2011-11-08 21:32:23 +0000
> @@ -1,11 +1,9 @@
> -# Copyright 2010 Canonical Ltd. This software is licensed under the
> -# GNU Affero General Public License version 3 (see the file LICENSE).
> +# Copyright 2010 Canonical Ltd. This software is licensed under the # GNU Affero General Public License version 3 (see the file LICENSE).
>
> Seem to have lost a newline here.

Good catch; fixed.

>
> === modified file 'lib/offspring/web/queuemanager/models.py'
> --- lib/offspring/web/queuemanager/models.py 2011-10-21 16:44:19 +0000
> +++ lib/offspring/web/queuemanager/models.py 2011-11-08 21:32:23 +0000
> @@ -11,8 +11,10 @@
> timedelta
> )
> import math
> +import re
>
> from django.contrib.auth.models import AnonymousUser, User
> +from django.core.exceptions import ValidationError
> from django.db import (
> connection,
> models
> @@ -199,6 +201,25 @@
> return is_visible_to(user)
>
>
> +def validate_lp_ssh_key(value):
> + """Check to see if the value looks like an SSH private key"""
> + if not value:
> + return
> +
> + key_search_regexp = (r"-----BEGIN \w+ PRIVATE KEY-----"+
> + r".*"+
> + r"-----END \w+ PRIVATE KEY-----")
> + is_key = re.search(key_search_regexp, value, re.DOTALL | re.MULTILINE)
> +
> + if not is_key:
> + msg = ("The key you entered doesn't appear to be valid. I am "+
> + "expecting a key in the form:\n "+
> + "-----BEGIN <type> PRIVATE KEY-----\n"+
> + "<ASCII key>\n"+
> + "-----END <type> PRIVATE KEY-----\n")
> + raise ValidationError(msg)
> +
> +
> class Project(AccessGroupMixin, MaybePrivateMixin):
> #XXX: This should probably be managed in the database.
> STATUS_CHOICES = (
> @@ -233,10 +254,13 @@
> # The Launchpad User and SSH key are stored per project. If we stored them
> # per LauncpadProject, anyone who could create a Project referencing that
> # LaunchpadProject could get access to the private data in it.
> - lp_user = models.TextField('Launchpad User', null=True, editable=False,
> + lp_user = models.TextField('Launchpad User', null=True,
> blank=True)
> - lp_ssh_key = models.TextField("Launchpad User's SSH Key", blank=True,
> - null=True, editable=False)
> + lp_ssh_key = models.TextField(
> + "Launchpad User's SSH Key", blank=True, null=True, editable=True,
> + validators=[validate_lp_ssh_key],
> + help_text=("Enter a private SSH ASCII key block, complete with begin "
> + "and end markers."))
>
> notes = models.TextField(blank=True, null=True)
>
> @@ -249,6 +273,17 @@
> def __unicode__(self):
> return self.display_name()
>
> + def clean(self):
> + if self.lp_user and not self.lp_ssh_key:
> + raise ValidationError(
> + "...

Read more...

91. By Guilherme Salgado

When the user submits a key on +editcredentials and there's a form error, show the submitted key

Revision history for this message
Guilherme Salgado (salgado) wrote :

r91 fixes that issue you pointed out

Revision history for this message
James Tunnicliffe (dooferlad) wrote :

On 9 November 2011 13:57, Guilherme Salgado
<email address hidden> wrote:
> r91 fixes that issue you pointed out

Great. Just ran it and it works very nicely.

We seem to be missing a migrate script. I think you can just copy the
one over from my dev branch.

In forms.py, we should change:
'lp_user' : Textarea(attrs={'cols': 40, 'rows' : 1}),

To a TextInput, (perhaps with cols set to 70, just for ease of
entering longer names) since this will prevent users from writing
multi-line user names by accident.

I think after those changed it will be ready to merge! At last!

--
James Tunnicliffe

92. By Guilherme Salgado

Change the widget used for lp_user to a TextInput

Revision history for this message
James Tunnicliffe (dooferlad) wrote :

Looks great!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches