def test_403s(app):
    """These should return 403 instead of 404."""
    for url in ('dashboard/', 'dashboard/test/1/', 'dashboard/abc/def/'):
        rv = app.get(phase2_url + url)
        assert rv.status_code == 403
        rv = app.get(phase2_url + url, headers={'Cookie': 'session=asdf'})
        assert rv.status_code == 403
def test_item_404(app):
    url = phase2_url + 'dashboard/'
    init_data(app.application.redis)

    rv = app.get(url + 'abcdef/0/', headers={
                                        'Cookie': 'session=%s' % session_key})
    assert rv.status_code == 404

    rv = app.get(url + 'test/0/', headers={
                                        'Cookie': 'session=%s' % session_key})
    assert rv.status_code == 404

    rv = app.get(url + 'admin/1/', headers={
                                        'Cookie': 'session=%s' % session_key})
    assert rv.status_code == 404
def test_admin_dashboard(app):
    url = phase2_url + 'dashboard/'
    init_data(app.application.redis)

    rv = app.get(url, headers={'Cookie': 'session=%s' % admin_session_key})
    assert b'Challenge complete!' in rv.data
    assert rv.status_code == 200
def test_solution(app):
    url = phase2_url + 'dashboard/admin/password/'
    init_data(app.application.redis)

    rv = app.get(url, headers={'Cookie': 'session=%s' % session_key})
    assert admin_hash.encode('utf-8') in rv.data
    assert rv.status_code == 200
def test_dashboard(app):
    url = phase2_url + 'dashboard/'
    init_data(app.application.redis)

    rv = app.get(url, headers={'Cookie': 'session=%s' % session_key})
    assert b'Buy groceries' in rv.data
    assert b'Take over the world' in rv.data
    assert rv.status_code == 200
Exemplo n.º 6
0
def test_404(app):
    rv = app.get('/asdf')
    assert rv.status_code == 404
Exemplo n.º 7
0
def test_home(app):
    rv = app.get('/')
    assert rv.status_code == 301
def test_get_405(app):
    rv = app.get(phase2_url + 'login/')
    assert rv.status_code == 405
def test_404(app):
    rv = app.get(phase2_url + 'asdf')
    assert rv.status_code == 404
Exemplo n.º 10
0
def test_home(app):
    rv = app.get(phase2_url)
    assert b'Sign In' in rv.data
    assert rv.status_code == 200
Exemplo n.º 11
0
def test_authed(app):
    rv = app.get('/phase1/', headers={'Cookie': 'uid=0'})
    assert b'Authenticated' in rv.data
    assert rv.status_code == 200
Exemplo n.º 12
0
def test_unauthed(app):
    rv = app.get('/phase1/')
    assert b'Not authenticated' in rv.data
    assert rv.status_code == 200