Ejemplo n.º 1
0
Archivo: api.py Proyecto: ed-/reddwarf
    def _check_injected_file_quota(self, context, injected_files):
        """Enforce quota limits on injected files.

        Raises a QuotaError if any limit is exceeded.

        """
        if injected_files is None:
            return
        limit = quota.allowed_injected_files(context, len(injected_files))
        if len(injected_files) > limit:
            raise quota.QuotaError(code="OnsetFileLimitExceeded")
        path_limit = quota.allowed_injected_file_path_bytes(context)
        for path, content in injected_files:
            if len(path) > path_limit:
                raise quota.QuotaError(code="OnsetFilePathLimitExceeded")
            content_limit = quota.allowed_injected_file_content_bytes(context, len(content))
            if len(content) > content_limit:
                raise quota.QuotaError(code="OnsetFileContentLimitExceeded")
Ejemplo n.º 2
0
    def _check_injected_file_quota(self, context, injected_files):
        """Enforce quota limits on injected files.

        Raises a QuotaError if any limit is exceeded.

        """
        if injected_files is None:
            return
        limit = quota.allowed_injected_files(context)
        if len(injected_files) > limit:
            raise quota.QuotaError(code="OnsetFileLimitExceeded")
        path_limit = quota.allowed_injected_file_path_bytes(context)
        content_limit = quota.allowed_injected_file_content_bytes(context)
        for path, content in injected_files:
            if len(path) > path_limit:
                raise quota.QuotaError(code="OnsetFilePathLimitExceeded")
            if len(content) > content_limit:
                raise quota.QuotaError(code="OnsetFileContentLimitExceeded")
Ejemplo n.º 3
0
 def test_unlimited_db_allowed_injected_files(self):
     self.flags(quota_max_injected_files=5)
     db.quota_create(self.context, self.project_id, "injected_files", None)
     self.assertEqual(quota.allowed_injected_files(self.context, 100), 100)
Ejemplo n.º 4
0
 def test_unlimited_default_allowed_injected_files(self):
     self.flags(quota_max_injected_files=-1)
     self.assertEqual(quota.allowed_injected_files(self.context, 100), 100)
Ejemplo n.º 5
0
 def test_overridden_allowed_injected_files(self):
     self.flags(quota_max_injected_files=5)
     db.quota_create(self.context, self.project_id, "injected_files", 77)
     self.assertEqual(quota.allowed_injected_files(self.context, 100), 77)
Ejemplo n.º 6
0
 def test_unlimited_db_allowed_injected_files(self):
     FLAGS.quota_max_injected_files = 5
     db.quota_create(self.context, self.project_id, 'injected_files', None)
     self.assertEqual(quota.allowed_injected_files(self.context, 100), 100)
Ejemplo n.º 7
0
 def test_overridden_allowed_injected_files(self):
     FLAGS.quota_max_injected_files = 5
     db.quota_create(self.context, self.project_id, 'injected_files', 77)
     self.assertEqual(quota.allowed_injected_files(self.context, 100), 77)
Ejemplo n.º 8
0
 def test_default_allowed_injected_files(self):
     FLAGS.quota_max_injected_files = 55
     self.assertEqual(quota.allowed_injected_files(self.context, 100), 55)
Ejemplo n.º 9
0
 def test_default_allowed_injected_files(self):
     self.flags(quota_injected_files=55)
     self.assertEqual(quota.allowed_injected_files(self.context, 100), 55)
Ejemplo n.º 10
0
 def test_allowed_injected_files(self):
     self.assertEqual(quota.allowed_injected_files(self.context),
                      FLAGS.quota_max_injected_files)
Ejemplo n.º 11
0
 def test_unlimited_db_allowed_injected_files(self):
     self.flags(quota_max_injected_files=5)
     db.quota_create(self.context, self.project_id, 'injected_files', None)
     self.assertEqual(quota.allowed_injected_files(self.context, 100), 100)
Ejemplo n.º 12
0
 def test_unlimited_default_allowed_injected_files(self):
     self.flags(quota_max_injected_files=-1)
     self.assertEqual(quota.allowed_injected_files(self.context, 100), 100)
Ejemplo n.º 13
0
 def test_overridden_allowed_injected_files(self):
     self.flags(quota_max_injected_files=5)
     db.quota_create(self.context, self.project_id, 'injected_files', 77)
     self.assertEqual(quota.allowed_injected_files(self.context, 100), 77)
Ejemplo n.º 14
0
 def test_allowed_injected_files(self):
     self.assertEqual(quota.allowed_injected_files(self.context), FLAGS.quota_max_injected_files)
Ejemplo n.º 15
0
 def test_default_allowed_injected_files(self):
     FLAGS.quota_max_injected_files = 55
     self.assertEqual(quota.allowed_injected_files(self.context, 100), 55)
Ejemplo n.º 16
0
 def test_default_allowed_injected_files(self):
     self.flags(quota_injected_files=55)
     self.assertEqual(quota.allowed_injected_files(self.context, 100), 55)