Esempio n. 1
0
def test_valid_registration_full_process_second_user_not_fully_managed(
        test_client, init_database):
    """
    GIVEN a Flask application configured for testing
    WHEN the '/register' page is posted to (POST)
    THEN check the response is valid and the user is logged in
    """
    response = test_client.post(
        '/auth/register',
        data=dict(username='******',
                  email='*****@*****.**',
                  password='******',
                  password2='password'),
        follow_redirects=True)
    assert response.status_code == 200
    assert b'Please verify your account' in response.data
    security(test_client)

    user = User.query.filter_by(
        email='*****@*****.**').first()
    token = user.get_mail_verification_token()
    response = test_client.get('/auth/verify_account?token=' + token,
                               follow_redirects=True)
    assert response.status_code == 200
    assert b'Register your company' not in response.data
    assert b'Trending' not in response.data
    assert b'invitation' in response.data
    """
    GIVEN a Flask application configured for testing
    WHEN the '/logout' page is requested (GET)
    THEN check the response is valid
    """
    response = test_client.get('/auth/logout', follow_redirects=True)
    assert response.status_code == 200
    assert b'Next' in response.data
Esempio n. 2
0
def test_login_page(test_client):
    """
    GIVEN a Flask application configured for testing
    WHEN the '/login' page is requested (GET)
    THEN check the response is valid
    """
    response = test_client.get('/auth/login')
    assert response.status_code == 200
    assert b'Next' in response.data

    # Check that admin panel is not accessible
    security(test_client)
Esempio n. 3
0
def test_email_unknown_login_email(test_client, init_database):
    """
    GIVEN a Flask application configured for testing
    WHEN the '/login' page is posted to with new unknown email (POST)
    THEN check that the register page is launched
    """
    response = test_client.post('/auth/login',
                                data=dict(email='*****@*****.**'),
                                follow_redirects=True)
    assert response.status_code == 200
    assert b'Register' in response.data
    # Check that admin panel is not accessible
    security(test_client)
Esempio n. 4
0
def test_invalid_login_bad_email_format(test_client, init_database):
    """
    GIVEN a Flask application configured for testing
    WHEN the '/login' page is posted to with invalid credentials (POST)
    THEN check an error message is returned to the user
    """
    response = test_client.post('/auth/login',
                                data=dict(email='info2pulsarnews.io'),
                                follow_redirects=True)
    assert response.status_code == 200
    assert b'Next' in response.data
    # Check that admin panel is not accessible
    security(test_client)
Esempio n. 5
0
def test_valid_login_logout(test_client, init_database):
    """
    GIVEN a Flask application configured for testing
    WHEN the '/login' page is posted to (POST)
    THEN check the response is valid
    """
    response = test_client.post('/auth/login_password',
                                data=dict(email='*****@*****.**',
                                          password='******'),
                                follow_redirects=True)
    assert response.status_code == 200
    assert b'Trending' not in response.data

    # Check that admin panel is not accessible
    security(test_client)
    """
    GIVEN a Flask application configured for testing
    WHEN the '/logout' page is requested (GET)
    THEN check the response is valid
    """
    response = test_client.get('/auth/logout', follow_redirects=True)
    assert response.status_code == 200
    assert b'Next' in response.data
Esempio n. 6
0
def test_valid_registration(test_client, init_database):
    """
    GIVEN a Flask application configured for testing
    WHEN the '/register' page is posted to (POST)
    THEN check the response is valid and the user is logged in
    """
    response = test_client.post('/auth/register',
                                data=dict(username='******',
                                          email='*****@*****.**',
                                          password='******',
                                          password2='password'),
                                follow_redirects=True)
    assert response.status_code == 200
    assert b'Please verify your account' in response.data
    security(test_client)
    """
    GIVEN a Flask application configured for testing
    WHEN the '/logout' page is requested (GET)
    THEN check the response is valid
    """
    response = test_client.get('/auth/logout', follow_redirects=True)
    assert response.status_code == 200
    assert b'Next' in response.data