示例#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
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
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")