def test_check_session_with_no_user_id_in_session(self):
        with self.app_request_context("/status"):
            with patch("app.authentication.authenticator.get_session_store",
                       return_value=None):
                # When
                user = load_user()

                # Then
                self.assertIsNone(user)
示例#2
0
def test_check_session_with_no_user_id_in_session(app, mocker):
    mocker.patch("app.authentication.authenticator.get_session_store",
                 return_value=None)

    with app.app_context():
        # Given / When
        user = load_user()

        # Then
        assert user is None
示例#3
0
    def test_check_session_with_no_user_id_in_session(self):
        with self.application.test_request_context():
            # Given
            self.session_storage.get_user_id = Mock(return_value=None)

            # When
            user = load_user()

            # Then
            self.assertIsNone(user)
    def test_check_session_with_no_user_id_in_session(self):
        with patch('app.authentication.authenticator.session_storage'
                   ) as session_storage:
            # Given
            session_storage.has_user_id = Mock(return_value=False)

            # When
            user = load_user()

            # Then
            self.assertIsNone(user)
    def test_check_session_with_user_id_in_session(self):
        with patch('app.authentication.authenticator.session_storage') as session_storage, \
             patch('app.authentication.authenticator.get_questionnaire_store', return_value=MagicMock()):
            # Given
            session_storage.has_user_id = Mock(return_value=True)
            session_storage.get_user_id = Mock(return_value='user_id')
            session_storage.get_user_ik = Mock(return_value='user_ik')

            # When
            user = load_user()

            # Then
            self.assertEqual(user.user_id, 'user_id')
            self.assertEqual(user.user_ik, 'user_ik')
    def test_check_session_with_user_id_in_session(self):
        with self.app_request_context('/status'):
            with patch('app.authentication.authenticator.get_session_store',
                       return_value=self.session_store):
                # Given
                self.session_store.create('eq_session_id', 'user_id',
                                          self.session_data)
                session[USER_IK] = 'user_ik'

                # When
                user = load_user()

                # Then
                self.assertEqual(user.user_id, 'user_id')
                self.assertEqual(user.user_ik, 'user_ik')
    def test_check_session_with_user_id_in_session(self):
        with self.app_request_context("/status"):
            with patch(
                    "app.authentication.authenticator.get_session_store",
                    return_value=self.session_store,
            ):
                # Given
                self.session_store.create("eq_session_id", "user_id",
                                          self.session_data, self.expires_at)
                cookie_session[USER_IK] = "user_ik"

                # When
                user = load_user()

                # Then
                self.assertEqual(user.user_id, "user_id")
                self.assertEqual(user.user_ik, "user_ik")
示例#8
0
def test_check_session_with_user_id_in_session(
    app,
    session_store,
    session_data,
    expires_at,
    mocker,
):
    mocker.patch("app.authentication.authenticator.get_session_store",
                 return_value=session_store)
    with app.app_context():
        # Given
        session_store.create("eq_session_id", "user_id", session_data,
                             expires_at)
        cookie_session[USER_IK] = "user_ik"

        # When
        user = load_user()

        # Then
        assert user.user_id == "user_id"
        assert user.user_ik == "user_ik"