comparison test/test_cgi.py @ 5159:7fb697267fdb

adding test case for home templates in various incantations. Also added comment about possibly creating/raising PageTraversal exception. I don't think we need it since @@file doesn't do it but...
author John Rouillard <rouilj@ieee.org>
date Fri, 22 Jul 2016 19:39:24 -0400
parents f608eeecf638
children f8a32b7331f1
comparison
equal deleted inserted replaced
5158:63294ed25e84 5159:7fb697267fdb
1137 # make sure a simple non-subdir template works. 1137 # make sure a simple non-subdir template works.
1138 # user.item.html exists so this works. 1138 # user.item.html exists so this works.
1139 # note that the extension is not included just the basename 1139 # note that the extension is not included just the basename
1140 self.assertEqual("user.item", t.selectTemplate("user", "item")) 1140 self.assertEqual("user.item", t.selectTemplate("user", "item"))
1141 1141
1142
1143 # make sure home templates work
1144 self.assertEqual("home", t.selectTemplate(None, ""))
1145 self.assertEqual("home.classlist", t.selectTemplate(None, "classlist"))
1146
1147 # home.item doesn't exist should return _generic.item.
1148 self.assertEqual("_generic.item", t.selectTemplate(None, "item"))
1149
1150 # test case where there is no view so generic template can't
1151 # be determined.
1152 with self.assertRaises(NoTemplate) as cm:
1153 t.selectTemplate("user", "")
1154 self.assertEqual(cm.exception.message,
1155 '''Template "user" doesn't exist''')
1156
1142 # there is no html/subdir/user.item.{,xml,html} so it will 1157 # there is no html/subdir/user.item.{,xml,html} so it will
1143 # raise NoTemplate. 1158 # raise NoTemplate.
1144 self.assertRaises(NoTemplate, 1159 self.assertRaises(NoTemplate,
1145 t.selectTemplate, "user", "subdir/item") 1160 t.selectTemplate, "user", "subdir/item")
1146 1161
1149 self.assertEqual("subdir/issue.item", r) 1164 self.assertEqual("subdir/issue.item", r)
1150 1165
1151 # there is a self.directory + /html/subdir/user.item.html file, 1166 # there is a self.directory + /html/subdir/user.item.html file,
1152 # but it is a link to self.dir /user.item.html which is outside 1167 # but it is a link to self.dir /user.item.html which is outside
1153 # the html subdir so is rejected by the path traversal check. 1168 # the html subdir so is rejected by the path traversal check.
1169 # Prefer NoTemplate here, or should the code be changed to
1170 # report a new PathTraversal exception? Could the PathTraversal
1171 # exception leak useful info to an attacker??
1154 self.assertRaises(NoTemplate, 1172 self.assertRaises(NoTemplate,
1155 t.selectTemplate, "user", "subdir/item") 1173 t.selectTemplate, "user", "subdir/item")
1156 1174
1157 # clear out the link and create a new one to self.dirname + 1175 # clear out the link and create a new one to self.dirname +
1158 # html/user.item.html which is inside the html subdir 1176 # html/user.item.html which is inside the html subdir

Roundup Issue Tracker: http://roundup-tracker.org/