Example #1
0
    def test_change_password(self):
        user = User(password=User.hash_password('password1'))
        assert user.verify_password('password1')

        with patch.object(User, '_save', return_value=make_future()):
            yield user.change_password('password1', 'password2')

            assert user.verify_password('password2')
            assert User._save.call_count == 1
Example #2
0
    def test_change_password(self):
        user = User(password=User.hash_password('password1'))
        assert user.verify_password('password1')

        with patch.object(User, '_save', return_value=make_future()):
            yield user.change_password('password1', 'password2')

            assert user.verify_password('password2')
            assert User._save.call_count == 1
Example #3
0
from perch import Organisation, Repository, User
from perch.model import State

from accounts.models import email


ADMINS = [
    '*****@*****.**',
    '*****@*****.**',
]
ADMIN = User(_id='admin1', name='admin user', email='*****@*****.**')
USER = User(
    first_name='test first',
    last_name='test last',
    verification_hash='testhash',
    password=User.hash_password('password0'),
    has_agreed_to_terms=True,
    email='*****@*****.**',
    _id='test id'
)
ORGANISATION = Organisation(
    _id='org1',
    name='test organisation'
)
REPOSITORY = Repository(
    id='repo1',
    organisation_id=ORGANISATION.id,
    name='test repo'
)

Example #4
0
    def test_change_password_incorrect_password(self):
        user = User(password=User.hash_password('password1'))

        with pytest.raises(exceptions.Unauthorized):
            yield user.change_password('password2', 'password3')
Example #5
0
from __future__ import unicode_literals

import pytest
from mock import patch
from tornado.testing import AsyncTestCase, gen_test

from perch import exceptions, Token, User
from perch.model import State
from .util import make_future, patch_db, patch_view

USERS = [{
    '_id': 'user0',
    'type': 'user',
    'email': '*****@*****.**',
    'password': User.hash_password('password0'),
    'state': 'approved',
    'has_agreed_to_terms': True,
    'organisations': {}
}, {
    '_id': 'user1',
    'type': 'user',
    'email': '*****@*****.**',
    'password': User.hash_password('password1'),
    'state': 'approved',
    'has_agreed_to_terms': True,
    'verification_hash': 'this is a hash'
}]

VERIFIED_USER = USERS[0]
UNVERIFIED_USER = USERS[1]
from functools import partial

import couch
import pytest
from mock import patch
from tornado.ioloop import IOLoop
from tornado.httpclient import HTTPError

from perch import Organisation, Service, Repository, UserOrganisation, User
from ..util import make_future

USER = {
    '_id': 'user0',
    'type': 'user',
    'email': '*****@*****.**',
    'password': User.hash_password('password0'),
    'state': 'approved',
    'role': 'user',
    'has_agreed_to_terms': True,
    'organisations': {}
}

sys_role = [
    ('administrator', True),
    ('user', False)
]

org_user_role = [
    ({
        'state': 'pending',
        'role': 'user'
Example #7
0
    def test_change_password_incorrect_password(self):
        user = User(password=User.hash_password('password1'))

        with pytest.raises(exceptions.Unauthorized):
            yield user.change_password('password2', 'password3')