Add more test coverage

This commit is contained in:
Matt Wright
2012-08-14 13:47:16 -04:00
parent 49bebcdd7b
commit f6bb01545d
2 changed files with 27 additions and 3 deletions
+24
View File
@@ -12,11 +12,19 @@ except ImportError:
from flask.ext.security.utils import capture_registrations, \
capture_reset_password_requests
from werkzeug.utils import parse_cookie
from example import app
from tests import SecurityTest
def get_cookies(rv):
cookies = {}
for value in rv.headers.get_all("Set-Cookie"):
cookies.update(parse_cookie(value))
return cookies
class DefaultSecurityTests(SecurityTest):
def test_login_view(self):
@@ -153,6 +161,22 @@ class DefaultSecurityTests(SecurityTest):
self.assertIn('WWW-Authenticate', r.headers)
self.assertEquals('Basic realm="My Realm"', r.headers['WWW-Authenticate'])
def test_user_deleted_during_session_reverts_to_anonymous_user(self):
self.authenticate()
with self.app.test_request_context('/'):
user = self.app.security.datastore.find_user(email='matt@lp.com')
self.app.security.datastore.delete_user(user)
r = self._get('/')
self.assertNotIn('Hello matt@lp.com', r.data)
def test_remember_token(self):
r = self.authenticate(follow_redirects=False)
self.client.cookie_jar.clear_session_cookies()
r = self._get('/profile')
self.assertIn('profile', r.data)
class ConfiguredSecurityTests(SecurityTest):