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 @@
...
@@ -2,6 +2,7 @@
Check that password matchs with confirmation and that it complies to the authentication policy.
Check that password matchs with confirmation and that it complies to the authentication policy.
"""
"""
from
AccessControl
import
getSecurityManager
from
Products.Formulator.Errors
import
ValidationError
from
Products.Formulator.Errors
import
ValidationError
password_confirm
=
request
.
get
(
'field_password_confirm'
,
password_confirm
=
request
.
get
(
'field_password_confirm'
,
...
@@ -11,9 +12,9 @@ password_confirm = request.get('field_password_confirm',
...
@@ -11,9 +12,9 @@ password_confirm = request.get('field_password_confirm',
if
password_confirm
!=
editor
:
if
password_confirm
!=
editor
:
return
0
return
0
user
=
context
.
getPortalObject
().
portal_membership
.
getAuthenticatedMember
().
getUser
Value
()
login
=
getSecurityManager
().
getUser
().
getLogin
Value
()
if
user
is
not
None
:
if
login
is
not
None
:
validation_message_list
=
user
.
analyzePassword
(
editor
)
validation_message_list
=
login
.
analyzePassword
(
editor
)
if
validation_message_list
:
if
validation_message_list
:
message
=
u' '
.
join
([
str
(
x
)
for
x
in
validation_message_list
])
message
=
u' '
.
join
([
str
(
x
)
for
x
in
validation_message_list
])
raise
ValidationError
(
'external_validator_failed'
,
context
,
error_text
=
message
)
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 @@
...
@@ -52,6 +52,14 @@
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
editor, request
</string>
</value>
<value>
<string>
editor, request
</string>
</value>
</item>
</item>
<item>
<key>
<string>
_proxy_roles
</string>
</key>
<value>
<tuple>
<string>
Manager
</string>
</tuple>
</value>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
<value>
<string>
PreferenceTool_validatePassword
</string>
</value>
<value>
<string>
PreferenceTool_validatePassword
</string>
</value>
...
...
product/ERP5/tests/testAuthenticationPolicy.py
View file @
885dca4a
...
@@ -32,6 +32,7 @@ import unittest
...
@@ -32,6 +32,7 @@ import unittest
import
urllib
import
urllib
from
StringIO
import
StringIO
from
StringIO
import
StringIO
import
time
import
time
import
httplib
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.Formulator.Errors
import
ValidationError
from
Products.Formulator.Errors
import
ValidationError
from
Products.ERP5Type.Document
import
newTempBase
from
Products.ERP5Type.Document
import
newTempBase
...
@@ -750,8 +751,8 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
...
@@ -750,8 +751,8 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
person
.
newContent
(
portal_type
=
'Assignment'
).
open
()
person
.
newContent
(
portal_type
=
'Assignment'
).
open
()
login
=
person
.
objectValues
(
portal_type
=
'ERP5 Login'
)[
0
]
login
=
person
.
objectValues
(
portal_type
=
'ERP5 Login'
)[
0
]
preference
=
self
.
portal
.
portal_catalog
.
getResultValue
(
preference
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
'System Preference'
,
portal_type
=
'System Preference'
,
title
=
'Authentication'
,)
title
=
'Authentication'
,)
preference
.
setPreferredMinPasswordLength
(
10
)
preference
.
setPreferredMinPasswordLength
(
10
)
self
.
_clearCache
()
self
.
_clearCache
()
self
.
tic
()
self
.
tic
()
...
@@ -770,14 +771,14 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
...
@@ -770,14 +771,14 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
})),
})),
request_method
=
"POST"
,
request_method
=
"POST"
,
handle_errors
=
False
)
handle_errors
=
False
)
self
.
assertEqual
s
(
200
,
ret
.
getStatus
())
self
.
assertEqual
(
httplib
.
OK
,
ret
.
getStatus
())
self
.
assertIn
(
self
.
assertIn
(
'<span class="error">Too short.
</span>'
,
'<span class="error">Too short.</span>'
,
ret
.
getBody
())
ret
.
getBody
())
# if for some reason, PreferenceTool_setNewPassword is called directly,
# if for some reason, PreferenceTool_setNewPassword is called directly,
# the password policy is also checked, so this cause an unhandled exception.
# the password policy is also checked, so this cause an unhandled exception.
self
.
login
(
person
.
getId
())
self
.
login
(
person
.
get
User
Id
())
self
.
assertRaises
(
self
.
assertRaises
(
ValueError
,
ValueError
,
self
.
portal
.
PreferenceTool_setNewPassword
,
self
.
portal
.
PreferenceTool_setNewPassword
,
...
@@ -798,7 +799,9 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
...
@@ -798,7 +799,9 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
})),
})),
request_method
=
"POST"
,
request_method
=
"POST"
,
handle_errors
=
False
)
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
# password is changed on the login
self
.
assertTrue
(
login
.
checkPassword
(
'long_enough_password'
))
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