Created
August 13, 2013 20:15
-
-
Save fweep/6225226 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyramid.authentication import AuthTktAuthenticationPolicy | |
from pyramid.authorization import ACLAuthorizationPolicy | |
from myapp.tests.base import ViewTestBase | |
from myapp.views.authentication.login import login_view | |
from myapp.tests.helper import create_user | |
class LoginViewTests(ViewTestBase): | |
def setUp(self): | |
super(LoginViewTests, self).setUp() | |
self.config.add_route('home', '/') | |
authz_policy = ACLAuthorizationPolicy() | |
authn_policy = AuthTktAuthenticationPolicy('secret', hashalg='sha512') | |
self.config.set_authorization_policy(authz_policy) | |
self.config.set_authentication_policy(authn_policy) | |
def test_sets_cookie_on_success(self): | |
user = create_user() | |
from pyramid.request import Request | |
request = Request.blank('/authentication/login', base_url='http://example.com/') | |
request.method = "POST" | |
request.POST['login'] = user.login | |
request.POST['password'] = user.password | |
result = login_view(request) | |
self.assertTrue("Set-Cookie" in result.headers.keys()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment