Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
d2b72fdb
Commit
d2b72fdb
authored
Jul 28, 2011
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add testing for Anonymous User using validation script.
parent
0f22c0b3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
4 deletions
+26
-4
product/ERP5/tests/testAuthenticationPolicy.py
product/ERP5/tests/testAuthenticationPolicy.py
+26
-4
No files found.
product/ERP5/tests/testAuthenticationPolicy.py
View file @
d2b72fdb
...
...
@@ -32,6 +32,7 @@ import unittest
import
time
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.backportUnittest
import
expectedFailure
from
Products.Formulator.Errors
import
ValidationError
from
Products.ERP5Type.Document
import
newTempBase
from
DateTime
import
DateTime
...
...
@@ -229,8 +230,8 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
"""
Test validity of a password.
"""
portal
=
self
.
getPortal
()
request
=
self
.
app
.
REQUEST
regular_expression_list
=
[
'([a-z]+)'
,
# english lowercase
'([A-Z]+)'
,
# english uppercase
...
...
@@ -299,12 +300,10 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
self
.
assertEqual
(
1
,
person
.
isPasswordValid
(
'a'
))
self
.
assertEqual
(
1
,
person
.
isPasswordValid
(
'b'
))
# only last 3 (including current one are invalid)
#import pdb; pdb.set_trace()
self
.
assertEqual
(
-
4
,
person
.
isPasswordValid
(
'd'
))
self
.
assertEqual
(
-
4
,
person
.
isPasswordValid
(
'e'
))
self
.
assertEqual
(
-
4
,
person
.
isPasswordValid
(
'f'
))
# if we remove restricted then all password are usable
preference
.
setPreferredNumberOfLastPasswordToCheck
(
None
)
self
.
_clearCache
()
...
...
@@ -422,6 +421,29 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
self
.
assertTrue
(
temp_person
.
Person_isPasswordValid
(
'abAB#12_%s'
%
first_name
))
self
.
assertTrue
(
temp_person
.
Person_isPasswordValid
(
'abAB#12_%s'
%
last_name
))
# check Base_isPasswordValid is able to work in Anonymous User fashion
# but with already create Person object (i.e. recover password case)
preference
.
setPrefferedForceUsernameCheckInPassword
(
1
)
preference
.
setPreferredMinPasswordLength
(
7
)
preference
.
setPreferredMinRegularExpressionGroupNumber
(
3
)
preference
.
setPreferredNumberOfLastPasswordToCheck
(
1
)
self
.
_clearCache
()
self
.
stepTic
()
person
.
setPassword
(
'used_ALREADY_1234'
)
self
.
_clearCache
()
self
.
stepTic
()
# emulate Anonymous User
self
.
logout
()
request
.
set
(
'field_user_login'
,
person
.
getReference
())
self
.
assertRaises
(
ValidationError
,
portal
.
Base_isPasswordValid
,
'abAB#12_%s'
%
person
.
getFirstName
(),
request
)
# contains name
self
.
assertRaises
(
ValidationError
,
portal
.
Base_isPasswordValid
,
'abAB#12_%s'
%
person
.
getLastName
(),
request
)
# contains name
self
.
assertRaises
(
ValidationError
,
portal
.
Base_isPasswordValid
,
'abAB#1'
,
request
)
# too short
self
.
assertRaises
(
ValidationError
,
portal
.
Base_isPasswordValid
,
'abABCDEFG'
,
request
)
# too few groups
self
.
assertRaises
(
ValidationError
,
portal
.
Base_isPasswordValid
,
'used_ALREADY_1234'
,
request
)
# already used
self
.
assertEqual
(
1
,
portal
.
Base_isPasswordValid
(
'abAB#12_'
,
request
))
self
.
assertEqual
(
1
,
portal
.
Base_isPasswordValid
(
'not_used_ALREADY_1234'
,
request
))
def
test_04_PasswordExpire
(
self
):
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment