Exemplo n.º 1
0
    def map(user):
        # The map() function must be static, so we manually create a "cls"
        # variable instead of changing the function into a classmethod.
        cls = PopulateFirebaseAccountsOneOffJob

        if user.deleted:
            return

        gae_auth_id = gae_auth_services.get_auth_id_from_user_id(user.id)
        # NOTE: This committer ID is a legacy ACL-bypass that we no longer
        # depend on. Because it is obsolete, we do not want it to have a
        # Firebase account associated with it.
        if gae_auth_id == feconf.SYSTEM_COMMITTER_ID:
            yield (cls.SYSTEM_COMMITTER_ACK, user.id)
            return

        auth_id = firebase_auth_services.get_auth_id_from_user_id(user.id)
        if auth_id is not None:
            yield (cls.POPULATED_KEY, 1)
        else:
            user_is_super_admin = (user.email == feconf.ADMIN_EMAIL_ADDRESS)
            if user_is_super_admin:
                yield (cls.SUPER_ADMIN_ACK, user.id)

            # Split up users into different shards to help speed up the job.
            sharding_key = ID_HASHING_FUNCTION(user.id) % cls.NUM_SHARDS
            yield (sharding_key, (cls.strip_uid_prefix(user.id), user.id,
                                  user.email, user_is_super_admin))
Exemplo n.º 2
0
    def test_get_association_that_is_present(self):
        gae_auth_services.associate_auth_id_with_user_id(
            auth_domain.AuthIdUserIdPair('aid', 'uid'))

        self.assertEqual(gae_auth_services.get_user_id_from_auth_id('aid'),
                         'uid')
        self.assertEqual(gae_auth_services.get_auth_id_from_user_id('uid'),
                         'aid')
Exemplo n.º 3
0
    def test_associate_without_collision(self):
        gae_auth_services.associate_auth_id_with_user_id(
            auth_domain.AuthIdUserIdPair('aid', 'uid'))

        self.assertEqual(gae_auth_services.get_user_id_from_auth_id('aid'),
                         'uid')
        self.assertEqual(gae_auth_services.get_auth_id_from_user_id('uid'),
                         'aid')
Exemplo n.º 4
0
    def assert_gae_assoc_does_not_exist(self, gae_id, user_id):
        """Asserts that the given user's GAE association doesn't exist.

        Args:
            user_id: str. The Oppia ID of the user.
            gae_id: str. The GAE ID of the user.
        """
        self.assertIsNone(gae_auth_services.get_auth_id_from_user_id(user_id))
        self.assertIsNone(gae_auth_services.get_user_id_from_auth_id(gae_id))
Exemplo n.º 5
0
    def assert_gae_assoc_exists(self, gae_id, user_id):
        """Asserts that the given user's GAE association exists.

        Args:
            user_id: str. The Oppia ID of the user.
            gae_id: str. The GAE ID of the user.
        """
        self.assertEqual(gae_auth_services.get_auth_id_from_user_id(user_id),
                         gae_id)
        self.assertEqual(gae_auth_services.get_user_id_from_auth_id(gae_id),
                         user_id)
Exemplo n.º 6
0
    def map(user):
        gae_auth_id = gae_auth_services.get_auth_id_from_user_id(user.id)
        # NOTE: This committer ID is a legacy ACL-bypass that we no longer
        # depend on. Because it is obsolete, we do not want it to have a
        # Firebase account associated with it, or even consider it for import.
        if gae_auth_id == feconf.SYSTEM_COMMITTER_ID:
            yield (SYSTEM_COMMITTER_ACK, user.id)
            return

        if user.deleted:
            yield ('[DELETED]', user.id)
        else:
            yield (user.email, user.id)
Exemplo n.º 7
0
    def map(user):
        # The map() function must be static, so we manually create a "cls"
        # variable instead of changing the function into a classmethod.
        cls = AuditFirebaseImportReadinessOneOffJob

        gae_auth_id = gae_auth_services.get_auth_id_from_user_id(user.id)
        # NOTE: This committer ID is a legacy ACL-bypass that we no longer
        # depend on. Because it is obsolete, we do not want it to have a
        # Firebase account associated with it, or even consider it for import.
        if gae_auth_id == feconf.SYSTEM_COMMITTER_ID:
            yield (cls.SYSTEM_COMMITTER_ACK, user.id)
        else:
            yield ('[DELETED]' if user.deleted else user.email, user.id)
Exemplo n.º 8
0
    def test_get_association_that_is_present_and_marked_as_deleted(self):
        gae_auth_services.associate_auth_id_with_user_id(
            auth_domain.AuthIdUserIdPair('aid', 'uid'))

        assoc_by_auth_id_model = auth_models.UserIdentifiersModel.get('aid')
        assoc_by_auth_id_model.deleted = True
        assoc_by_auth_id_model.update_timestamps()
        assoc_by_auth_id_model.put()

        self.assertEqual(gae_auth_services.get_user_id_from_auth_id('aid'),
                         'uid')
        self.assertEqual(gae_auth_services.get_auth_id_from_user_id('uid'),
                         'aid')
Exemplo n.º 9
0
    def map(user):
        if user.deleted:
            return

        gae_auth_id = gae_auth_services.get_auth_id_from_user_id(user.id)
        # NOTE: This committer ID is a legacy ACL-bypass that we no longer
        # depend on. Because it is obsolete, we do not want it to have a
        # Firebase account associated with it.
        if gae_auth_id == feconf.SYSTEM_COMMITTER_ID:
            yield (SYSTEM_COMMITTER_ACK, user.id)
            return

        auth_id = firebase_auth_services.get_auth_id_from_user_id(user.id)
        if auth_id is not None:
            yield (POPULATED_KEY, 1)
        else:
            # Split up users into different shards to help speed up the job.
            sharding_key = (ID_HASHING_FUNCTION(user.id) %
                            PopulateFirebaseAccountsOneOffJob.NUM_SHARDS)
            yield (sharding_key, (_strip_uid_prefix(user.id), user.id,
                                  user.email))
Exemplo n.º 10
0
 def test_get_association_that_is_missing(self):
     self.assertIsNone(
         gae_auth_services.get_user_id_from_auth_id('does_not_exist'))
     self.assertIsNone(
         gae_auth_services.get_auth_id_from_user_id('does_not_exist'))