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
141
Merge Requests
141
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
67d5a4d9
Commit
67d5a4d9
authored
Jan 26, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
credential: py3 wip
parent
004cd9f5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
15 deletions
+16
-15
bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_createPersonAndAssignment.py
...credential/CredentialRequest_createPersonAndAssignment.py
+1
-1
bt5/erp5_credential/TestTemplateItem/portal_components/test.erp5.testERP5Credential.py
...ateItem/portal_components/test.erp5.testERP5Credential.py
+15
-14
No files found.
bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_createPersonAndAssignment.py
View file @
67d5a4d9
...
...
@@ -35,7 +35,7 @@ for portal_type in related_portal_type:
context
.
CredentialRequest_updateLocalRolesOnSecurityGroups
()
if
password
is
not
None
:
if
password
.
startswith
(
'{SSHA}'
):
if
password
.
startswith
(
b
'{SSHA}'
):
#password is encoded, set it to None to script witch send the password to user
password
=
None
# Send notification in activities
...
...
bt5/erp5_credential/TestTemplateItem/portal_components/test.erp5.testERP5Credential.py
View file @
67d5a4d9
...
...
@@ -35,7 +35,6 @@ from DateTime import DateTime
import
email
,
re
from
email.header
import
decode_header
,
make_header
from
email.utils
import
parseaddr
import
cgi
import
six.moves.urllib.parse
use_verbose_security
=
0
...
...
@@ -173,21 +172,22 @@ class TestERP5Credential(ERP5TypeTestCase):
'headers'
:
{}
}
# Get Message
msg
=
email
.
message_from_string
(
file_
)
msg
=
email
.
message_from_string
(
file_
.
decode
()
)
# Back up original file
theMail
[
'__original__'
]
=
file_
# Recode headers to UTF-8 if needed
for
key
,
value
in
msg
.
items
():
for
key
,
value
in
six
.
iteritems
(
msg
):
decoded_value_list
=
decode_header
(
value
)
unicode_value
=
make_header
(
decoded_value_list
)
new_value
=
unicode_value
.
__unicode__
().
encode
(
'utf-8'
)
new_value
=
make_header
(
decoded_value_list
)
if
six
.
PY2
:
# Recode headers to UTF-8 if needed
new_value
=
new_value
.
__unicode__
().
encode
(
'utf-8'
)
theMail
[
'headers'
][
key
.
lower
()]
=
new_value
# Filter mail addresses
for
header
in
(
'resent-to'
,
'resent-from'
,
'resent-cc'
,
'resent-sender'
,
'to'
,
'from'
,
'cc'
,
'sender'
,
'reply-to'
):
header_field
=
theMail
[
'headers'
].
get
(
header
)
if
header_field
:
theMail
[
'headers'
][
header
]
=
parseaddr
(
header_field
)[
1
]
theMail
[
'headers'
][
header
]
=
parseaddr
(
header_field
.
encode
()
)[
1
]
# Get attachments
body_found
=
0
for
part
in
msg
.
walk
():
...
...
@@ -203,11 +203,13 @@ class TestERP5Credential(ERP5TypeTestCase):
elif
content_type
==
'message/rfc822'
:
continue
elif
content_type
in
(
"text/plain"
,
"text/html"
):
charset
=
part
.
get_content_charset
()
charset
=
part
.
get_content_charset
()
or
'utf-8'
payload
=
part
.
get_payload
(
decode
=
True
)
#LOG('CMFMailIn -> ',0,'charset: %s, payload: %s' % (charset,payload))
if
charset
:
payload
=
unicode
(
payload
,
charset
).
encode
(
'utf-8'
)
payload
=
payload
.
decode
(
charset
)
if
six
.
PY2
:
payload
=
payload
.
encode
(
'utf-8'
)
if
body_found
:
# Keep the content type
theMail
[
'attachment_list'
].
append
((
file_name
,
...
...
@@ -810,7 +812,7 @@ class TestERP5Credential(ERP5TypeTestCase):
url
=
url
.
strip
()
self
.
assertNotEqual
(
url
,
None
)
self
.
publish
(
url
)
parameters
=
cgi
.
parse_qs
(
six
.
moves
.
urllib
.
parse
.
urlparse
(
url
)[
4
])
parameters
=
six
.
moves
.
urllib
.
parse
.
parse_qs
(
six
.
moves
.
urllib
.
parse
.
urlparse
(
url
)[
4
])
self
.
assertTrue
(
'reset_key'
in
parameters
,
'reset_key not found in mail message : %s'
%
body_message
...
...
@@ -1100,12 +1102,11 @@ class TestERP5Credential(ERP5TypeTestCase):
mfrom
,
mto
,
message_text
=
last_message
self
.
assertEqual
(
mfrom
,
'Portal Administrator <postmaster@localhost>'
)
self
.
assertEqual
([
'Vifib Test <barney@duff.com>'
],
mto
)
self
.
assertNotEqual
(
re
.
search
(
r"Subject\
:.*Welcome
", message_text), None)
self.assertNotEqual(re.search(r"
Hello
\
Vifib
\
Test
\
,
", message_text), None)
decoded_message
=
self
.
decode_email
(
last_message
[
2
])
self
.
assertEqual
(
decoded_message
[
"headers"
][
"subject"
].
encode
(),
"Welcome"
)
body_message
=
decoded_message
[
'body'
]
self.assert
NotEqual(re.search("
key
=%
s
" % mail_message.getReference(),
body_message), None
)
self
.
assert
Regex
(
self
.
decode_email
(
last_message
[
2
])[
'body'
],
r"Hello\
Vi
fib\
Tes
t\
,
")
self.assertRegex(self.decode_email(last_message[2])['body'], "
key
=%
s
" % mail_message.getReference()
)
def testAssignmentCreationUsingSystemPreferenceProperty(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