コード例 #1
0
def test_setter_properties(app):
    from aura.models import User
    user = User(username="******", password="******")
    user.username = "******"
    assert user.username == "other"
    user.password = "******"
    assert user.password_is("otherpass")
コード例 #2
0
def test_username_failures(mock_user, name, app):
    mock_user.return_value = None
    from aura.models import User
    user = User()
    #Username empty, too short, too long
    with pytest.raises(UserDomainError):
        user.username = name
コード例 #3
0
def test_password_failures(mock_user, pw, app):
    mock_user.return_value = None
    from aura.models import User

    user = User()
    #Password empty, too short
    with pytest.raises(UserDomainError):
        user.password = pw
コード例 #4
0
def create_user(data):
    data = validate(
        Schema({
            'username': str,
            'password': str
        }, ignore_extra_keys=True), data)

    user = User(username=data['username'], password=data['password'])
    db.session.add(user)
    db.session.commit()
    return user
コード例 #5
0
ファイル: test_services_auth.py プロジェクト: elymatos/aura
def test_retrieve_user_invalid_credentials(app):
    from aura.models import User
    db = get_db()
    db.session.add(User(username='******', password='******'))
    db.session.commit()

    from aura.services import retrieve_user
    #Non existing user
    with pytest.raises(ServiceError):
        retrieve_user({'username':'******', 'password': '******'})
    #Wrong password still raises Service error
    with pytest.raises(ServiceError):
        retrieve_user({'username':'******', 'password': '******'})
コード例 #6
0
ファイル: test_services_auth.py プロジェクト: elymatos/aura
def test_retrieve_user(app):
    from aura.models import User
    from aura.services import retrieve_user
    with app.app_context():
        db = get_db()
        db.session.add(User(username='******', password='******'))
        db.session.commit()

        user = User.query.filter_by(username='******').first()
        print("==")
        print(user)
        print("==")

        
        user = retrieve_user({'username':'******', 'password': '******'})
        assert isinstance(user, User)
        assert user.username == 'admin'
        assert user.password_is('admin')
コード例 #7
0
def test_password_encryption(app):
    from aura.models import User
    user = User("user", "pass")
    assert user.password != "pass"
コード例 #8
0
def test_hybrid_properties(app):
    from aura.models import User
    user = User(username="******", password="******")
    assert user.username == user._username
    assert user.password == user._password
コード例 #9
0
def test_constructor(app):
    from aura.models import User
    user = User(username="******", password="******")
    assert user.username == "user"
    assert user.password_is("pass")