Add customizable unauthorized URL. Fixes #23

This commit is contained in:
Matt Wright
2012-07-12 12:47:21 -04:00
parent 8d1bdca1de
commit dfcb3cdcc6
6 changed files with 47 additions and 13 deletions
+12 -2
View File
@@ -140,7 +140,8 @@ class ConfiguredURLTests(SecurityTest):
'SECURITY_LOGIN_VIEW': '/custom_login',
'SECURITY_POST_LOGIN_VIEW': '/post_login',
'SECURITY_POST_LOGOUT_VIEW': '/post_logout',
'SECURITY_POST_REGISTER_VIEW': '/post_register'
'SECURITY_POST_REGISTER_VIEW': '/post_register',
'SECURITY_UNAUTHORIZED_VIEW': '/unauthorized'
}
def test_login_view(self):
@@ -157,10 +158,19 @@ class ConfiguredURLTests(SecurityTest):
self.assertIn('Post Logout', r.data)
def test_register(self):
data = dict(email='dude@lp.com', password='password', password_confirm='password')
data = dict(email='dude@lp.com',
password='password',
password_confirm='password')
r = self.client.post('/register', data=data, follow_redirects=True)
self.assertIn('Post Register', r.data)
def test_unauthorized(self):
self.authenticate("joe@lp.com", endpoint="/custom_auth")
r = self._get("/admin", follow_redirects=True)
msg = 'You are not allowed to access the requested resouce'
self.assertIn(msg, r.data)
class RegisterableTests(SecurityTest):
AUTH_CONFIG = {