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

Side by Side Diff: appengine/findit/common/test/base_handler_test.py

Issue 2506893003: [Findit] After login, redirect to the targeted page for GETs, but original page for others like POS… (Closed)
Patch Set: Fix nits. Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « appengine/findit/common/base_handler.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import mock 5 import mock
6 import re 6 import re
7 import urllib 7 import urllib
8 8
9 import webapp2 9 import webapp2
10 import webtest 10 import webtest
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 PermissionLevelHandler.PERMISSION_LEVEL = permission 102 PermissionLevelHandler.PERMISSION_LEVEL = permission
103 # Simulation of task queue request by setting the header requires admin 103 # Simulation of task queue request by setting the header requires admin
104 # login. 104 # login.
105 self._VerifyAuthorizedAccess( 105 self._VerifyAuthorizedAccess(
106 'test@chromium.org', True, {'X-AppEngine-QueueName': 'task_queue'}) 106 'test@chromium.org', True, {'X-AppEngine-QueueName': 'task_queue'})
107 107
108 def testUnknownPermissionLevel(self): 108 def testUnknownPermissionLevel(self):
109 PermissionLevelHandler.PERMISSION_LEVEL = 80000 # An unknown permission. 109 PermissionLevelHandler.PERMISSION_LEVEL = 80000 # An unknown permission.
110 self._VerifyUnauthorizedAccess('test@google.com') 110 self._VerifyUnauthorizedAccess('test@google.com')
111 111
112 def testLoginLinkWithReferer(self): 112 def testLoginLinkForGetWithReferer(self):
113 PermissionLevelHandler.PERMISSION_LEVEL = Permission.CORP_USER
114 referer_url = 'http://localhost/referer'
115 login_url = ('https://www.google.com/accounts/Login?continue=%s' %
116 urllib.quote('http://localhost/permission'))
117 self.assertRaisesRegexp(
118 webtest.app.AppError,
119 re.compile('.*401 Unauthorized.*%s.*' % re.escape(login_url),
120 re.MULTILINE | re.DOTALL),
121 self.test_app.get, '/permission', headers={'referer': referer_url})
122
123 def testLoginLinkForGetWithoutReferer(self):
124 PermissionLevelHandler.PERMISSION_LEVEL = Permission.CORP_USER
125 login_url = ('https://www.google.com/accounts/Login?continue=%s' %
126 urllib.quote('http://localhost/permission'))
127 self.assertRaisesRegexp(
128 webtest.app.AppError,
129 re.compile('.*401 Unauthorized.*%s.*' % re.escape(login_url),
130 re.MULTILINE | re.DOTALL),
131 self.test_app.get, '/permission')
132
133 def testLoginLinkForPostWithReferer(self):
113 PermissionLevelHandler.PERMISSION_LEVEL = Permission.CORP_USER 134 PermissionLevelHandler.PERMISSION_LEVEL = Permission.CORP_USER
114 referer_url = 'http://localhost/referer' 135 referer_url = 'http://localhost/referer'
115 login_url = ('https://www.google.com/accounts/Login?continue=%s' % 136 login_url = ('https://www.google.com/accounts/Login?continue=%s' %
116 urllib.quote(referer_url)) 137 urllib.quote(referer_url))
117 self.assertRaisesRegexp( 138 self.assertRaisesRegexp(
118 webtest.app.AppError, 139 webtest.app.AppError,
119 re.compile('.*401 Unauthorized.*%s.*' % re.escape(login_url), 140 re.compile('.*401 Unauthorized.*%s.*' % re.escape(login_url),
120 re.MULTILINE | re.DOTALL), 141 re.MULTILINE | re.DOTALL),
121 self.test_app.get, '/permission', headers={'referer': referer_url}) 142 self.test_app.post, '/permission', headers={'referer': referer_url})
122 143
123 def testLoginLinkWithRequestedUrl(self): 144 def testLoginLinkWithRequestedUrl(self):
124 PermissionLevelHandler.PERMISSION_LEVEL = Permission.CORP_USER 145 PermissionLevelHandler.PERMISSION_LEVEL = Permission.CORP_USER
125 request_url = '/permission' 146 request_url = '/permission'
126 login_url = ('https://www.google.com/accounts/Login?continue=%s' % 147 login_url = ('https://www.google.com/accounts/Login?continue=%s' %
127 urllib.quote('http://localhost/permission')) 148 urllib.quote('http://localhost/permission'))
128 self.assertRaisesRegexp( 149 self.assertRaisesRegexp(
129 webtest.app.AppError, 150 webtest.app.AppError,
130 re.compile('.*401 Unauthorized.*%s.*' % re.escape(login_url), 151 re.compile('.*401 Unauthorized.*%s.*' % re.escape(login_url),
131 re.MULTILINE | re.DOTALL), 152 re.MULTILINE | re.DOTALL),
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 app_module = webapp2.WSGIApplication([ 276 app_module = webapp2.WSGIApplication([
256 ('/exception', InternalExceptionHandler), 277 ('/exception', InternalExceptionHandler),
257 ], debug=True) 278 ], debug=True)
258 279
259 def testInternalException(self): 280 def testInternalException(self):
260 self.assertRaisesRegexp( 281 self.assertRaisesRegexp(
261 webtest.app.AppError, 282 webtest.app.AppError,
262 re.compile('.*500 Internal Server Error.*An internal error occurred.*', 283 re.compile('.*500 Internal Server Error.*An internal error occurred.*',
263 re.MULTILINE | re.DOTALL), 284 re.MULTILINE | re.DOTALL),
264 self.test_app.get, '/exception') 285 self.test_app.get, '/exception')
OLDNEW
« no previous file with comments | « appengine/findit/common/base_handler.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698