def test_login_redirect(app, io_loop):
    cookies = app.login_user('river')
    user = app.users['river']
    # no next_url, server running
    io_loop.run_sync(user.spawn)
    r = get_page('login', app, cookies=cookies, allow_redirects=False)
    r.raise_for_status()
    assert r.status_code == 302
    assert '/user/river' in r.headers['Location']
    
    # no next_url, server not running
    io_loop.run_sync(user.stop)
    r = get_page('login', app, cookies=cookies, allow_redirects=False)
    r.raise_for_status()
    assert r.status_code == 302
    assert '/hub/' in r.headers['Location']
    
    # next URL given, use it
    r = get_page('login?next=/hub/admin', app, cookies=cookies, allow_redirects=False)
    r.raise_for_status()
    assert r.status_code == 302
    assert r.headers['Location'].endswith('/hub/admin')
dataset/ETHPy150Open jupyterhub/jupyterhub/jupyterhub/tests/test_pages.py/test_login_redirect/original