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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
erp5
Commits
0d756303
Commit
0d756303
authored
Jan 26, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
credential: py3 wip
parent
a6fdc44c
Changes
2
Show 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 @
0d756303
...
@@ -35,7 +35,7 @@ for portal_type in related_portal_type:
...
@@ -35,7 +35,7 @@ for portal_type in related_portal_type:
context
.
CredentialRequest_updateLocalRolesOnSecurityGroups
()
context
.
CredentialRequest_updateLocalRolesOnSecurityGroups
()
if
password
is
not
None
:
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 is encoded, set it to None to script witch send the password to user
password
=
None
password
=
None
# Send notification in activities
# Send notification in activities
...
...
bt5/erp5_credential/TestTemplateItem/portal_components/test.erp5.testERP5Credential.py
View file @
0d756303
...
@@ -35,7 +35,6 @@ from DateTime import DateTime
...
@@ -35,7 +35,6 @@ from DateTime import DateTime
import
email
,
re
import
email
,
re
from
email.header
import
decode_header
,
make_header
from
email.header
import
decode_header
,
make_header
from
email.utils
import
parseaddr
from
email.utils
import
parseaddr
import
cgi
import
six.moves.urllib.parse
import
six.moves.urllib.parse
use_verbose_security
=
0
use_verbose_security
=
0
...
@@ -173,21 +172,22 @@ class TestERP5Credential(ERP5TypeTestCase):
...
@@ -173,21 +172,22 @@ class TestERP5Credential(ERP5TypeTestCase):
'headers'
:
{}
'headers'
:
{}
}
}
# Get Message
# Get Message
msg
=
email
.
message_from_string
(
file_
)
msg
=
email
.
message_from_string
(
file_
.
decode
()
)
# Back up original file
# Back up original file
theMail
[
'__original__'
]
=
file_
theMail
[
'__original__'
]
=
file_
# Recode headers to UTF-8 if needed
for
key
,
value
in
six
.
iteritems
(
msg
):
for
key
,
value
in
msg
.
items
():
decoded_value_list
=
decode_header
(
value
)
decoded_value_list
=
decode_header
(
value
)
unicode_value
=
make_header
(
decoded_value_list
)
new_value
=
make_header
(
decoded_value_list
)
new_value
=
unicode_value
.
__unicode__
().
encode
(
'utf-8'
)
if
six
.
PY2
:
# Recode headers to UTF-8 if needed
new_value
=
new_value
.
__unicode__
().
encode
(
'utf-8'
)
theMail
[
'headers'
][
key
.
lower
()]
=
new_value
theMail
[
'headers'
][
key
.
lower
()]
=
new_value
# Filter mail addresses
# Filter mail addresses
for
header
in
(
'resent-to'
,
'resent-from'
,
'resent-cc'
,
'resent-sender'
,
for
header
in
(
'resent-to'
,
'resent-from'
,
'resent-cc'
,
'resent-sender'
,
'to'
,
'from'
,
'cc'
,
'sender'
,
'reply-to'
):
'to'
,
'from'
,
'cc'
,
'sender'
,
'reply-to'
):
header_field
=
theMail
[
'headers'
].
get
(
header
)
header_field
=
theMail
[
'headers'
].
get
(
header
)
if
header_field
:
if
header_field
:
theMail
[
'headers'
][
header
]
=
parseaddr
(
header_field
)[
1
]
theMail
[
'headers'
][
header
]
=
parseaddr
(
header_field
.
encode
()
)[
1
]
# Get attachments
# Get attachments
body_found
=
0
body_found
=
0
for
part
in
msg
.
walk
():
for
part
in
msg
.
walk
():
...
@@ -203,11 +203,13 @@ class TestERP5Credential(ERP5TypeTestCase):
...
@@ -203,11 +203,13 @@ class TestERP5Credential(ERP5TypeTestCase):
elif
content_type
==
'message/rfc822'
:
elif
content_type
==
'message/rfc822'
:
continue
continue
elif
content_type
in
(
"text/plain"
,
"text/html"
):
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
)
payload
=
part
.
get_payload
(
decode
=
True
)
#LOG('CMFMailIn -> ',0,'charset: %s, payload: %s' % (charset,payload))
#LOG('CMFMailIn -> ',0,'charset: %s, payload: %s' % (charset,payload))
if
charset
:
if
charset
:
payload
=
unicode
(
payload
,
charset
).
encode
(
'utf-8'
)
payload
=
payload
.
decode
(
charset
)
if
six
.
PY2
:
payload
=
payload
.
encode
(
'utf-8'
)
if
body_found
:
if
body_found
:
# Keep the content type
# Keep the content type
theMail
[
'attachment_list'
].
append
((
file_name
,
theMail
[
'attachment_list'
].
append
((
file_name
,
...
@@ -810,7 +812,7 @@ class TestERP5Credential(ERP5TypeTestCase):
...
@@ -810,7 +812,7 @@ class TestERP5Credential(ERP5TypeTestCase):
url
=
url
.
strip
()
url
=
url
.
strip
()
self
.
assertNotEqual
(
url
,
None
)
self
.
assertNotEqual
(
url
,
None
)
self
.
publish
(
url
)
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
(
self
.
assertTrue
(
'reset_key'
in
parameters
,
'reset_key'
in
parameters
,
'reset_key not found in mail message : %s'
%
body_message
'reset_key not found in mail message : %s'
%
body_message
...
@@ -1100,12 +1102,11 @@ class TestERP5Credential(ERP5TypeTestCase):
...
@@ -1100,12 +1102,11 @@ class TestERP5Credential(ERP5TypeTestCase):
mfrom
,
mto
,
message_text
=
last_message
mfrom
,
mto
,
message_text
=
last_message
self
.
assertEqual
(
mfrom
,
'Portal Administrator <postmaster@localhost>'
)
self
.
assertEqual
(
mfrom
,
'Portal Administrator <postmaster@localhost>'
)
self
.
assertEqual
([
'Vifib Test <barney@duff.com>'
],
mto
)
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
])
decoded_message
=
self
.
decode_email
(
last_message
[
2
])
self
.
assertEqual
(
decoded_message
[
"headers"
][
"subject"
].
encode
(),
"Welcome"
)
body_message
=
decoded_message
[
'body'
]
body_message
=
decoded_message
[
'body'
]
self.assert
NotEqual(re.search("
key
=%
s
" % mail_message.getReference(),
self
.
assert
Regex
(
self
.
decode_email
(
last_message
[
2
])[
'body'
],
r"Hello\
Vi
fib\
Tes
t\
,
")
body_message), None
)
self.assertRegex(self.decode_email(last_message[2])['body'], "
key
=%
s
" % mail_message.getReference()
)
def testAssignmentCreationUsingSystemPreferenceProperty(self):
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