mirror of
https://github.com/wassname/flask-security.git
synced 2026-07-08 00:10:54 +08:00
work in progress
This commit is contained in:
+24
-24
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import with_statement
|
||||
# from __future__ import with_statement
|
||||
|
||||
import base64
|
||||
import time
|
||||
@@ -16,18 +16,18 @@ from flask.ext.security.forms import TextField, SubmitField, valid_user_email
|
||||
|
||||
from tests import SecurityTest
|
||||
|
||||
# TODO: Wait for passlib + bcrypt python3 compatibility to be fixed
|
||||
# class ConfiguredPasswordHashSecurityTests(SecurityTest):
|
||||
|
||||
class ConfiguredPasswordHashSecurityTests(SecurityTest):
|
||||
# AUTH_CONFIG = {
|
||||
# 'SECURITY_PASSWORD_HASH': 'bcrypt',
|
||||
# 'SECURITY_PASSWORD_SALT': 'so-salty',
|
||||
# 'USER_COUNT': 1
|
||||
# }
|
||||
|
||||
AUTH_CONFIG = {
|
||||
'SECURITY_PASSWORD_HASH': 'bcrypt',
|
||||
'SECURITY_PASSWORD_SALT': 'so-salty',
|
||||
'USER_COUNT': 1
|
||||
}
|
||||
|
||||
def test_authenticate(self):
|
||||
r = self.authenticate(endpoint="/login")
|
||||
self.assertIn(b'Home Page', r.data)
|
||||
# def test_authenticate(self):
|
||||
# r = self.authenticate(endpoint="/login")
|
||||
# self.assertIn(b'Home Page', r.data)
|
||||
|
||||
|
||||
class ConfiguredSecurityTests(SecurityTest):
|
||||
@@ -45,7 +45,7 @@ class ConfiguredSecurityTests(SecurityTest):
|
||||
|
||||
def test_login_view(self):
|
||||
r = self._get('/custom_login')
|
||||
self.assertIn("<h1>Login</h1>", r.data)
|
||||
self.assertIn(b"<h1>Login</h1>", r.data)
|
||||
|
||||
def test_authenticate(self):
|
||||
r = self.authenticate(endpoint="/custom_login")
|
||||
@@ -87,13 +87,13 @@ class ConfiguredSecurityTests(SecurityTest):
|
||||
password='password',
|
||||
password_confirm='password')
|
||||
r = self._post('/register', data=data, follow_redirects=True)
|
||||
msg = 'matt@lp.com is already associated with an account'
|
||||
msg = b'matt@lp.com is already associated with an account'
|
||||
self.assertIn(msg, 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'
|
||||
msg = b'You are not allowed to access the requested resouce'
|
||||
self.assertIn(msg, r.data)
|
||||
|
||||
def test_default_http_auth_realm(self):
|
||||
@@ -221,7 +221,7 @@ class ConfirmableTests(SecurityTest):
|
||||
e = 'dude@lp.com'
|
||||
|
||||
with capture_registrations() as registrations:
|
||||
self.register(e)
|
||||
r = self.register(e)
|
||||
token = registrations[0]['confirm_token']
|
||||
|
||||
self.client.get('/confirm/' + token, follow_redirects=True)
|
||||
@@ -241,7 +241,7 @@ class ConfirmableTests(SecurityTest):
|
||||
e = 'dude@lp.com'
|
||||
|
||||
with capture_registrations() as registrations:
|
||||
self.register(e)
|
||||
r = self.register(e)
|
||||
token = registrations[0]['confirm_token']
|
||||
|
||||
r = self.client.get('/confirm/' + token, follow_redirects=True)
|
||||
@@ -393,7 +393,7 @@ class RecoverableTests(SecurityTest):
|
||||
def test_forgot_password_invalid_email(self):
|
||||
r = self._post('/reset', data=dict(email='larry@lp.com'),
|
||||
follow_redirects=True)
|
||||
self.assertIn("Specified user does not exist", r.data)
|
||||
self.assertIn(b"Specified user does not exist", r.data)
|
||||
|
||||
def test_reset_password_with_valid_token(self):
|
||||
with capture_reset_password_requests() as requests:
|
||||
@@ -755,11 +755,11 @@ class ExtendFormsTest(SecurityTest):
|
||||
|
||||
def test_login_view(self):
|
||||
r = self._get('/login', follow_redirects=True)
|
||||
self.assertIn("My Login Email Address Field", r.data)
|
||||
self.assertIn(b"My Login Email Address Field", r.data)
|
||||
|
||||
def test_register(self):
|
||||
r = self._get('/register', follow_redirects=True)
|
||||
self.assertIn("My Register Email Address Field", r.data)
|
||||
self.assertIn(b"My Register Email Address Field", r.data)
|
||||
|
||||
|
||||
class RecoverableExtendFormsTest(SecurityTest):
|
||||
@@ -782,7 +782,7 @@ class RecoverableExtendFormsTest(SecurityTest):
|
||||
|
||||
def test_forgot_password(self):
|
||||
r = self._get('/reset', follow_redirects=True)
|
||||
self.assertIn("My Forgot Password Email Address Field", r.data)
|
||||
self.assertIn(b"My Forgot Password Email Address Field", r.data)
|
||||
|
||||
def test_reset_password(self):
|
||||
with capture_reset_password_requests() as requests:
|
||||
@@ -790,7 +790,7 @@ class RecoverableExtendFormsTest(SecurityTest):
|
||||
follow_redirects=True)
|
||||
token = requests[0]['token']
|
||||
r = self._get('/reset/' + token)
|
||||
self.assertIn("My Reset Password Submit Field", r.data)
|
||||
self.assertIn(b"My Reset Password Submit Field", r.data)
|
||||
|
||||
|
||||
class PasswordlessExtendFormsTest(SecurityTest):
|
||||
@@ -808,7 +808,7 @@ class PasswordlessExtendFormsTest(SecurityTest):
|
||||
|
||||
def test_passwordless_login(self):
|
||||
r = self._get('/login', follow_redirects=True)
|
||||
self.assertIn("My Passwordless Login Email Address Field", r.data)
|
||||
self.assertIn(b"My Passwordless Login Email Address Field", r.data)
|
||||
|
||||
|
||||
class ConfirmableExtendFormsTest(SecurityTest):
|
||||
@@ -831,11 +831,11 @@ class ConfirmableExtendFormsTest(SecurityTest):
|
||||
|
||||
def test_register(self):
|
||||
r = self._get('/register', follow_redirects=True)
|
||||
self.assertIn("My Confirm Register Email Address Field", r.data)
|
||||
self.assertIn(b"My Confirm Register Email Address Field", r.data)
|
||||
|
||||
def test_send_confirmation(self):
|
||||
r = self._get('/confirm', follow_redirects=True)
|
||||
self.assertIn("My Send Confirmation Email Address Field", r.data)
|
||||
self.assertIn(b"My Send Confirmation Email Address Field", r.data)
|
||||
|
||||
|
||||
class AdditionalUserIdentityAttributes(SecurityTest):
|
||||
|
||||
Reference in New Issue
Block a user