Пример #1
0
    def test_login_user(self):
        User.register(email=self.email,
                      name=self.name,
                      plaintext_password=self.password)

        response = self.login_user()
        assert response.status_code == 302
Пример #2
0
    def _verify_user(self, user_id):
        user = User.get_by_id(user_id)

        assert user.id == int(user_id)
        assert user.email == self.email
        assert user.name == self.name

        assert AuthService().verify_password(plaintext_password=self.password,
                                             password_hash=user.password)
Пример #3
0
    def setUp(self):
        super(TestExchange, self).setUp()
        self.what_to_get = 'a cat'
        self.what_not_to_get = 'a dog'
        self.who_to_ask_for_help = 'nora or zach'

        self.user = User.register(email='test_email',
                                  plaintext_password='******',
                                  name='test_name')
        self.exchange = Exchange.create(creator_id=self.user.id,
                                        name='test',
                                        ends_at=datetime.utcnow())
Пример #4
0
    def _create_user(self, exchange_id):
        user = User.register(
            email=
            f"{self._rand()}.{self._rand()}.{self._rand()}.{self._rand()}",
            name="name",
            plaintext_password="******",
        )

        ExchangeRegistration.register(
            exchange_id=exchange_id,
            user_id=user.id,
            who_to_ask_for_help='',
            what_not_to_get='',
            what_to_get='',
        )
Пример #5
0
        def register_post():
            for field in ['email', 'password', 'name']:
                if field not in request.form:
                    flash(f'{field} is missing from the request', 'error')
                    return BlueprintName.AUTH.redirect('register_get')

            try:
                registered_user = User.register(
                    email=request.form['email'],
                    plaintext_password=request.form['password'],
                    name=request.form['name']
                )

                login_user(registered_user)
            except Exception as e:
                flash(str(e), 'error')
                return BlueprintName.AUTH.redirect('register_get')

            return BlueprintName.EXCHANGES.redirect('exchanges_get')
Пример #6
0
        def login_post():
            for field in ['email', 'password']:
                if field not in request.form:
                    flash(f'{field} is missing from the request', 'error')
                    return BlueprintName.AUTH.redirect('login_get')

            email = request.form['email']
            password = request.form['password']

            try:
                logged_in_user = User.login(
                    email=email,
                    plaintext_password=password
                )
                login_user(logged_in_user)
            except Exception as e:
                flash(str(e), 'error')
                return BlueprintName.AUTH.redirect('login_get')

            return BlueprintName.EXCHANGES.redirect('exchanges_get')
Пример #7
0
 def setUp(self):
     super(TestMatch, self).setUp()
     self.match_service = MatchingService()
     self.creator = User.register(email='test_email',
                                  plaintext_password='******',
                                  name='test_name')