Skip to content

Commit 773b46b

Browse files
committed
issue2550755: exceptions.NotFound(msg) msg is not reported to user in cgi fix tests
Correct tests so they now expect NotFound exception rather than SeriousError. Renamed: test/test_cgi.py::FormTestCase::testCSVExportFailPermission to test/test_cgi.py::FormTestCase::testCSVExportFailPermissionBadColumn I think this test should return Unauthorised rather than NotFound. Discussion is on the issue. Also added a new test case to verify that exceptions.Unauthorised is raised if all columns are valid and the user is not allowed to access the class.
1 parent fa67b6f commit 773b46b

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

test/test_cgi.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,10 +1151,10 @@ def testCSVExportBadColumnName(self):
11511151
output = StringIO.StringIO()
11521152
cl.request = MockNull()
11531153
cl.request.wfile = output
1154-
self.assertRaises(exceptions.SeriousError,
1154+
self.assertRaises(exceptions.NotFound,
11551155
actions.ExportCSVAction(cl).handle)
11561156

1157-
def testCSVExportFailPermission(self):
1157+
def testCSVExportFailPermissionBadColumn(self):
11581158
cl = self._make_client({'@columns': 'id,email,password'}, nodeid=None,
11591159
userid='2')
11601160
cl.classname = 'user'
@@ -1163,7 +1163,22 @@ def testCSVExportFailPermission(self):
11631163
cl.request.wfile = output
11641164
# used to be self.assertRaises(exceptions.Unauthorised,
11651165
# but not acting like the column name is not found
1166-
self.assertRaises(exceptions.SeriousError,
1166+
# see issue2550755 - should this return Unauthorised?
1167+
# The unauthorised user should never get to the point where
1168+
# they can determine if the column name is valid or not.
1169+
self.assertRaises(exceptions.NotFound,
1170+
actions.ExportCSVAction(cl).handle)
1171+
1172+
def testCSVExportFailPermissionValidColumn(self):
1173+
cl = self._make_client({'@columns': 'id,address,password'}, nodeid=None,
1174+
userid='2')
1175+
cl.classname = 'user'
1176+
output = StringIO.StringIO()
1177+
cl.request = MockNull()
1178+
cl.request.wfile = output
1179+
# used to be self.assertRaises(exceptions.Unauthorised,
1180+
# but not acting like the column name is not found
1181+
self.assertRaises(exceptions.Unauthorised,
11671182
actions.ExportCSVAction(cl).handle)
11681183

11691184
class TemplateHtmlRendering(unittest.TestCase):

0 commit comments

Comments
 (0)