def authenticate(): username = flask.request.form.get('username') password = flask.request.form.get('password') status, user = login_user(conf, username, password) if status == LOGIN_SUCCESS: saml_req_id = flask.request.cookies.get('mockidp_request_id') if saml_req_id not in open_saml_requests: return '404: Missing login session', 404 saml_request = open_saml_requests[saml_req_id] session = get_session(user, saml_request) url, saml_response = create_auth_response(conf, session) return flask.render_template('auth_response.html', post_url=url, saml_response=saml_response) else: flask.flash(f"Incorrect username or password {username}") return flask.redirect("/saml/login", code=302)
def test_incorrect_password(): status, user = login_user(config, 'charlie', 'wrongpassword') eq_(LOGIN_FAIL, status) eq_(None, user)
def test_non_existing_user(): status, user = login_user(config, 'penelope', 'anypassword') eq_(LOGIN_FAIL, status) eq_(None, user)
def test_successful_login(): status, user = login_user(config, 'charlie', 'secret') eq_(LOGIN_SUCCESS, status) eq_('charlie brown', user['name'])