Пример #1
0
 def setUpClass(cls):
     # Create a dummy account for testing with; won't touch the database
     # as long as we don't `._commit()`
     name = "unit_tester_%s" % uuid.uuid4().hex
     cls._password = uuid.uuid4().hex
     cls._account = Account(name=name,
                            password=bcrypt_password(cls._password))
Пример #2
0
 def setUpClass(cls):
     # Create a dummy account for testing with; won't touch the database
     # as long as we don't `._commit()`
     name = "unit_tester_%s" % uuid.uuid4().hex
     cls._password = uuid.uuid4().hex
     cls._account = Account(
         name=name,
         password=bcrypt_password(cls._password)
     )
Пример #3
0
    def setUp(self):
        name = "unit_tester_%s" % uuid.uuid4().hex
        self._password = uuid.uuid4().hex
        self._account = Account(name=name,
                                password=bcrypt_password(self._password))
        self._account._id = 1337

        c.cookies = Cookies()
        c.secure = True
        c.user_is_loggedin = True
        c.user = self._account
        c.oauth_user = None
        request.method = "POST"
Пример #4
0
    def setUpClass(cls):
        cls._backup_user = c.user
        cls._backup_loggedin = c.user_is_loggedin

        # Create a dummy account for testing with; won't touch the database
        # as long as we don't `._commit()`
        name = "unit_tester_%s" % uuid.uuid4().hex
        cls._password = uuid.uuid4().hex
        try:
            Account._by_name(name)
            raise AccountExists
        except NotFound:
            cls._account = Account(name=name,
                                   password=bcrypt_password(cls._password))
Пример #5
0
    def setUp(self):
        name = "unit_tester_%s" % uuid.uuid4().hex
        self._password = uuid.uuid4().hex
        self._account = Account(
            name=name,
            password=bcrypt_password(self._password)
        )
        self._account._id = 1337

        c.cookies = Cookies()
        c.secure = True
        c.user_is_loggedin = True
        c.user = self._account
        c.oauth_user = None
        request.method = "POST"
Пример #6
0
    def setUpClass(cls):
        cls._backup_user = c.user
        cls._backup_loggedin = c.user_is_loggedin

        # Create a dummy account for testing with; won't touch the database
        # as long as we don't `._commit()`
        name = "unit_tester_%s" % uuid.uuid4().hex
        cls._password = uuid.uuid4().hex
        try:
            Account._by_name(name)
            raise AccountExists
        except NotFound:
            cls._account = Account(
                name=name,
                password=bcrypt_password(cls._password)
            )
Пример #7
0
    def setUp(self):
        super(PasswordUpdateTests, self).setUp()

        self.user = FakeAccount(name="fake", password=bcrypt_password(CURRENT_PW))
Пример #8
0
from pylons import app_globals as g

from r2.models import Account, Award, bcrypt_password, valid_password
from r2.models.token import (
    AccountRecoveryToken,
    OAuth2AccessToken,
    OAuth2RefreshToken,
)
from r2.tests import RedditControllerTestCase


CURRENT_PASSWORD = "******"
NEW_PASSWORD = "******"
HACKER_PASSWORD = "******"

CURRENT_PW_BCRYPT = bcrypt_password(CURRENT_PASSWORD)
HACKER_PW_BCRYPT = bcrypt_password(HACKER_PASSWORD)

USER_EMAIL = "*****@*****.**"
HACKER_EMAIL = "*****@*****.**"


class AccountRecoveryTest(RedditControllerTestCase):
    CONTROLLER = "api"

    def setUp(self):
        super(AccountRecoveryTest, self).setUp()

        self.user = MagicMock(name="user")
        self.user._fullname = "test"
        self.user.email = USER_EMAIL
Пример #9
0
from mock import patch, MagicMock
from pylons import app_globals as g

from r2.models import Account, Award, bcrypt_password, valid_password
from r2.models.token import (
    AccountRecoveryToken,
    OAuth2AccessToken,
    OAuth2RefreshToken,
)
from r2.tests import RedditControllerTestCase

CURRENT_PASSWORD = "******"
NEW_PASSWORD = "******"
HACKER_PASSWORD = "******"

CURRENT_PW_BCRYPT = bcrypt_password(CURRENT_PASSWORD)
HACKER_PW_BCRYPT = bcrypt_password(HACKER_PASSWORD)

USER_EMAIL = "*****@*****.**"
HACKER_EMAIL = "*****@*****.**"


class AccountRecoveryTest(RedditControllerTestCase):
    CONTROLLER = "api"

    def setUp(self):
        super(AccountRecoveryTest, self).setUp()

        self.user = MagicMock(name="user")
        self.user._fullname = "test"
        self.user.email = USER_EMAIL
Пример #10
0
    def setUp(self):
        super(PasswordUpdateTests, self).setUp()

        self.user = FakeAccount(name='fake',
                                password=bcrypt_password(CURRENT_PW))