16039: Fix & add test for sanitized/unsanitized name conflict.
authorTom Clegg <tom@tomclegg.ca>
Wed, 12 Feb 2020 15:48:05 +0000 (10:48 -0500)
committerTom Clegg <tom@tomclegg.ca>
Wed, 12 Feb 2020 15:48:05 +0000 (10:48 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@tomclegg.ca>

services/fuse/arvados_fuse/fusedir.py
services/fuse/tests/test_mount.py

index 3f6430973d07e282eb025ea63c5b51b0ac954e91..8b12f73e895a8d59e3f95461218ab7cf14589887 100644 (file)
@@ -941,7 +941,7 @@ class ProjectDirectory(Directory):
                                                                 namefilter],
                                                        limit=2).execute(num_retries=self.num_retries)["items"]
         if contents:
-            if len(contents) > 1 and contents[1].name == k:
+            if len(contents) > 1 and contents[1]['name'] == k:
                 # If "foo/bar" and "foo[SUBST]bar" both exist, use
                 # "foo[SUBST]bar".
                 contents = [contents[1]]
index 1e63b9f4da89f97a16955beac65e5ec9083dd6eb..593d945cff0be54e46cb360712efd20b28e1658d 100644 (file)
@@ -1239,3 +1239,17 @@ class SlashSubstitutionTest(IntegrationTest):
     def checkContents(self):
         self.assertRegexpMatches(self.api.collections().get(uuid=self.testcoll['uuid']).execute()['manifest_text'], ' acbd18db') # md5(foo)
         self.assertRegexpMatches(self.api.collections().get(uuid=self.testcolleasy['uuid']).execute()['manifest_text'], ' f561aaf6') # md5(xxx)
+
+    @IntegrationTest.mount(argv=mnt_args)
+    @mock.patch('arvados.util.get_config_once')
+    def test_slash_substitution_conflict(self, get_config_once):
+        self.testcollconflict = self.api.collections().create(body={"name": self.fusename}).execute()
+        get_config_once.return_value = {"Collections": {"ForwardSlashNameSubstitution": "[SLASH]"}}
+        self.pool_test(os.path.join(self.mnt, 'zzz'), self.fusename)
+        self.assertRegexpMatches(self.api.collections().get(uuid=self.testcollconflict['uuid']).execute()['manifest_text'], ' acbd18db') # md5(foo)
+        # foo/bar/baz collection unchanged, because it is masked by foo[SLASH]bar[SLASH]baz
+        self.assertEqual(self.api.collections().get(uuid=self.testcoll['uuid']).execute()['manifest_text'], '')
+    @staticmethod
+    def _test_slash_substitution_conflict(self, tmpdir, fusename):
+        with open(os.path.join(tmpdir, fusename, 'waz'), 'w') as f:
+            f.write('foo')