예제 #1
0
    def test_authenticate_using_token(self):
        user = UserFactory.create()

        exists, auth_user = User.authenticate(email=user.email, password=UserFactory.get_default_password())
        expect(auth_user).not_to_be_null()

        auth_user = User.authenticate_with_token(token=auth_user.token)
        expect(auth_user).not_to_be_null()
예제 #2
0
    def test_authenticate_using_token(self):
        user = UserFactory.create()

        exists, auth_user = User.authenticate(
            email=user.email, password=UserFactory.get_default_password())
        expect(auth_user).not_to_be_null()

        auth_user = User.authenticate_with_token(token=auth_user.token)
        expect(auth_user).not_to_be_null()
예제 #3
0
    def test_can_create_user(self):
        user = UserFactory.create()

        password = UserFactory.get_default_password()
        password = hmac.new(six.b(str(user.salt)), six.b(password), hashlib.sha1).hexdigest()

        retrieved = User.objects(id=user.id)
        expect(retrieved.count()).to_equal(1)
        expect(retrieved.first().password).to_equal(password)
        expect(retrieved.first().email).to_equal(user.email)
        expect(retrieved.first().token).to_equal(user.token)
예제 #4
0
    def test_can_create_user(self):
        user = UserFactory.create()

        password = UserFactory.get_default_password()
        password = hmac.new(six.b(str(user.salt)), six.b(password),
                            hashlib.sha1).hexdigest()

        retrieved = User.objects(id=user.id)
        expect(retrieved.count()).to_equal(1)
        expect(retrieved.first().password).to_equal(password)
        expect(retrieved.first().email).to_equal(user.email)
        expect(retrieved.first().token).to_equal(user.token)
예제 #5
0
    def test_default_action_when_user_authenticated_properly(
            self, get_mock, mock_stdout):
        user = UserFactory.create()

        headers_mock = mock.Mock(get=lambda msg: "test-token-2")
        response_mock = mock.Mock(status_code=200, headers=headers_mock)
        get_mock.return_value = response_mock

        ctrl = self.make_controller(
            AuthController,
            conf=self.fixture_for('test.conf'),
            email=user.email,
            password=UserFactory.get_default_password())
        ctrl.app.user_data = UserData(target=self.get_url('/'))
        expect(ctrl.default()).to_be_true()

        expect(mock_stdout.getvalue()).to_be_like("Authenticated.")
        expect(get_mock.called).to_be_true()

        assert_token_is("test-token-2")
예제 #6
0
    def test_default_action_when_user_authenticated_properly(self, get_mock, mock_stdout):
        user = UserFactory.create()

        headers_mock = mock.Mock(get=lambda msg: "test-token-2")
        response_mock = mock.Mock(status_code=200, headers=headers_mock)
        get_mock.return_value = response_mock

        ctrl = self.make_controller(AuthController, conf=self.fixture_for('test.conf'), email=user.email, password=UserFactory.get_default_password())
        ctrl.app.user_data = UserData(target=self.get_url('/'))
        expect(ctrl.default()).to_be_true()

        expect(mock_stdout.getvalue()).to_be_like("Authenticated.")
        expect(get_mock.called).to_be_true()

        assert_token_is("test-token-2")