def test_user_verify_password_creates_login_event(client, sample_user):
    yesterday = datetime.utcnow() - timedelta(days=1)
    sample_user.logged_in_at = yesterday
    data = json.dumps({'password': '******', 'loginData': {"foo": "bar"}})
    auth_header = create_authorization_header()
    resp = client.post(
        url_for('user.verify_user_password', user_id=sample_user.id),
        data=data,
        headers=[('Content-Type', 'application/json'), auth_header])
    assert resp.status_code == 204
    assert User.query.get(sample_user.id).logged_in_at == yesterday

    events = list_login_events(sample_user.id)
    assert len(events) == 1
Exemple #2
0
def list_login_events_user(user_id):
    data = list_login_events(user_id)
    return jsonify(list(map(lambda o: o.serialize(), data)))
Exemple #3
0
def test_list_login_events(sample_login_event):
    LoginEvent(**{'user': sample_login_event.user, 'data': {}})

    keys = list_login_events(sample_login_event.user.id)
    assert len(keys) == 2
def test_list_login_events(sample_login_event):
    LoginEvent(**{"user": sample_login_event.user, "data": {}})

    keys = list_login_events(sample_login_event.user.id)
    assert len(keys) == 2