def setUp(self):
     super(AccountRequestServiceTest, self).setUp()
     self.email_service = Mock(EmailService)
     self.crowd_client = Mock(CrowdClient)
     crowd_client_factory = CrowdClientFactory()
     crowd_client_factory.get_client = Mock(return_value=self.crowd_client)
     self.account_request_service = AccountRequestService(
         email_service=self.email_service,
         crowd_client_factory=crowd_client_factory)
     self.clean_database()
Пример #2
0
    def test_GIVEN_user_and_password_WHEN_password_set_THEN_password_call_made_to_crowd_and_forgotten_password_blanked(self):
        user = self.login()
        crowd_client = Mock(CrowdClient)
        crowd_client_factory = CrowdClientFactory()
        crowd_client_factory.get_client = Mock(return_value=crowd_client)
        user_service = UserService(crowd_client_factory=crowd_client_factory)
        user_service.set_forgot_password(user.id)
        password = "******"

        user_service.reset_password(user.id, password, password)

        assert_that(crowd_client.update_users_password.called, is_(True), "Crowd called to update user")
        user = user_service.get_user_by_id(user.id)
        assert_that(user.forgotten_password_uuid, is_(None), "uuid")
        assert_that(user.forgotten_password_expiry_date, is_(None), "expiry date")
Пример #3
0
    def test_GIVEN_user_and_password_WHEN_password_set_and_crowd_client_raises_THEN_forgotten_password_not_blanked_error(self):
        user = self.login()
        crowd_client = Mock(CrowdClient)
        crowd_client.update_users_password = Mock(side_effect=ClientException())
        crowd_client_factory = CrowdClientFactory()
        crowd_client_factory.get_client = Mock(return_value=crowd_client)
        user_service = UserService(crowd_client_factory=crowd_client_factory)
        user_service.set_forgot_password(user.id)
        password = "******"

        with self.assertRaises(ServiceException, msg="Service exception not raise"):
            user_service.reset_password(user.id, password, password)

        user = user_service.get_user_by_id(user.id)
        assert_that(user.forgotten_password_uuid, is_not(None), "uuid")
        assert_that(user.forgotten_password_expiry_date, is_not(None), "expiry date")