def test_delete_user_collection_exploration_single(self):
        self.save_new_valid_exploration(self.EXPLORATION_1_ID, self.user_1_id)
        self.save_new_valid_collection(self.COLLECTION_1_ID,
                                       self.user_1_id,
                                       exploration_id=self.EXPLORATION_1_ID)

        wipeout_service.pre_delete_user(self.user_1_id)

        self.assertIsNotNone(
            user_models.UserSettingsModel.get_by_id(self.user_1_id))
        self.assertIsNotNone(
            user_models.UserEmailPreferencesModel.get_by_id(self.user_1_id))
        self.assertIsNotNone(
            collection_models.CollectionModel.get_by_id(self.COLLECTION_1_ID))
        self.assertIsNotNone(
            exp_models.ExplorationModel.get_by_id(self.EXPLORATION_1_ID))

        wipeout_service.delete_user(
            wipeout_service.get_pending_deletion_request(self.user_1_id))

        self.assertIsNone(
            user_models.UserSettingsModel.get_by_id(self.user_1_id))
        self.assertIsNone(
            user_models.UserEmailPreferencesModel.get_by_id(self.user_1_id))
        self.assertIsNone(
            collection_models.CollectionModel.get_by_id(self.COLLECTION_1_ID))
        self.assertIsNone(
            exp_models.ExplorationModel.get_by_id(self.EXPLORATION_1_ID))
Exemple #2
0
    def delete(self):
        """Handles DELETE requests."""
        if not constants.ENABLE_ACCOUNT_DELETION:
            raise self.PageNotFoundException

        wipeout_service.pre_delete_user(self.user_id)
        self.render_json({'success': True})
    def test_delete_user_multiple(self):
        wipeout_service.pre_delete_user(self.user_2_id)

        self.assertIsNotNone(
            user_models.UserSettingsModel.get_by_id(self.user_2_id))
        self.assertIsNotNone(
            user_models.UserEmailPreferencesModel.get_by_id(self.user_2_id))
        self.assertIsNotNone(
            user_models.CompletedActivitiesModel.get_by_id(self.user_2_id))
        self.assertIsNotNone(
            user_models.IncompleteActivitiesModel.get_by_id(self.user_2_id))
        self.assertIsNotNone(
            user_models.LearnerPlaylistModel.get_by_id(self.user_2_id))

        wipeout_service.delete_user(
            wipeout_service.get_pending_deletion_request(self.user_2_id))

        self.assertIsNone(
            user_models.UserSettingsModel.get_by_id(self.user_2_id))
        self.assertIsNone(
            user_models.UserEmailPreferencesModel.get_by_id(self.user_2_id))
        self.assertIsNone(
            user_models.CompletedActivitiesModel.get_by_id(self.user_2_id))
        self.assertIsNone(
            user_models.IncompleteActivitiesModel.get_by_id(self.user_2_id))
        self.assertIsNone(
            user_models.LearnerPlaylistModel.get_by_id(self.user_2_id))
 def setUp(self):
     super(WipeoutServiceVerifyDeleteTests, self).setUp()
     self.signup(self.USER_1_EMAIL, self.USER_1_USERNAME)
     self.signup(self.USER_2_EMAIL, self.USER_2_USERNAME)
     self.user_1_id = self.get_user_id_from_email(self.USER_1_EMAIL)
     self.user_2_id = self.get_user_id_from_email(self.USER_2_EMAIL)
     wipeout_service.pre_delete_user(self.user_1_id)
     wipeout_service.pre_delete_user(self.user_2_id)
    def setUp(self):
        super(FirebaseAccountWipeoutTests, self).setUp()
        self._uninstall_stub = FirebaseAdminSdkStub.install(self)

        firebase_admin.auth.create_user(uid=self.AUTH_ID)
        self.signup(self.EMAIL, self.USERNAME)
        self.user_id = self.get_user_id_from_email(self.EMAIL)
        firebase_auth_services.associate_auth_id_to_user_id(
            auth_domain.AuthIdUserIdPair(self.AUTH_ID, self.user_id))
        wipeout_service.pre_delete_user(self.user_id)
    def test_after_deletion_user_cannot_do_anything(self):
        wipeout_service.pre_delete_user(self.user_1_id)
        wipeout_service.delete_user(
            wipeout_service.get_pending_deletion_request(self.user_1_id))

        self.assertIsNone(user_services.get_user_settings(self.user_1_id))
        with self.assertRaisesRegexp(Exception, 'User not found.'):
            # Try to do some action with the deleted user.
            user_services.update_preferred_language_codes(
                self.user_1_id, ['en'])
    def test_pre_delete_user_exploration_is_marked_deleted(self):
        self.save_new_valid_exploration('exp_id', self.user_1_id)

        exp_model = exp_models.ExplorationModel.get_by_id('exp_id')
        self.assertFalse(exp_model.deleted)

        wipeout_service.pre_delete_user(self.user_1_id)

        exp_model = exp_models.ExplorationModel.get_by_id('exp_id')
        self.assertTrue(exp_model.deleted)
    def test_pre_delete_user_collection_is_marked_deleted(self):
        self.save_new_valid_collection(
            'col_id', self.user_1_id)

        collection_model = collection_models.CollectionModel.get_by_id('col_id')
        self.assertFalse(collection_model.deleted)

        wipeout_service.pre_delete_user(self.user_1_id)

        collection_model = collection_models.CollectionModel.get_by_id('col_id')
        self.assertTrue(collection_model.deleted)
    def test_pre_delete_user_with_activities(self):
        self.save_new_valid_exploration('exp_id', self.user_1_id)
        self.save_new_valid_collection(
            'col_id', self.user_1_id, exploration_id='exp_id')

        wipeout_service.pre_delete_user(self.user_1_id)

        pending_deletion_model = (
            user_models.PendingDeletionRequestModel.get_by_id(self.user_1_id))
        self.assertEqual(
            pending_deletion_model.exploration_ids, ['exp_id'])
        self.assertEqual(pending_deletion_model.collection_ids, ['col_id'])
 def setUp(self):
     super(WipeoutServiceDeleteStoryModelsTests, self).setUp()
     self.signup(self.USER_1_EMAIL, self.USER_1_USERNAME)
     self.signup(self.USER_2_EMAIL, self.USER_2_USERNAME)
     self.user_1_id = self.get_user_id_from_email(self.USER_1_EMAIL)
     self.user_2_id = self.get_user_id_from_email(self.USER_2_EMAIL)
     self.save_new_topic(self.TOPIC_1_ID,
                         self.user_1_id,
                         canonical_story_ids=[self.STORY_1_ID])
     self.save_new_story(self.STORY_1_ID, self.user_1_id, self.TOPIC_1_ID)
     wipeout_service.pre_delete_user(self.user_1_id)
     wipeout_service.pre_delete_user(self.user_2_id)
Exemple #11
0
 def setUp(self):
     super(UserDeletionOneOffJobTests, self).setUp()
     self.signup(self.USER_1_EMAIL, self.USER_1_USERNAME)
     self.user_1_id = self.get_user_id_from_email(self.USER_1_EMAIL)
     user_models.CompletedActivitiesModel(id=self.user_1_id,
                                          exploration_ids=[],
                                          collection_ids=[]).put()
     user_models.IncompleteActivitiesModel(id=self.user_1_id,
                                           exploration_ids=[],
                                           collection_ids=[]).put()
     user_models.LearnerPlaylistModel(id=self.user_1_id,
                                      exploration_ids=[],
                                      collection_ids=[]).put()
     wipeout_service.pre_delete_user(self.user_1_id)
    def test_delete_user_simple(self):
        wipeout_service.pre_delete_user(self.user_1_id)

        self.assertIsNotNone(
            user_models.UserSettingsModel.get_by_id(self.user_1_id))
        self.assertIsNotNone(
            user_models.UserEmailPreferencesModel.get_by_id(self.user_1_id))

        wipeout_service.delete_user(
            wipeout_service.get_pending_deletion_request(self.user_1_id))

        self.assertIsNone(
            user_models.UserSettingsModel.get_by_id(self.user_1_id))
        self.assertIsNone(
            user_models.UserEmailPreferencesModel.get_by_id(self.user_1_id))
Exemple #13
0
    def delete(self):
        user_id = self.normalized_request.get('user_id')
        username = self.normalized_request.get('username')

        user_id_from_username = (
            user_services.get_user_id_from_username(username))
        if user_id_from_username is None:
            raise self.InvalidInputException(
                'The username doesn\'t belong to any user')
        if user_id_from_username != user_id:
            raise self.InvalidInputException(
                'The user ID retrieved from the username and '
                'the user ID provided by admin differ.')
        wipeout_service.pre_delete_user(user_id)
        self.render_json({'success': True})
 def setUp(self):
     super(UserDeletionOneOffJobTests, self).setUp()
     self.signup(self.USER_1_EMAIL, self.USER_1_USERNAME)
     self.user_1_id = self.get_user_id_from_email(self.USER_1_EMAIL)
     user_models.CompletedActivitiesModel(
         id=self.user_1_id, exploration_ids=[], collection_ids=[],
         story_ids=[], learnt_topic_ids=[]
     ).put()
     user_models.IncompleteActivitiesModel(
         id=self.user_1_id, exploration_ids=[], collection_ids=[],
         story_ids=[], partially_learnt_topic_ids=[]
     ).put()
     user_models.LearnerPlaylistModel(
         id=self.user_1_id, exploration_ids=[], collection_ids=[]
     ).put()
     wipeout_service.pre_delete_user(self.user_1_id)
     self.process_and_flush_pending_mapreduce_tasks()
Exemple #15
0
    def test_pre_delete_user_without_activities(self):
        user_models.UserSubscriptionsModel(id=self.user_1_id,
                                           activity_ids=[],
                                           collection_ids=[]).put()

        user_settings = user_services.get_user_settings(self.user_1_id)
        self.assertFalse(user_settings.to_be_deleted)

        wipeout_service.pre_delete_user(self.user_1_id)

        user_settings = user_services.get_user_settings(self.user_1_id)
        self.assertTrue(user_settings.to_be_deleted)

        pending_deletion_model = (
            user_models.PendingDeletionRequestModel.get_by_id(self.user_1_id))
        self.assertEqual(pending_deletion_model.exploration_ids, [])
        self.assertEqual(pending_deletion_model.collection_ids, [])
Exemple #16
0
    def test_pre_delete_user_email_subscriptions(self):
        email_preferences = user_services.get_email_preferences(self.user_1_id)
        self.assertEqual(email_preferences.can_receive_email_updates,
                         feconf.DEFAULT_EMAIL_UPDATES_PREFERENCE)
        self.assertEqual(email_preferences.can_receive_editor_role_email,
                         feconf.DEFAULT_EDITOR_ROLE_EMAIL_PREFERENCE)
        self.assertEqual(email_preferences.can_receive_feedback_message_email,
                         feconf.DEFAULT_FEEDBACK_MESSAGE_EMAIL_PREFERENCE)
        self.assertEqual(email_preferences.can_receive_subscription_email,
                         feconf.DEFAULT_SUBSCRIPTION_EMAIL_PREFERENCE)

        wipeout_service.pre_delete_user(self.user_1_id)

        email_preferences = user_services.get_email_preferences(self.user_1_id)
        self.assertFalse(email_preferences.can_receive_email_updates)
        self.assertFalse(email_preferences.can_receive_editor_role_email)
        self.assertFalse(email_preferences.can_receive_feedback_message_email)
        self.assertFalse(email_preferences.can_receive_subscription_email)
    def test_pre_delete_user_with_activities_multiple_owners(self):
        user_services.update_user_role(
            self.user_1_id, feconf.ROLE_ID_COLLECTION_EDITOR)
        user_1_actions = user_services.UserActionsInfo(self.user_1_id)
        self.save_new_valid_exploration('exp_id', self.user_1_id)
        rights_manager.assign_role_for_exploration(
            user_1_actions, 'exp_id', self.user_2_id, rights_manager.ROLE_OWNER)
        self.save_new_valid_collection(
            'col_id', self.user_1_id, exploration_id='exp_id')
        rights_manager.assign_role_for_collection(
            user_1_actions, 'col_id', self.user_2_id, rights_manager.ROLE_OWNER)

        wipeout_service.pre_delete_user(self.user_1_id)

        pending_deletion_model = (
            user_models.PendingDeletionRequestModel.get_by_id(self.user_1_id))
        self.assertEqual(
            pending_deletion_model.exploration_ids, [])
        self.assertEqual(pending_deletion_model.collection_ids, [])
Exemple #18
0
 def delete(self):
     """Handles DELETE requests."""
     wipeout_service.pre_delete_user(self.user_id)
     self.render_json({'success': True})