Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: appengine/monorail/framework/test/banned_test.py

Issue 1868553004: Open Source Monorail (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/monorail/framework/test/banned_test.py
diff --git a/appengine/monorail/framework/test/banned_test.py b/appengine/monorail/framework/test/banned_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..45f2ad331580df8578df6b057c472a690e468c97
--- /dev/null
+++ b/appengine/monorail/framework/test/banned_test.py
@@ -0,0 +1,55 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is govered by a BSD-style
+# license that can be found in the LICENSE file or at
+# https://developers.google.com/open-source/licenses/bsd
+
+"""Unittests for monorail.framework.banned."""
+
+import unittest
+
+import webapp2
+
+from framework import banned
+from framework import monorailrequest
+from services import service_manager
+from testing import testing_helpers
+
+
+class BannedTest(unittest.TestCase):
+
+ def testAssertBasePermission(self):
+ servlet = banned.Banned(
+ 'request', 'response', services=service_manager.Services())
+
+ mr = monorailrequest.MonorailRequest()
+ mr.auth.user_id = 0L # Anon user cannot see banned page.
+ try:
+ servlet.AssertBasePermission(mr)
+ self.fail()
+ except webapp2.HTTPException as e:
+ self.assertEquals(404, e.code)
+
+ mr.auth.user_id = 111L # User who is not banned cannot view banned page.
+ try:
+ servlet.AssertBasePermission(mr)
+ self.fail()
+ except webapp2.HTTPException as e:
+ self.assertEquals(404, e.code)
+
+ # This should not throw exception.
+ mr.auth.user_pb.banned = 'spammer'
+ servlet.AssertBasePermission(mr)
+
+ def testGatherPageData(self):
+ servlet = banned.Banned(
+ 'request', 'response', services=service_manager.Services())
+ self.assertNotEquals(servlet.template, None)
+
+ _request, mr = testing_helpers.GetRequestObjects()
+ page_data = servlet.GatherPageData(mr)
+
+ self.assertEquals(None, page_data['currentPageURLEncoded'])
+
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « appengine/monorail/framework/test/artifactcollision_test.py ('k') | appengine/monorail/framework/test/captcha_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698