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
885dca4a
Commit
885dca4a
authored
Jan 12, 2017
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
preference tool password
parent
b90e9db7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
9 deletions
+21
-9
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/PreferenceTool_validatePassword.py
...portal_skins/erp5_base/PreferenceTool_validatePassword.py
+4
-3
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/PreferenceTool_validatePassword.xml
...ortal_skins/erp5_base/PreferenceTool_validatePassword.xml
+8
-0
product/ERP5/tests/testAuthenticationPolicy.py
product/ERP5/tests/testAuthenticationPolicy.py
+9
-6
No files found.
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/PreferenceTool_validatePassword.py
View file @
885dca4a
...
...
@@ -2,6 +2,7 @@
Check that password matchs with confirmation and that it complies to the authentication policy.
"""
from
AccessControl
import
getSecurityManager
from
Products.Formulator.Errors
import
ValidationError
password_confirm
=
request
.
get
(
'field_password_confirm'
,
...
...
@@ -11,9 +12,9 @@ password_confirm = request.get('field_password_confirm',
if
password_confirm
!=
editor
:
return
0
user
=
context
.
getPortalObject
().
portal_membership
.
getAuthenticatedMember
().
getUser
Value
()
if
user
is
not
None
:
validation_message_list
=
user
.
analyzePassword
(
editor
)
login
=
getSecurityManager
().
getUser
().
getLogin
Value
()
if
login
is
not
None
:
validation_message_list
=
login
.
analyzePassword
(
editor
)
if
validation_message_list
:
message
=
u' '
.
join
([
str
(
x
)
for
x
in
validation_message_list
])
raise
ValidationError
(
'external_validator_failed'
,
context
,
error_text
=
message
)
...
...
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/PreferenceTool_validatePassword.xml
View file @
885dca4a
...
...
@@ -52,6 +52,14 @@
<key>
<string>
_params
</string>
</key>
<value>
<string>
editor, request
</string>
</value>
</item>
<item>
<key>
<string>
_proxy_roles
</string>
</key>
<value>
<tuple>
<string>
Manager
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
PreferenceTool_validatePassword
</string>
</value>
...
...
product/ERP5/tests/testAuthenticationPolicy.py
View file @
885dca4a
...
...
@@ -32,6 +32,7 @@ import unittest
import
urllib
from
StringIO
import
StringIO
import
time
import
httplib
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.Formulator.Errors
import
ValidationError
from
Products.ERP5Type.Document
import
newTempBase
...
...
@@ -750,8 +751,8 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
person
.
newContent
(
portal_type
=
'Assignment'
).
open
()
login
=
person
.
objectValues
(
portal_type
=
'ERP5 Login'
)[
0
]
preference
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
'System Preference'
,
title
=
'Authentication'
,)
portal_type
=
'System Preference'
,
title
=
'Authentication'
,)
preference
.
setPreferredMinPasswordLength
(
10
)
self
.
_clearCache
()
self
.
tic
()
...
...
@@ -770,14 +771,14 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
})),
request_method
=
"POST"
,
handle_errors
=
False
)
self
.
assertEqual
s
(
200
,
ret
.
getStatus
())
self
.
assertEqual
(
httplib
.
OK
,
ret
.
getStatus
())
self
.
assertIn
(
'<span class="error">Too short.
</span>'
,
'<span class="error">Too short.</span>'
,
ret
.
getBody
())
# if for some reason, PreferenceTool_setNewPassword is called directly,
# the password policy is also checked, so this cause an unhandled exception.
self
.
login
(
person
.
getId
())
self
.
login
(
person
.
get
User
Id
())
self
.
assertRaises
(
ValueError
,
self
.
portal
.
PreferenceTool_setNewPassword
,
...
...
@@ -798,7 +799,9 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
})),
request_method
=
"POST"
,
handle_errors
=
False
)
self
.
assertEquals
(
200
,
ret
.
getStatus
())
# When password reset is succesful, user is logged out
self
.
assertEqual
(
httplib
.
FOUND
,
ret
.
getStatus
())
self
.
assertTrue
(
ret
.
getHeader
(
"Location"
).
endswith
(
"/logout"
))
# password is changed on the login
self
.
assertTrue
(
login
.
checkPassword
(
'long_enough_password'
))
...
...
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