Merge lp:~waigani/juju-core/change-user-regex into lp:~go-bot/juju-core/trunk

Proposed by Jesse Meek
Status: Work in progress
Proposed branch: lp:~waigani/juju-core/change-user-regex
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 58 lines (+16/-11)
2 files modified
names/user.go (+1/-1)
names/user_test.go (+15/-10)
To merge this branch: bzr merge lp:~waigani/juju-core/change-user-regex
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+220896@code.launchpad.net

Description of the change

names/user: Update regex

Update username regex to allow launchpad
usernames, which use the following regex:
r"^[a-z0-9][a-z0-9\+\.\-]+$"

https://codereview.appspot.com/100800043/

To post a comment you must log in.
Revision history for this message
Jesse Meek (waigani) wrote :

Reviewers: mp+220896_code.launchpad.net,

Message:
Please take a look.

Description:
names/user: Update regex

Update username regex to allow launchpad
usernames, which use the following regex:
r"^[a-z0-9][a-z0-9\+\.\-]+$"

https://code.launchpad.net/~waigani/juju-core/change-user-regex/+merge/220896

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/100800043/

Affected files (+18, -11 lines):
   A [revision details]
   M names/user.go
   M names/user_test.go

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-20140526011313-826c14om0palwq0z
+New revision: <email address hidden>

Index: names/user.go
=== modified file 'names/user.go'
--- names/user.go 2014-05-21 22:02:21 +0000
+++ names/user.go 2014-05-26 02:17:41 +0000
@@ -7,7 +7,7 @@
   "regexp"
  )

-var validName = regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9.-]*[a-zA-Z0-9]$")
+var validName = regexp.MustCompile("^[a-zA-Z0-9][a-zA-Z0-9+.-]*$")

  // IsUser returns whether id is a valid user id.
  func IsUser(name string) bool {

Index: names/user_test.go
=== modified file 'names/user_test.go'
--- names/user_test.go 2014-05-22 00:48:08 +0000
+++ names/user_test.go 2014-05-26 02:17:41 +0000
@@ -24,18 +24,18 @@
   {"b^b", false},
   {"bob1", true},
   {"bob-1", true},
- {"bob+1", false},
+ {"bob+1", true},
   {"bob.1", true},
- {"1bob", false},
- {"1-bob", false},
- {"1+bob", false},
- {"1.bob", false},
- {"jim.bob+99-1.", false},
- {"a", false},
- {"0foo", false},
+ {"1bob", true},
+ {"1-bob", true},
+ {"1+bob", true},
+ {"1.bob", true},
+ {"jim.bob+99-1.", true},
+ {"a", true},
+ {"0foo", true},
   {"foo bar", false},
   {"bar{}", false},
- {"bar+foo", false},
+ {"bar+foo", true},
   {"bar_foo", false},
   {"bar!", false},
   {"bar^", false},
@@ -48,7 +48,12 @@
   {"&bar", false},
   {"#1foo", false},
   {"<email address hidden>", false},
- {"not/valid", false},
+ {"foo.", true},
+ {"foo+", true},
+ {"foo-", true},
+ {".foo", false},
+ {"+foo", false},
+ {"-foo", false},
  }

  func (s *userSuite) TestUserTag(c *gc.C) {

Revision history for this message
William Reade (fwereade) wrote :

What's the motivation here?

https://codereview.appspot.com/100800043/

Revision history for this message
William Reade (fwereade) wrote :

On 2014/05/26 07:11:46, fwereade wrote:
> What's the motivation here?

We discussed this, but I don't recall what conclusion we came to. IMO
this is the internal juju name, and we don't want to let external auth
providers affect it -- we can't just keep on changing the regex as we
get new ones. I'm open to the idea that we want a *different* regex, but
I think that's about the display name for juju (and depends on the
schema change to use something else as the _id, I think). WIP for now?

https://codereview.appspot.com/100800043/

Unmerged revisions

2790. By Jesse Meek

Update regex to allow lp username policy

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'names/user.go'
2--- names/user.go 2014-05-21 22:02:21 +0000
3+++ names/user.go 2014-05-26 02:22:16 +0000
4@@ -7,7 +7,7 @@
5 "regexp"
6 )
7
8-var validName = regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9.-]*[a-zA-Z0-9]$")
9+var validName = regexp.MustCompile("^[a-zA-Z0-9][a-zA-Z0-9+.-]*$")
10
11 // IsUser returns whether id is a valid user id.
12 func IsUser(name string) bool {
13
14=== modified file 'names/user_test.go'
15--- names/user_test.go 2014-05-22 00:48:08 +0000
16+++ names/user_test.go 2014-05-26 02:22:16 +0000
17@@ -24,18 +24,18 @@
18 {"b^b", false},
19 {"bob1", true},
20 {"bob-1", true},
21- {"bob+1", false},
22+ {"bob+1", true},
23 {"bob.1", true},
24- {"1bob", false},
25- {"1-bob", false},
26- {"1+bob", false},
27- {"1.bob", false},
28- {"jim.bob+99-1.", false},
29- {"a", false},
30- {"0foo", false},
31+ {"1bob", true},
32+ {"1-bob", true},
33+ {"1+bob", true},
34+ {"1.bob", true},
35+ {"jim.bob+99-1.", true},
36+ {"a", true},
37+ {"0foo", true},
38 {"foo bar", false},
39 {"bar{}", false},
40- {"bar+foo", false},
41+ {"bar+foo", true},
42 {"bar_foo", false},
43 {"bar!", false},
44 {"bar^", false},
45@@ -48,7 +48,12 @@
46 {"&bar", false},
47 {"#1foo", false},
48 {"bar@ram.u", false},
49- {"not/valid", false},
50+ {"foo.", true},
51+ {"foo+", true},
52+ {"foo-", true},
53+ {".foo", false},
54+ {"+foo", false},
55+ {"-foo", false},
56 }
57
58 func (s *userSuite) TestUserTag(c *gc.C) {

Subscribers

People subscribed via source and target branches

to status/vote changes: