Skip to content

fix #3068 #3069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions qiita_db/meta_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ def validate_filepath_access_by_user(user, filepath_id):
# [0] cause we should only have 1
aid = anid[0]
analysis = qdb.analysis.Analysis(aid)
return analysis in (
user.private_analyses | user.shared_analyses)
return analysis.is_public | (analysis in (
user.private_analyses | user.shared_analyses))
return False


Expand Down
16 changes: 16 additions & 0 deletions qiita_db/test/test_meta_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def test_validate_filepath_access_by_user(self):
self.assertFalse(qdb.meta_util.validate_filepath_access_by_user(
user, i))

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

# Now the Analysis is public so the user should have access again. Note
# that we are not using the internal Analysis methods to skip
# validation; thus simplifying the test code
for a in qdb.analysis.Analysis(1).artifacts:
a.visibility = 'public'
# Note that 15 is the biom from the analysis and 16 is the
# analysis mapping file and here we are testing access
for i in [15, 16]:
self.assertTrue(qdb.meta_util.validate_filepath_access_by_user(
user, i))
# returning to private
for a in qdb.analysis.Analysis(1).artifacts:
a.visibility = 'private'

# Now shared has access to public study files
self._set_artifact_public()
for i in [1, 2, 3, 4, 5, 9, 12, 17, 18, 19, 20, 21]:
Expand Down