11502: Instead of asking for a stripped manifest, replace the tokens with some consta...
authorLucas Di Pentima <lucas@curoverse.com>
Wed, 19 Apr 2017 19:28:26 +0000 (16:28 -0300)
committerLucas Di Pentima <lucas@curoverse.com>
Wed, 19 Apr 2017 19:28:26 +0000 (16:28 -0300)
sdk/python/arvados/commands/get.py
sdk/python/tests/test_arv_get.py

index e54fd87a193607c9da303d734ecd714c7de34a52..3bf929584ea4e22968b0e29a07044c7e1e95a744 100755 (executable)
@@ -87,7 +87,7 @@ skipped.
 """)
 group.add_argument('--strip-manifest', action='store_true', default=False,
                    help="""
-When getting a collection manifest, strip its access tokens before writing 
+When getting a collection manifest, strip its access tokens before writing
 it.
 """)
 
index 8be528fe6ebbb8f36579c2d6d6866895c55a4195..b7f5e2b9c6d7923f39d485cbd96f9f1c6228ac82 100644 (file)
@@ -3,6 +3,7 @@
 
 import io
 import os
+import re
 import shutil
 import tempfile
 
@@ -78,20 +79,21 @@ class ArvadosGetTestCase(run_test_server.TestCaseWithServers):
             self.assertEqual("baz", f.read())
 
     def test_get_collection_unstripped_manifest(self):
+        dummy_token = "+Axxxxxxx"
         # Get the collection manifest by UUID
         r = self.run_get([self.col_loc, self.tempdir])
         self.assertEqual(0, r)
-        m_from_collection = collection.Collection(self.col_manifest).manifest_text(strip=True)
+        m_from_collection = re.sub(r"\+A[0-9a-f@]+", dummy_token, self.col_manifest)
         with open(os.path.join(self.tempdir, self.col_loc), "r") as f:
-            # Strip manifest before comparison to avoid races
-            m_from_file = collection.Collection(f.read()).manifest_text(strip=True)
+            # Replace manifest tokens before comparison to avoid races
+            m_from_file = re.sub(r"\+A[0-9a-f@]+", dummy_token, f.read())
             self.assertEqual(m_from_collection, m_from_file)
         # Get the collection manifest by PDH
         r = self.run_get([self.col_pdh, self.tempdir])
         self.assertEqual(0, r)
         with open(os.path.join(self.tempdir, self.col_pdh), "r") as f:
-            # Strip manifest before comparison to avoid races
-            m_from_file = collection.Collection(f.read()).manifest_text(strip=True)
+            # Replace manifest tokens before comparison to avoid races
+            m_from_file = re.sub(r"\+A[0-9a-f@]+", dummy_token, f.read())
             self.assertEqual(m_from_collection, m_from_file)
 
     def test_get_collection_stripped_manifest(self):