|
a/Allura/allura/tests/functional/test_auth.py |
|
b/Allura/allura/tests/functional/test_auth.py |
|
|
1 |
import json
|
|
|
2 |
|
1 |
from allura.tests import TestController
|
3 |
from allura.tests import TestController
|
2 |
from allura import model as M
|
4 |
from allura import model as M
|
3 |
from ming.orm.ormsession import ThreadLocalORMSession
|
5 |
from ming.orm.ormsession import ThreadLocalORMSession
|
4 |
|
6 |
|
5 |
|
7 |
|
|
... |
|
... |
12 |
result = self.app.get('/auth/')
|
14 |
result = self.app.get('/auth/')
|
13 |
r = self.app.post('/auth/send_verification_link', params=dict(a='test@example.com'))
|
15 |
r = self.app.post('/auth/send_verification_link', params=dict(a='test@example.com'))
|
14 |
r = self.app.post('/auth/send_verification_link', params=dict(a='Beta@wiki.test.projects.sourceforge.net'))
|
16 |
r = self.app.post('/auth/send_verification_link', params=dict(a='Beta@wiki.test.projects.sourceforge.net'))
|
15 |
ThreadLocalORMSession.flush_all()
|
17 |
ThreadLocalORMSession.flush_all()
|
16 |
r = self.app.get('/auth/verify_addr', params=dict(a='foo'))
|
18 |
r = self.app.get('/auth/verify_addr', params=dict(a='foo'))
|
17 |
r = self.app.get(r.location)
|
19 |
assert json.loads(self.webflash(r))['status'] == 'error', self.webflash(r)
|
18 |
assert 'class="error"' in r
|
|
|
19 |
ea = M.EmailAddress.query.find().first()
|
20 |
ea = M.EmailAddress.query.find().first()
|
20 |
r = self.app.get('/auth/verify_addr', params=dict(a=ea.nonce))
|
21 |
r = self.app.get('/auth/verify_addr', params=dict(a=ea.nonce))
|
21 |
r = self.app.get(r.location)
|
22 |
assert json.loads(self.webflash(r))['status'] == 'ok', self.webflash(r)
|
22 |
assert 'class="error"' not in r
|
|
|
23 |
r = self.app.get('/auth/logout')
|
23 |
r = self.app.get('/auth/logout')
|
24 |
r = self.app.post('/auth/do_login', params=dict(
|
24 |
r = self.app.post('/auth/do_login', params=dict(
|
25 |
username='test-user', password='foo'))
|
25 |
username='test-user', password='foo'))
|
26 |
r = self.app.post('/auth/do_login', params=dict(
|
26 |
r = self.app.post('/auth/do_login', params=dict(
|
27 |
username='test-user', password='food'))
|
27 |
username='test-user', password='food'))
|
|
... |
|
... |
58 |
'display_name':'Test Admin',
|
58 |
'display_name':'Test Admin',
|
59 |
'new_addr.addr':'Beta@wiki.test.projects.sourceforge.net',
|
59 |
'new_addr.addr':'Beta@wiki.test.projects.sourceforge.net',
|
60 |
'new_addr.claim':'Claim Address',
|
60 |
'new_addr.claim':'Claim Address',
|
61 |
'primary_addr':'Beta@wiki.test.projects.sourceforge.net',
|
61 |
'primary_addr':'Beta@wiki.test.projects.sourceforge.net',
|
62 |
'preferences.email_format':'plain'})
|
62 |
'preferences.email_format':'plain'})
|
63 |
r = self.app.get('/auth/prefs/')
|
|
|
64 |
assert 'class="error"' in r
|
|
|
65 |
|
63 |
|
66 |
def test_api_key(self):
|
64 |
def test_api_key(self):
|
67 |
r = self.app.get('/auth/prefs/')
|
65 |
r = self.app.get('/auth/prefs/')
|
68 |
assert 'No API token generated' in r
|
66 |
assert 'No API token generated' in r
|
69 |
r = self.app.post('/auth/prefs/gen_api_token', status=302)
|
67 |
r = self.app.post('/auth/prefs/gen_api_token', status=302)
|
|
... |
|
... |
87 |
provider='http://www.google.com/accounts/o8/id', username='rick446@usa.net'))
|
85 |
provider='http://www.google.com/accounts/o8/id', username='rick446@usa.net'))
|
88 |
assert '<form' in result.body
|
86 |
assert '<form' in result.body
|
89 |
result = self.app.get('/auth/login_verify_oid', params=dict(
|
87 |
result = self.app.get('/auth/login_verify_oid', params=dict(
|
90 |
provider='http://www.google.com/accounts/', username='rick446@usa.net'),
|
88 |
provider='http://www.google.com/accounts/', username='rick446@usa.net'),
|
91 |
status=302)
|
89 |
status=302)
|
92 |
result = self.app.get(result.location)
|
90 |
assert json.loads(self.webflash(result))['status'] == 'error', self.webflash(result)
|
93 |
assert 'class="error"' in result.body
|
|
|
94 |
result = self.app.get('/auth/login_verify_oid', params=dict(
|
91 |
result = self.app.get('/auth/login_verify_oid', params=dict(
|
95 |
provider='', username='http://blog.pythonisito.com'))
|
92 |
provider='', username='http://blog.pythonisito.com'))
|
96 |
assert result.status_int == 302
|
93 |
assert result.status_int == 302
|
97 |
r = self.app.get('/auth/setup_openid_user')
|
94 |
r = self.app.get('/auth/setup_openid_user')
|
98 |
r = self.app.post('/auth/do_setup_openid_user', params=dict(
|
95 |
r = self.app.post('/auth/do_setup_openid_user', params=dict(
|