lordgamez commented on code in PR #2059:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2059#discussion_r2533908747


##########
behave_framework/src/minifi_test_framework/containers/container.py:
##########
@@ -254,6 +285,59 @@ def verify_file_contents(self, directory_path: str, 
expected_contents: list[str]
 
         return sorted(actual_file_contents) == sorted(expected_contents)
 
+    def _verify_file_contents_in_stopped_container(self, directory_path: str, 
expected_contents: list[str]) -> bool:
+        if not self.container:
+            return False
+
+        with tempfile.TemporaryDirectory() as temp_dir:
+            extracted_dir = 
self._extract_directory_from_container(directory_path, temp_dir)
+            if not extracted_dir:
+                return False
+
+            actual_file_contents = 
self._read_files_from_directory(extracted_dir)
+            if actual_file_contents is None:
+                return False
+
+            return sorted(actual_file_contents) == sorted(expected_contents)
+
+    def _extract_directory_from_container(self, directory_path: str, temp_dir: 
str) -> str | None:
+        try:
+            bits, _ = self.container.get_archive(directory_path)
+            temp_tar_path = os.path.join(temp_dir, "archive.tar")
+
+            with open(temp_tar_path, 'wb') as f:
+                for chunk in bits:
+                    f.write(chunk)
+
+            with tarfile.open(temp_tar_path) as tar:
+                tar.extractall(path=temp_dir)
+

Review Comment:
   We only use it for containers that are validated by us, so this should not 
be a problem, `tarfile.data_filter` will not work for use as we need to support 
the minimum python version 3.10.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to