Example #1
0
    def test_password_hashing(self):
        from horus.tests.models import UserAccount
        user_account1 = UserAccount(username='******', email='*****@*****.**')
        user_account1.set_password('password')
        self.session.add(user_account1)
        self.session.flush()

        assert user_account1.password != 'password'
        assert user_account1.salt != None
Example #2
0
    def test_acl(self):
        from horus.tests.models import UserAccount
        from pyramid.security import Allow

        user_account1 = UserAccount(username='******', email='*****@*****.**')
        user_account1.set_password('foo')

        self.session.add(user_account1)
        self.session.flush()

        assert user_account1.__acl__ == [(Allow, 'useraccount:%s' % user_account1.id, 'access_user_account')]
Example #3
0
    def test_get_user_by_invalid_email(self):
        from horus.tests.models import UserAccount

        user_account = UserAccount(username='******', email='*****@*****.**')
        user_account.set_password('password')
        self.session.add(user_account)
        self.session.commit()

        request = testing.DummyRequest()

        new_user_account = UserAccount.get_by_email(request, '*****@*****.**')

        assert new_user_account == None
Example #4
0
    def test_get_user_by_id(self):
        from horus.tests.models import UserAccount

        user_account = UserAccount(username='******', email='*****@*****.**')
        user_account.set_password('temp')
        self.session.add(user_account)
        self.session.commit()

        request = testing.DummyRequest()

        new_user_account = UserAccount.get_by_id(request, user_account.id)

        assert new_user_account == user_account
Example #5
0
    def test_get_user_by_activation(self):
        from horus.tests.models import UserAccount
        from horus.tests.models import Activation

        user_account = UserAccount(username='******', email='*****@*****.**')
        user_account.set_password('password')
        activation = Activation()
        user_account.activation = activation

        self.session.add(user_account)
        self.session.commit()

        request = testing.DummyRequest()

        new_user_account = UserAccount.get_by_activation(request, activation)

        assert new_user_account == user_account
Example #6
0
    def test_get_all(self):
        from horus.tests.models import Group
        from horus.tests.models import User
        from horus.tests.models import UserAccount

        user = User()
        user_account = UserAccount(username='******', email='*****@*****.**')
        user_account.set_password('temp')
        user.accounts.apend(user_account)
        self.session.add(user)

        group = Group(name='admin', description='group for admins')
        group.users.append(user)
        self.session.add(group)
        self.session.commit()

        request = testing.DummyRequest()

        groups = Group.get_all(request)

        assert len(groups.all()) == 1
Example #7
0
    def test_get_all_users(self):
        from horus.tests.models import UserAccount

        user_account = UserAccount(username='******', email='*****@*****.**')
        user_account.set_password('temp')
        user_account2 = UserAccount(username='******', email='*****@*****.**')
        user_account2.set_password('temp')
        self.session.add(user_account)
        self.session.add(user_account2)
        self.session.commit()

        request = testing.DummyRequest()

        user_accounts = UserAccount.get_all(request)

        assert len(user_accounts.all()) == 2
Example #8
0
    def test_get_user_by_activation_with_multiple_users(self):
        from horus.tests.models import UserAccount
        from horus.tests.models import Activation

        user_account1 = UserAccount(username='******', email='*****@*****.**')
        user_account2 = UserAccount(username='******', email='*****@*****.**')
        user_account1.set_password('password')
        user_account2.set_password('password2')
        activation = Activation()
        user_account2.activation = activation

        self.session.add(user_account1)
        self.session.add(user_account2)

        self.session.commit()

        request = testing.DummyRequest()

        new_user_account = UserAccount.get_by_activation(request, activation)

        assert new_user_account == user_account2