misc: split auth tests
This commit is contained in:
parent
c9225cb94c
commit
7481ab86d3
|
@ -1597,47 +1597,6 @@ def test_form_visit_existing(pub):
|
|||
assert 'The form has been recorded on' in resp
|
||||
|
||||
|
||||
def test_form_auth(pub):
|
||||
create_user(pub)
|
||||
formdef = create_formdef()
|
||||
formdef.data_class().wipe()
|
||||
resp = get_app(pub).get('/test/auth')
|
||||
assert resp.location == 'http://example.net/login/?ReturnUrl=http%3A//example.net/test/'
|
||||
|
||||
resp = login(get_app(pub), username='foo', password='foo').get('/test/auth')
|
||||
assert resp.location == 'http://example.net/test/'
|
||||
|
||||
|
||||
def test_form_tryauth(pub):
|
||||
create_user(pub)
|
||||
formdef = create_formdef()
|
||||
formdef.data_class().wipe()
|
||||
resp = get_app(pub).get('/test/tryauth')
|
||||
assert resp.location == 'http://example.net/test/'
|
||||
|
||||
app = login(get_app(pub), username='foo', password='foo')
|
||||
pub.cfg['identification'] = {'methods': ['idp']}
|
||||
pub.write_cfg()
|
||||
# if the user is logged in, the form should be presented
|
||||
resp = app.get('/test/tryauth')
|
||||
assert resp.location == 'http://example.net/test/'
|
||||
|
||||
# if the user is unlogged, there should be a passive redirection to SSO
|
||||
resp = get_app(pub).get('/test/tryauth')
|
||||
assert 'IsPassive=true' in resp.location
|
||||
|
||||
pub.cfg['identification'] = {'methods': ['password']}
|
||||
pub.write_cfg()
|
||||
|
||||
|
||||
def test_form_forceauth(pub):
|
||||
create_user(pub)
|
||||
formdef = create_formdef()
|
||||
formdef.data_class().wipe()
|
||||
resp = get_app(pub).get('/test/forceauth')
|
||||
assert resp.location == 'http://example.net/login/?ReturnUrl=http%3A//example.net/test/&forceAuthn=true'
|
||||
|
||||
|
||||
def test_form_no_tracking_code(pub):
|
||||
formdef = create_formdef()
|
||||
formdef.data_class().wipe()
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
import pytest
|
||||
|
||||
from wcs.formdef import FormDef
|
||||
|
||||
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, login
|
||||
from .test_all import create_user
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request):
|
||||
pub = create_temporary_pub()
|
||||
pub.cfg['identification'] = {'methods': ['password']}
|
||||
pub.cfg['language'] = {'language': 'en'}
|
||||
pub.write_cfg()
|
||||
return pub
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def formdef(pub):
|
||||
FormDef.wipe()
|
||||
formdef = FormDef()
|
||||
formdef.name = 'test'
|
||||
formdef.fields = []
|
||||
formdef.store()
|
||||
return formdef
|
||||
|
||||
|
||||
def teardown_module(module):
|
||||
clean_temporary_pub()
|
||||
|
||||
|
||||
def test_form_auth(pub, formdef):
|
||||
create_user(pub)
|
||||
|
||||
resp = get_app(pub).get('/test/auth')
|
||||
assert resp.location == 'http://example.net/login/?ReturnUrl=http%3A//example.net/test/'
|
||||
|
||||
resp = login(get_app(pub), username='foo', password='foo').get('/test/auth')
|
||||
assert resp.location == 'http://example.net/test/'
|
||||
|
||||
|
||||
def test_form_tryauth(pub, formdef):
|
||||
create_user(pub)
|
||||
|
||||
resp = get_app(pub).get('/test/tryauth')
|
||||
assert resp.location == 'http://example.net/test/'
|
||||
|
||||
app = login(get_app(pub), username='foo', password='foo')
|
||||
pub.cfg['identification'] = {'methods': ['idp']}
|
||||
pub.write_cfg()
|
||||
# if the user is logged in, the form should be presented
|
||||
resp = app.get('/test/tryauth')
|
||||
assert resp.location == 'http://example.net/test/'
|
||||
|
||||
# if the user is unlogged, there should be a passive redirection to SSO
|
||||
resp = get_app(pub).get('/test/tryauth')
|
||||
assert 'IsPassive=true' in resp.location
|
||||
|
||||
pub.cfg['identification'] = {'methods': ['password']}
|
||||
pub.write_cfg()
|
||||
|
||||
|
||||
def test_form_forceauth(pub, formdef):
|
||||
create_user(pub)
|
||||
|
||||
resp = get_app(pub).get('/test/forceauth')
|
||||
assert resp.location == 'http://example.net/login/?ReturnUrl=http%3A//example.net/test/&forceAuthn=true'
|
Loading…
Reference in New Issue