0001-misc-split-auth-tests.patch
tests/form_pages/test_all.py | ||
---|---|---|
1597 | 1597 |
assert 'The form has been recorded on' in resp |
1598 | 1598 | |
1599 | 1599 | |
1600 |
def test_form_auth(pub): |
|
1601 |
create_user(pub) |
|
1602 |
formdef = create_formdef() |
|
1603 |
formdef.data_class().wipe() |
|
1604 |
resp = get_app(pub).get('/test/auth') |
|
1605 |
assert resp.location == 'http://example.net/login/?ReturnUrl=http%3A//example.net/test/' |
|
1606 | ||
1607 |
resp = login(get_app(pub), username='foo', password='foo').get('/test/auth') |
|
1608 |
assert resp.location == 'http://example.net/test/' |
|
1609 | ||
1610 | ||
1611 |
def test_form_tryauth(pub): |
|
1612 |
create_user(pub) |
|
1613 |
formdef = create_formdef() |
|
1614 |
formdef.data_class().wipe() |
|
1615 |
resp = get_app(pub).get('/test/tryauth') |
|
1616 |
assert resp.location == 'http://example.net/test/' |
|
1617 | ||
1618 |
app = login(get_app(pub), username='foo', password='foo') |
|
1619 |
pub.cfg['identification'] = {'methods': ['idp']} |
|
1620 |
pub.write_cfg() |
|
1621 |
# if the user is logged in, the form should be presented |
|
1622 |
resp = app.get('/test/tryauth') |
|
1623 |
assert resp.location == 'http://example.net/test/' |
|
1624 | ||
1625 |
# if the user is unlogged, there should be a passive redirection to SSO |
|
1626 |
resp = get_app(pub).get('/test/tryauth') |
|
1627 |
assert 'IsPassive=true' in resp.location |
|
1628 | ||
1629 |
pub.cfg['identification'] = {'methods': ['password']} |
|
1630 |
pub.write_cfg() |
|
1631 | ||
1632 | ||
1633 |
def test_form_forceauth(pub): |
|
1634 |
create_user(pub) |
|
1635 |
formdef = create_formdef() |
|
1636 |
formdef.data_class().wipe() |
|
1637 |
resp = get_app(pub).get('/test/forceauth') |
|
1638 |
assert resp.location == 'http://example.net/login/?ReturnUrl=http%3A//example.net/test/&forceAuthn=true' |
|
1639 | ||
1640 | ||
1641 | 1600 |
def test_form_no_tracking_code(pub): |
1642 | 1601 |
formdef = create_formdef() |
1643 | 1602 |
formdef.data_class().wipe() |
tests/form_pages/test_auth.py | ||
---|---|---|
1 |
import pytest |
|
2 | ||
3 |
from wcs.formdef import FormDef |
|
4 | ||
5 |
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, login |
|
6 |
from .test_all import create_user |
|
7 | ||
8 | ||
9 |
@pytest.fixture |
|
10 |
def pub(request): |
|
11 |
pub = create_temporary_pub() |
|
12 |
pub.cfg['identification'] = {'methods': ['password']} |
|
13 |
pub.cfg['language'] = {'language': 'en'} |
|
14 |
pub.write_cfg() |
|
15 |
return pub |
|
16 | ||
17 | ||
18 |
@pytest.fixture |
|
19 |
def formdef(pub): |
|
20 |
FormDef.wipe() |
|
21 |
formdef = FormDef() |
|
22 |
formdef.name = 'test' |
|
23 |
formdef.fields = [] |
|
24 |
formdef.store() |
|
25 |
return formdef |
|
26 | ||
27 | ||
28 |
def teardown_module(module): |
|
29 |
clean_temporary_pub() |
|
30 | ||
31 | ||
32 |
def test_form_auth(pub, formdef): |
|
33 |
create_user(pub) |
|
34 | ||
35 |
resp = get_app(pub).get('/test/auth') |
|
36 |
assert resp.location == 'http://example.net/login/?ReturnUrl=http%3A//example.net/test/' |
|
37 | ||
38 |
resp = login(get_app(pub), username='foo', password='foo').get('/test/auth') |
|
39 |
assert resp.location == 'http://example.net/test/' |
|
40 | ||
41 | ||
42 |
def test_form_tryauth(pub, formdef): |
|
43 |
create_user(pub) |
|
44 | ||
45 |
resp = get_app(pub).get('/test/tryauth') |
|
46 |
assert resp.location == 'http://example.net/test/' |
|
47 | ||
48 |
app = login(get_app(pub), username='foo', password='foo') |
|
49 |
pub.cfg['identification'] = {'methods': ['idp']} |
|
50 |
pub.write_cfg() |
|
51 |
# if the user is logged in, the form should be presented |
|
52 |
resp = app.get('/test/tryauth') |
|
53 |
assert resp.location == 'http://example.net/test/' |
|
54 | ||
55 |
# if the user is unlogged, there should be a passive redirection to SSO |
|
56 |
resp = get_app(pub).get('/test/tryauth') |
|
57 |
assert 'IsPassive=true' in resp.location |
|
58 | ||
59 |
pub.cfg['identification'] = {'methods': ['password']} |
|
60 |
pub.write_cfg() |
|
61 | ||
62 | ||
63 |
def test_form_forceauth(pub, formdef): |
|
64 |
create_user(pub) |
|
65 | ||
66 |
resp = get_app(pub).get('/test/forceauth') |
|
67 |
assert resp.location == 'http://example.net/login/?ReturnUrl=http%3A//example.net/test/&forceAuthn=true' |
|
0 |
- |