Ejemplo n.º 1
0
def remembered_valid_thedude_totp_token(thedude_totp_key, cache_handler):
    keys = cache_handler.keys('*authentication*')
    for key in keys:
        cache_handler.cache_region.delete(key)

    token = int(TOTP(key=thedude_totp_key, digits=6).generate().token)
    yield TOTPToken(token, remember_me=True)

    keys = cache_handler.keys('*authentication*')
    for key in keys:
        cache_handler.cache_region.delete(key)
Ejemplo n.º 2
0
def valid_thedude_totp_token(thedude_totp_key, cache_handler, totp_factory):
    keys = cache_handler.keys('*authentication*')
    for key in keys:
        cache_handler.cache_region.delete(key)

    totp = totp_factory.from_json(thedude_totp_key)
    token = totp.generate().token
    yield TOTPToken(totp_token=token)

    keys = cache_handler.keys('*authentication*')
    for key in keys:
        cache_handler.cache_region.delete(key)
Ejemplo n.º 3
0
def invalid_thedude_totp_token(cache_handler, yosai, monkeypatch):
    keys = cache_handler.keys('*authentication*')
    for key in keys:
        cache_handler.cache_region.delete(key)

    token = int(TOTP(key='AYAGB3C5RPYX5375L5VY2ULKZXMXWLZF', digits=6).generate().token)
    yield TOTPToken(totp_token=token)

    keys = cache_handler.keys('*authentication*')
    for key in keys:
        cache_handler.cache_region.delete(key)

    with Yosai.context(yosai):
        new_subject = Yosai.get_current_subject()
        da = new_subject.security_manager.authenticator
        monkeypatch.setattr(da.authc_settings, 'account_lock_threshold', 3)
        da.init_locking()
        da.locking_realm.unlock_account('thedude')
Ejemplo n.º 4
0
def totp_token():
    return TOTPToken(123456)
Ejemplo n.º 5
0
def test_totp_credentials_raises():
    with pytest.raises(MalformedTokenError):
        TOTPToken(1234567)
Ejemplo n.º 6
0
def totp_token():
    return TOTPToken('123456')