def authenticate():
    if not request.json or not 'user' in request.json or not 'password' in request.json or not 'metadata' in request.json:
        abort(400)
    try:
        with sql.connect("database.db") as con:
            cur = con.cursor()
            user = request.json['user']
            password = request.json['password']
            metadata = request.json['metadata']
            ip = metadata['IP']
            cookie = metadata['Cookie']
            redirect = metadata['Redirect']
            userAgent = metadata['UserAgent']
            os = userAgent['OS']
            browser = userAgent['Browser']
            cur.execute(
                "INSERT INTO AUTHENTICATION(name,password,ip,cookie,redirect,os,browser,date) VALUES (?,?,?,?,?,?,?,CURRENT_TIMESTAMP)",
                (user, password, ip, cookie, redirect, os, browser))
            con.commit()
            msg = "Record successfully added"
            print(msg)
    finally:
        con.close()
        return jsonify({
            "Authentication":
            True,
            "Check-email":
            check_email(request.json['user']),
            "Check-password":
            check_password(request.json['password'])
        }), 201
Esempio n. 2
0
def test_check_email(mock_requests):
    mock_requests.get.return_value.text = breaches

    response = check_email('*****@*****.**')

    assert response