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
139
Merge Requests
139
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
d3a022e0
Commit
d3a022e0
authored
Oct 05, 2022
by
Kazuhiko Shiozaki
Committed by
Arnaud Fontaine
Mar 10, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py2/py3: rename function attributes.
parent
b014aef9
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
42 additions
and
38 deletions
+42
-38
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFields.py
...estTemplateItem/portal_components/test.erp5.testFields.py
+2
-2
bt5/erp5_oauth_facebook_login/TestTemplateItem/portal_components/test.erp5.testFacebookLogin.py
...lateItem/portal_components/test.erp5.testFacebookLogin.py
+6
-6
bt5/erp5_oauth_google_login/TestTemplateItem/portal_components/test.erp5.testGoogleLogin.py
...mplateItem/portal_components/test.erp5.testGoogleLogin.py
+6
-6
bt5/erp5_openid_connect_client_login/TestTemplateItem/portal_components/test.erp5.testOpenIdConnectLogin.py
...tem/portal_components/test.erp5.testOpenIdConnectLogin.py
+6
-6
product/ERP5/tests/testSecurity.py
product/ERP5/tests/testSecurity.py
+7
-10
product/ERP5Type/Accessor/Alias.py
product/ERP5Type/Accessor/Alias.py
+1
-1
product/ERP5Type/Cache.py
product/ERP5Type/Cache.py
+1
-1
product/ERP5Type/patches/ExternalMethod.py
product/ERP5Type/patches/ExternalMethod.py
+11
-4
product/ERP5Type/patches/ZopePageTemplateUtils.py
product/ERP5Type/patches/ZopePageTemplateUtils.py
+1
-1
product/ERP5Type/tests/Sequence.py
product/ERP5Type/tests/Sequence.py
+1
-1
No files found.
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFields.py
View file @
d3a022e0
...
@@ -67,10 +67,10 @@ class TestRenderViewAPI(ERP5TypeTestCase):
...
@@ -67,10 +67,10 @@ class TestRenderViewAPI(ERP5TypeTestCase):
def
test_signature
(
self
):
def
test_signature
(
self
):
for
field
in
FieldRegistry
.
get_field_classes
().
itervalues
():
# pylint: disable=no-value-for-parameter
for
field
in
FieldRegistry
.
get_field_classes
().
itervalues
():
# pylint: disable=no-value-for-parameter
self
.
assertEqual
((
'self'
,
'value'
,
'REQUEST'
,
'render_prefix'
),
self
.
assertEqual
((
'self'
,
'value'
,
'REQUEST'
,
'render_prefix'
),
field
.
render_view
.
__func__
.
func_code
.
co_varnames
)
field
.
render_view
.
__func__
.
__code__
.
co_varnames
)
if
field
is
not
ProxyField
:
if
field
is
not
ProxyField
:
self
.
assertEqual
((
'self'
,
'field'
,
'value'
,
'REQUEST'
),
self
.
assertEqual
((
'self'
,
'field'
,
'value'
,
'REQUEST'
),
field
.
widget
.
render_view
.
__func__
.
func_code
.
co_varnames
[:
4
],
'%s %s'
%
(
field
.
widget
,
field
.
widget
.
render_view
.
__func__
.
func_code
.
co_varnames
[:
4
]))
field
.
widget
.
render_view
.
__func__
.
__code__
.
co_varnames
[:
4
],
'%s %s'
%
(
field
.
widget
,
field
.
widget
.
render_view
.
__func__
.
__code__
.
co_varnames
[:
4
]))
class
TestFloatField
(
ERP5TypeTestCase
):
class
TestFloatField
(
ERP5TypeTestCase
):
...
...
bt5/erp5_oauth_facebook_login/TestTemplateItem/portal_components/test.erp5.testFacebookLogin.py
View file @
d3a022e0
...
@@ -121,8 +121,8 @@ class TestFacebookLogin(ERP5TypeTestCase):
...
@@ -121,8 +121,8 @@ class TestFacebookLogin(ERP5TypeTestCase):
'erp5.component.extension.FacebookLoginUtility.getUserEntry'
,
'erp5.component.extension.FacebookLoginUtility.getUserEntry'
,
side_effect
=
getUserEntry
side_effect
=
getUserEntry
)
as
getUserEntry_mock
:
)
as
getUserEntry_mock
:
getAccessTokenFromCode_mock
.
func_code
=
getAccessTokenFromCode
.
func_code
getAccessTokenFromCode_mock
.
__code__
=
getAccessTokenFromCode
.
__code__
getUserEntry_mock
.
func_code
=
getUserEntry
.
func_code
getUserEntry_mock
.
__code__
=
getUserEntry
.
__code__
self
.
portal
.
ERP5Site_callbackFacebookLogin
(
code
=
CODE
)
self
.
portal
.
ERP5Site_callbackFacebookLogin
(
code
=
CODE
)
getAccessTokenFromCode_mock
.
assert_called_once
()
getAccessTokenFromCode_mock
.
assert_called_once
()
getUserEntry_mock
.
assert_called_once
()
getUserEntry_mock
.
assert_called_once
()
...
@@ -161,8 +161,8 @@ class TestFacebookLogin(ERP5TypeTestCase):
...
@@ -161,8 +161,8 @@ class TestFacebookLogin(ERP5TypeTestCase):
'erp5.component.extension.FacebookLoginUtility.getUserEntry'
,
'erp5.component.extension.FacebookLoginUtility.getUserEntry'
,
side_effect
=
getUserEntry
side_effect
=
getUserEntry
)
as
getUserEntry_mock
:
)
as
getUserEntry_mock
:
getAccessTokenFromCode_mock
.
func_code
=
getAccessTokenFromCode
.
func_code
getAccessTokenFromCode_mock
.
__code__
=
getAccessTokenFromCode
.
__code__
getUserEntry_mock
.
func_code
=
getUserEntry
.
func_code
getUserEntry_mock
.
__code__
=
getUserEntry
.
__code__
self
.
portal
.
ERP5Site_callbackFacebookLogin
(
code
=
CODE
)
self
.
portal
.
ERP5Site_callbackFacebookLogin
(
code
=
CODE
)
ac_cookie
,
=
[
v
for
(
k
,
v
)
in
response
.
listHeaders
()
if
k
.
lower
()
==
'set-cookie'
and
'__ac_facebook_hash='
in
v
]
ac_cookie
,
=
[
v
for
(
k
,
v
)
in
response
.
listHeaders
()
if
k
.
lower
()
==
'set-cookie'
and
'__ac_facebook_hash='
in
v
]
...
@@ -227,8 +227,8 @@ return credential_request
...
@@ -227,8 +227,8 @@ return credential_request
'erp5.component.extension.FacebookLoginUtility.getUserEntry'
,
'erp5.component.extension.FacebookLoginUtility.getUserEntry'
,
side_effect
=
getUserEntry
side_effect
=
getUserEntry
)
as
getUserEntry_mock
:
)
as
getUserEntry_mock
:
getAccessTokenFromCode_mock
.
func_code
=
getAccessTokenFromCode
.
func_code
getAccessTokenFromCode_mock
.
__code__
=
getAccessTokenFromCode
.
__code__
getUserEntry_mock
.
func_code
=
getUserEntry
.
func_code
getUserEntry_mock
.
__code__
=
getUserEntry
.
__code__
response
=
self
.
portal
.
ERP5Site_callbackFacebookLogin
(
code
=
CODE
)
response
=
self
.
portal
.
ERP5Site_callbackFacebookLogin
(
code
=
CODE
)
facebook_hash
=
self
.
portal
.
REQUEST
.
RESPONSE
.
cookies
.
get
(
"__ac_facebook_hash"
)[
"value"
]
facebook_hash
=
self
.
portal
.
REQUEST
.
RESPONSE
.
cookies
.
get
(
"__ac_facebook_hash"
)[
"value"
]
self
.
assertEqual
(
"8cec04e21e927f1023f4f4980ec11a77"
,
facebook_hash
)
self
.
assertEqual
(
"8cec04e21e927f1023f4f4980ec11a77"
,
facebook_hash
)
...
...
bt5/erp5_oauth_google_login/TestTemplateItem/portal_components/test.erp5.testGoogleLogin.py
View file @
d3a022e0
...
@@ -163,8 +163,8 @@ class TestGoogleLogin(GoogleLoginTestCase):
...
@@ -163,8 +163,8 @@ class TestGoogleLogin(GoogleLoginTestCase):
'erp5.component.extension.GoogleLoginUtility.getUserEntry'
,
'erp5.component.extension.GoogleLoginUtility.getUserEntry'
,
side_effect
=
getUserEntry
side_effect
=
getUserEntry
)
as
getUserEntry_mock
:
)
as
getUserEntry_mock
:
getAccessTokenFromCode_mock
.
func_code
=
getAccessTokenFromCode
.
func_code
getAccessTokenFromCode_mock
.
__code__
=
getAccessTokenFromCode
.
__code__
getUserEntry_mock
.
func_code
=
getUserEntry
.
func_code
getUserEntry_mock
.
__code__
=
getUserEntry
.
__code__
self
.
portal
.
ERP5Site_receiveGoogleCallback
(
code
=
CODE
)
self
.
portal
.
ERP5Site_receiveGoogleCallback
(
code
=
CODE
)
getAccessTokenFromCode_mock
.
assert_called_once
()
getAccessTokenFromCode_mock
.
assert_called_once
()
getUserEntry_mock
.
assert_called_once
()
getUserEntry_mock
.
assert_called_once
()
...
@@ -207,8 +207,8 @@ class TestGoogleLogin(GoogleLoginTestCase):
...
@@ -207,8 +207,8 @@ class TestGoogleLogin(GoogleLoginTestCase):
'erp5.component.extension.GoogleLoginUtility.getUserEntry'
,
'erp5.component.extension.GoogleLoginUtility.getUserEntry'
,
side_effect
=
getUserEntry
side_effect
=
getUserEntry
)
as
getUserEntry_mock
:
)
as
getUserEntry_mock
:
getAccessTokenFromCode_mock
.
func_code
=
getAccessTokenFromCode
.
func_code
getAccessTokenFromCode_mock
.
__code__
=
getAccessTokenFromCode
.
__code__
getUserEntry_mock
.
func_code
=
getUserEntry
.
func_code
getUserEntry_mock
.
__code__
=
getUserEntry
.
__code__
self
.
portal
.
ERP5Site_receiveGoogleCallback
(
code
=
CODE
)
self
.
portal
.
ERP5Site_receiveGoogleCallback
(
code
=
CODE
)
getAccessTokenFromCode_mock
.
assert_called_once
()
getAccessTokenFromCode_mock
.
assert_called_once
()
...
@@ -278,8 +278,8 @@ return credential_request
...
@@ -278,8 +278,8 @@ return credential_request
'erp5.component.extension.GoogleLoginUtility.getUserEntry'
,
'erp5.component.extension.GoogleLoginUtility.getUserEntry'
,
side_effect
=
getUserEntry
side_effect
=
getUserEntry
)
as
getUserEntry_mock
:
)
as
getUserEntry_mock
:
getAccessTokenFromCode_mock
.
func_code
=
getAccessTokenFromCode
.
func_code
getAccessTokenFromCode_mock
.
__code__
=
getAccessTokenFromCode
.
__code__
getUserEntry_mock
.
func_code
=
getUserEntry
.
func_code
getUserEntry_mock
.
__code__
=
getUserEntry
.
__code__
response
=
self
.
portal
.
ERP5Site_receiveGoogleCallback
(
code
=
CODE
)
response
=
self
.
portal
.
ERP5Site_receiveGoogleCallback
(
code
=
CODE
)
getAccessTokenFromCode_mock
.
assert_called_once
()
getAccessTokenFromCode_mock
.
assert_called_once
()
getUserEntry_mock
.
assert_called_once
()
getUserEntry_mock
.
assert_called_once
()
...
...
bt5/erp5_openid_connect_client_login/TestTemplateItem/portal_components/test.erp5.testOpenIdConnectLogin.py
View file @
d3a022e0
...
@@ -126,8 +126,8 @@ class TestOpenIdConnectLogin(OpenIdConnectLoginTestCase):
...
@@ -126,8 +126,8 @@ class TestOpenIdConnectLogin(OpenIdConnectLoginTestCase):
'erp5.component.extension.OpenIdConnectLoginUtility.getUserEntry'
,
'erp5.component.extension.OpenIdConnectLoginUtility.getUserEntry'
,
side_effect
=
getUserEntry
side_effect
=
getUserEntry
)
as
getUserEntry_mock
:
)
as
getUserEntry_mock
:
getAccessTokenFromCode_mock
.
func_code
=
getAccessTokenFromCode
.
func_code
getAccessTokenFromCode_mock
.
__code__
=
getAccessTokenFromCode
.
__code__
getUserEntry_mock
.
func_code
=
getUserEntry
.
func_code
getUserEntry_mock
.
__code__
=
getUserEntry
.
__code__
self
.
portal
.
ERP5Site_receiveOpenIdCallback
(
code
=
CODE
,
state
=
state
)
self
.
portal
.
ERP5Site_receiveOpenIdCallback
(
code
=
CODE
,
state
=
state
)
getAccessTokenFromCode_mock
.
assert_called_once
()
getAccessTokenFromCode_mock
.
assert_called_once
()
...
@@ -165,8 +165,8 @@ class TestOpenIdConnectLogin(OpenIdConnectLoginTestCase):
...
@@ -165,8 +165,8 @@ class TestOpenIdConnectLogin(OpenIdConnectLoginTestCase):
'erp5.component.extension.OpenIdConnectLoginUtility.getUserEntry'
,
'erp5.component.extension.OpenIdConnectLoginUtility.getUserEntry'
,
side_effect
=
getUserEntry
side_effect
=
getUserEntry
)
as
getUserEntry_mock
:
)
as
getUserEntry_mock
:
getAccessTokenFromCode_mock
.
func_code
=
getAccessTokenFromCode
.
func_code
getAccessTokenFromCode_mock
.
__code__
=
getAccessTokenFromCode
.
__code__
getUserEntry_mock
.
func_code
=
getUserEntry
.
func_code
getUserEntry_mock
.
__code__
=
getUserEntry
.
__code__
self
.
portal
.
ERP5Site_receiveOpenIdCallback
(
code
=
CODE
,
state
=
state
)
self
.
portal
.
ERP5Site_receiveOpenIdCallback
(
code
=
CODE
,
state
=
state
)
getAccessTokenFromCode_mock
.
assert_called_once
()
getAccessTokenFromCode_mock
.
assert_called_once
()
getUserEntry_mock
.
assert_called_once
()
getUserEntry_mock
.
assert_called_once
()
...
@@ -260,8 +260,8 @@ return credential_request
...
@@ -260,8 +260,8 @@ return credential_request
'erp5.component.extension.OpenIdConnectLoginUtility.getUserEntry'
,
'erp5.component.extension.OpenIdConnectLoginUtility.getUserEntry'
,
side_effect
=
getUserEntry
side_effect
=
getUserEntry
)
as
getUserEntry_mock
:
)
as
getUserEntry_mock
:
getAccessTokenFromCode_mock
.
func_code
=
getAccessTokenFromCode
.
func_code
getAccessTokenFromCode_mock
.
__code__
=
getAccessTokenFromCode
.
__code__
getUserEntry_mock
.
func_code
=
getUserEntry
.
func_code
getUserEntry_mock
.
__code__
=
getUserEntry
.
__code__
self
.
portal
.
ERP5Site_receiveOpenIdCallback
(
code
=
CODE
,
state
=
state
)
self
.
portal
.
ERP5Site_receiveOpenIdCallback
(
code
=
CODE
,
state
=
state
)
getAccessTokenFromCode_mock
.
assert_called_once
()
getAccessTokenFromCode_mock
.
assert_called_once
()
getUserEntry_mock
.
assert_called_once
()
getUserEntry_mock
.
assert_called_once
()
...
...
product/ERP5/tests/testSecurity.py
View file @
d3a022e0
...
@@ -92,18 +92,15 @@ class TestSecurityMixin(ERP5TypeTestCase):
...
@@ -92,18 +92,15 @@ class TestSecurityMixin(ERP5TypeTestCase):
method
.
__doc__
and
\
method
.
__doc__
and
\
not
hasattr
(
obj
,
'%s__roles__'
%
method_id
)
and
\
not
hasattr
(
obj
,
'%s__roles__'
%
method_id
)
and
\
method
.
__module__
:
method
.
__module__
:
if
method
.
__module__
==
'Products.ERP5Type.Accessor.WorkflowState'
and
method
.
func_code
.
co_name
==
'serialize'
:
if
method
.
__module__
==
'Products.ERP5Type.Accessor.WorkflowState'
and
method
.
__code__
.
co_name
==
'serialize'
:
continue
continue
func_code
=
method
.
__code__
func_code
=
method
.
__code__
error_set
.
add
((
func_code
.
co_filename
,
func_code
.
co_firstlineno
,
method_id
))
error_dict
[(
func_code
.
co_filename
,
func_code
.
co_firstlineno
,
method_id
)]
=
True
error_list
=
error_dict
.
keys
()
error_list
=
[]
if
os
.
environ
.
get
(
'erp5_debug_mode'
,
None
):
for
filename
,
lineno
,
method_id
in
sorted
(
error_set
):
pass
# ignore security problems with non ERP5 documents, unless running in debug mode.
if
os
.
environ
.
get
(
'erp5_debug_mode'
)
or
'/erp5/'
in
filename
or
'<portal_components'
in
filename
:
error_list
.
append
(
'%s:%s %s'
%
(
filename
,
lineno
,
method_id
))
else
:
else
:
print
(
'Ignoring missing security definition for %s in %s:%s '
%
(
method_id
,
filename
,
lineno
)
)
error_list
=
filter
(
lambda
x
:
'/erp5/'
in
x
[
0
],
error_list
)
if
error_list
:
if
error_list
:
message
=
'
\
n
The following %s methods have a docstring but have no security assertions.
\
n
\
t
%s'
\
message
=
'
\
n
The following %s methods have a docstring but have no security assertions.
\
n
\
t
%s'
\
%
(
len
(
error_list
),
'
\
n
\
t
'
.
join
(
error_list
))
%
(
len
(
error_list
),
'
\
n
\
t
'
.
join
(
error_list
))
...
...
product/ERP5Type/Accessor/Alias.py
View file @
d3a022e0
...
@@ -82,7 +82,7 @@ class Dummy(Reindex):
...
@@ -82,7 +82,7 @@ class Dummy(Reindex):
self
.
_id
=
id
self
.
_id
=
id
self
.
__name__
=
id
self
.
__name__
=
id
self
.
_accessor_id
=
accessor_id
self
.
_accessor_id
=
accessor_id
# self.__code__ = func_code = getattr(instance, self._accessor_id).
func_code
# self.__code__ = func_code = getattr(instance, self._accessor_id).
__code__
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
method
=
getattr
(
instance
,
self
.
_accessor_id
)
method
=
getattr
(
instance
,
self
.
_accessor_id
)
...
...
product/ERP5Type/Cache.py
View file @
d3a022e0
...
@@ -353,7 +353,7 @@ def transactional_cached(key_method=_default_key_method):
...
@@ -353,7 +353,7 @@ def transactional_cached(key_method=_default_key_method):
def
decorator
(
function
):
def
decorator
(
function
):
# Unfornately, we can only check functions (not other callable like class).
# Unfornately, we can only check functions (not other callable like class).
assert
(
key_method
is
not
_default_key_method
or
assert
(
key_method
is
not
_default_key_method
or
not
getattr
(
function
,
'
func_defaults
'
,
None
)),
(
not
getattr
(
function
,
'
__defaults__
'
,
None
)),
(
"default 'key_method' of 'transactional_cached' does not work with"
"default 'key_method' of 'transactional_cached' does not work with"
" functions having default values for parameters"
)
" functions having default values for parameters"
)
key
=
repr
(
function
)
key
=
repr
(
function
)
...
...
product/ERP5Type/patches/ExternalMethod.py
View file @
d3a022e0
...
@@ -83,14 +83,18 @@ class _(PatchClass(ExternalMethod)):
...
@@ -83,14 +83,18 @@ class _(PatchClass(ExternalMethod)):
return
_f
return
_f
except
AttributeError
:
except
AttributeError
:
pass
pass
code
=
f
.
func_code
code
=
f
.
__code__
argument_object
=
getargs
(
code
)
argument_object
=
getargs
(
code
)
# reconstruct back the original names
# reconstruct back the original names
arg_list
=
argument_object
.
args
[:]
arg_list
=
argument_object
.
args
[:]
if
argument_object
.
varargs
:
if
argument_object
.
varargs
:
arg_list
.
append
(
'*'
+
argument_object
.
varargs
)
arg_list
.
append
(
'*'
+
argument_object
.
varargs
)
if
six
.
PY2
:
if
argument_object
.
keywords
:
if
argument_object
.
keywords
:
arg_list
.
append
(
'**'
+
argument_object
.
keywords
)
arg_list
.
append
(
'**'
+
argument_object
.
keywords
)
else
:
if
argument_object
.
varkw
:
arg_list
.
append
(
'**'
+
argument_object
.
varkw
)
i
=
isinstance
(
f
,
MethodType
)
i
=
isinstance
(
f
,
MethodType
)
ff
=
six
.
get_unbound_function
(
f
)
if
i
else
f
ff
=
six
.
get_unbound_function
(
f
)
if
i
else
f
...
@@ -98,6 +102,9 @@ class _(PatchClass(ExternalMethod)):
...
@@ -98,6 +102,9 @@ class _(PatchClass(ExternalMethod)):
i
+=
has_self
i
+=
has_self
if
i
:
if
i
:
code
=
FuncCode
(
ff
,
i
)
code
=
FuncCode
(
ff
,
i
)
try
:
# This fails with mock function
self
.
_v_f
=
_f
=
(
f
,
f
.
__defaults__
,
code
,
has_self
,
arg_list
)
except
AttributeError
:
self
.
_v_f
=
_f
=
(
f
,
f
.
func_defaults
,
code
,
has_self
,
arg_list
)
self
.
_v_f
=
_f
=
(
f
,
f
.
func_defaults
,
code
,
has_self
,
arg_list
)
return
_f
return
_f
...
...
product/ERP5Type/patches/ZopePageTemplateUtils.py
View file @
d3a022e0
...
@@ -59,4 +59,4 @@ try:
...
@@ -59,4 +59,4 @@ try:
except
TypeError
:
except
TypeError
:
# We need to monkey patch in-place, as it is a top-level function and
# We need to monkey patch in-place, as it is a top-level function and
# already imported in other places.
# already imported in other places.
convertToUnicode
.
func_code
=
patched_convertToUnicode
.
func_code
convertToUnicode
.
__code__
=
patched_convertToUnicode
.
__code__
product/ERP5Type/tests/Sequence.py
View file @
d3a022e0
...
@@ -57,7 +57,7 @@ def special_extract_tb(tb, limit = None):
...
@@ -57,7 +57,7 @@ def special_extract_tb(tb, limit = None):
else
:
line
=
None
else
:
line
=
None
# display where we failed in the sequence
# display where we failed in the sequence
if
co
==
Sequence
.
play
.
func_code
:
if
co
==
Sequence
.
play
.
__code__
:
if
line
is
None
:
if
line
is
None
:
line
=
''
line
=
''
sequence
=
f
.
f_locals
[
'self'
]
sequence
=
f
.
f_locals
[
'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