Skip to content

Commit 331293c

Browse files
Merge pull request #3155 from antgonza/fix-3150
fix #3150
2 parents 7e8df20 + 7fdf51f commit 331293c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

qiita_pet/handlers/artifact_handlers/base_handlers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ def patch(self, artifact_id):
457457

458458

459459
class ArtifactSummaryHandler(StaticFileHandler, BaseHandler):
460+
@authenticated
460461
def validate_absolute_path(self, root, absolute_path):
461462
"""Overrides StaticFileHandler's method to include authentication"""
462463
user = self.current_user

qiita_pet/handlers/artifact_handlers/tests/test_base_handlers.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from os import close, remove
1212
from os.path import basename, exists, relpath
1313
from json import loads
14+
from mock import Mock
1415

1516
from tornado.web import HTTPError
1617

@@ -23,6 +24,7 @@
2324
from qiita_db.software import Parameters, Command
2425
from qiita_pet.exceptions import QiitaHTTPError
2526
from qiita_pet.test.tornado_test_base import TestHandlerBase
27+
from qiita_pet.handlers.base_handlers import BaseHandler
2628
from qiita_pet.handlers.artifact_handlers.base_handlers import (
2729
check_artifact_access, artifact_summary_get_request,
2830
artifact_summary_post_request, artifact_patch_request,
@@ -430,6 +432,14 @@ def test_get_artifact_summary_handler(self):
430432
self.assertEqual(response.body.decode('ascii'),
431433
'<b>HTML TEST - not important</b>\n')
432434

435+
# testing with a not log user should return the login page
436+
BaseHandler.get_current_user = Mock(return_value=None)
437+
response = self.get('/artifact/html_summary/%s' % summary)
438+
self.assertEqual(response.code, 200)
439+
exp = ('<button tabindex="3" type="submit" class="btn btn-success">'
440+
'Sign in</button>')
441+
self.assertIn(exp, response.body.decode())
442+
433443

434444
if __name__ == '__main__':
435445
main()

0 commit comments

Comments
 (0)