diff options
author | 2007-09-03 21:54:20 -0700 | |
---|---|---|
committer | 2007-09-03 22:06:37 -0700 | |
commit | e7a1cc68c7e30d0f3c9af33aa39871dda064a58d (patch) | |
tree | 1554f1a355fa0db7e4421ff7f09c4aee7184519a | |
parent | Fix whitespace in README. (diff) | |
download | gitosis-gentoo-e7a1cc68c7e30d0f3c9af33aa39871dda064a58d.tar.gz gitosis-gentoo-e7a1cc68c7e30d0f3c9af33aa39871dda064a58d.tar.bz2 gitosis-gentoo-e7a1cc68c7e30d0f3c9af33aa39871dda064a58d.zip |
Let SSH public key user fields have a bit more varied content.
-rw-r--r-- | gitosis/init.py | 2 | ||||
-rw-r--r-- | gitosis/test/test_init.py | 27 |
2 files changed, 28 insertions, 1 deletions
diff --git a/gitosis/init.py b/gitosis/init.py index 61504c8..7ba04cd 100644 --- a/gitosis/init.py +++ b/gitosis/init.py @@ -25,7 +25,7 @@ def read_ssh_pubkey(fp=None): line = fp.readline() return line -_ACCEPTABLE_USER_RE = re.compile(r'^[a-z][a-z0-9]*@[a-z][a-z0-9]*$') +_ACCEPTABLE_USER_RE = re.compile(r'^[a-z][a-z0-9]*(@[a-z][a-z0-9.-]*)?$') class InsecureSSHKeyUsername(Exception): """Username contains not allowed characters""" diff --git a/gitosis/test/test_init.py b/gitosis/test/test_init.py index 8f72b2d..559a0c8 100644 --- a/gitosis/test/test_init.py +++ b/gitosis/test/test_init.py @@ -18,6 +18,33 @@ def test_ssh_extract_user_simple(): +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= fakeuser@fakehost') eq(got, 'fakeuser@fakehost') +def test_ssh_extract_user_domain(): + got = init.ssh_extract_user( + 'ssh-somealgo ' + +'0123456789ABCDEFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= fakeuser@fakehost.example.com') + eq(got, 'fakeuser@fakehost.example.com') + +def test_ssh_extract_user_domain_dashes(): + got = init.ssh_extract_user( + 'ssh-somealgo ' + +'0123456789ABCDEFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= fakeuser@ridiculously-long.example.com') + eq(got, 'fakeuser@ridiculously-long.example.com') + +def test_ssh_extract_user_no_at(): + got = init.ssh_extract_user( + 'ssh-somealgo ' + +'0123456789ABCDEFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= fakeuser') + eq(got, 'fakeuser') + def test_ssh_extract_user_bad(): e = assert_raises( init.InsecureSSHKeyUsername, |