diff --git a/glare/objects/meta/file_utils.py b/glare/objects/meta/file_utils.py index a60dfce..a2015da 100644 --- a/glare/objects/meta/file_utils.py +++ b/glare/objects/meta/file_utils.py @@ -83,6 +83,7 @@ def unpack_zip_archive_to_artifact_folder(context, af, zip_ref, folder_name): file_dict[name] = blob blobs.append((blob_id, utils.BlobIterator(zip_ref.read(name)))) + setattr(af, folder_name, file_dict) af = af.update_blob(context, af.id, folder_name, file_dict) default_store = getattr( diff --git a/glare/tests/unit/test_unpacking.py b/glare/tests/unit/test_unpacking.py index c15b5c1..41b35aa 100644 --- a/glare/tests/unit/test_unpacking.py +++ b/glare/tests/unit/test_unpacking.py @@ -15,6 +15,7 @@ import os from time import time +from glare.common.exception import BadRequest from glare.tests.unit import base @@ -65,7 +66,7 @@ class TestArtifactHooks(base.BaseTestArtifactAPI): artifact = self.controller.show(self.req, 'unpacking_artifact', self.unpacking_artifact['id']) - self.assertEqual(15702, artifact['zip']['size']) + self.assertEqual(100, len(artifact['content'])) self.assertEqual('active', artifact['zip']['status']) self.assertEqual(100, len(artifact['content'])) @@ -74,6 +75,19 @@ class TestArtifactHooks(base.BaseTestArtifactAPI): self.assertEqual('active', blob['status']) self.assertEqual(15, blob['size']) + def test_unpacking_more_than_max_size_archive(self): + var_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), + '../', 'var')) + data_path = os.path.join(var_dir, 'hooks_265.zip') + with open(data_path, "rb") as data: + self.assertRaises(BadRequest, self.controller.upload_blob, + self.req, 'unpacking_artifact', + self.unpacking_artifact['id'], 'zip', + data, 'application/octet-stream') + artifact = self.controller.show(self.req, 'unpacking_artifact', + self.unpacking_artifact['id']) + self.assertEqual(0, len(artifact['content'])) + def test_unpacking_database_big_archive(self): self.config(default_store='database', group='artifact_type:unpacking_artifact') diff --git a/glare/tests/var/hooks_265.zip b/glare/tests/var/hooks_265.zip new file mode 100644 index 0000000..e69de29