Skip to content

Commit 94e01ca

Browse files
authored
fix #3068 (#3069)
1 parent 1b82fd6 commit 94e01ca

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

qiita_db/meta_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ def validate_filepath_access_by_user(user, filepath_id):
160160
# [0] cause we should only have 1
161161
aid = anid[0]
162162
analysis = qdb.analysis.Analysis(aid)
163-
return analysis in (
164-
user.private_analyses | user.shared_analyses)
163+
return analysis.is_public | (analysis in (
164+
user.private_analyses | user.shared_analyses))
165165
return False
166166

167167

qiita_db/test/test_meta_util.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ def test_validate_filepath_access_by_user(self):
5757
self.assertFalse(qdb.meta_util.validate_filepath_access_by_user(
5858
user, i))
5959

60+
# Note that 15 is the biom from the analysis and 16 is the
61+
# analysis mapping file and here we are testing access
6062
for i in [15, 16]:
6163
self.assertTrue(qdb.meta_util.validate_filepath_access_by_user(
6264
user, i))
@@ -67,6 +69,20 @@ def test_validate_filepath_access_by_user(self):
6769
self.assertFalse(qdb.meta_util.validate_filepath_access_by_user(
6870
user, i))
6971

72+
# Now the Analysis is public so the user should have access again. Note
73+
# that we are not using the internal Analysis methods to skip
74+
# validation; thus simplifying the test code
75+
for a in qdb.analysis.Analysis(1).artifacts:
76+
a.visibility = 'public'
77+
# Note that 15 is the biom from the analysis and 16 is the
78+
# analysis mapping file and here we are testing access
79+
for i in [15, 16]:
80+
self.assertTrue(qdb.meta_util.validate_filepath_access_by_user(
81+
user, i))
82+
# returning to private
83+
for a in qdb.analysis.Analysis(1).artifacts:
84+
a.visibility = 'private'
85+
7086
# Now shared has access to public study files
7187
self._set_artifact_public()
7288
for i in [1, 2, 3, 4, 5, 9, 12, 17, 18, 19, 20, 21]:

0 commit comments

Comments
 (0)