Ejemplo n.º 1
0
async def test_authentication_with_exceed_atempts_of_login(tmpcwd, app):
    auth = NaasAuthenticator(db=app.db)
    auth.allowed_failed_logins = 3
    auth.secs_before_next_try = 10

    infos = {"username": "******", "password": "******"}
    auth.create_user(infos["username"], "password")
    UserInfo.change_authorization(app.db, "johnsnow")

    for i in range(3):
        response = await auth.authenticate(app, infos)
        assert not response

    infos["password"] = "******"
    response = await auth.authenticate(app, infos)
    assert not response
Ejemplo n.º 2
0
async def test_authentication_with_exceed_atempts_of_login(tmpcwd, app):
    auth = NaasAuthenticator(db=app.db)
    auth.allowed_failed_logins = 3
    auth.secs_before_next_try = 10

    infos = {'username': '******', 'password': '******'}
    auth.get_or_create_user(infos['username'], 'password')
    UserInfo.change_authorization(app.db, 'johnsnow')

    for i in range(3):
        response = await auth.authenticate(app, infos)
        assert not response

    infos['password'] = '******'
    response = await auth.authenticate(app, infos)
    assert not response

    time.sleep(12)
    response = await auth.authenticate(app, infos)
    assert response