Show More
@@ -5,6 +5,7 b' from __future__ import print_function' | |||||
5 | import os |
|
5 | import os | |
6 | import time |
|
6 | import time | |
7 |
|
7 | |||
|
8 | from nose import SkipTest | |||
8 | from tornado.web import HTTPError |
|
9 | from tornado.web import HTTPError | |
9 | from unittest import TestCase |
|
10 | from unittest import TestCase | |
10 | from tempfile import NamedTemporaryFile |
|
11 | from tempfile import NamedTemporaryFile | |
@@ -129,6 +130,25 b' class TestFileContentsManager(TestCase):' | |||||
129 | [symlink_model, file_model], |
|
130 | [symlink_model, file_model], | |
130 | ) |
|
131 | ) | |
131 |
|
132 | |||
|
133 | def test_403(self): | |||
|
134 | if hasattr(os, 'getuid'): | |||
|
135 | if os.getuid() == 0: | |||
|
136 | raise SkipTest("Can't test permissions as root") | |||
|
137 | ||||
|
138 | with TemporaryDirectory() as td: | |||
|
139 | cm = FileContentsManager(root_dir=td) | |||
|
140 | model = cm.new_untitled(type='file') | |||
|
141 | os_path = cm._get_os_path(model['path']) | |||
|
142 | ||||
|
143 | os.chmod(os_path, 0o400) | |||
|
144 | try: | |||
|
145 | with cm.open(os_path, 'w') as f: | |||
|
146 | f.write(u"don't care") | |||
|
147 | except HTTPError as e: | |||
|
148 | self.assertEqual(e.status_code, 403) | |||
|
149 | else: | |||
|
150 | self.fail("Should have raised HTTPError(403)") | |||
|
151 | ||||
132 |
|
152 | |||
133 | class TestContentsManager(TestCase): |
|
153 | class TestContentsManager(TestCase): | |
134 |
|
154 |
General Comments 0
You need to be logged in to leave comments.
Login now