Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5_fork
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eteri
erp5_fork
Commits
f5b92a1b
Commit
f5b92a1b
authored
Oct 24, 2011
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initialise testing.
Cover basic _getSignature cases.
parent
be898a8d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
118 additions
and
1 deletion
+118
-1
bt5/erp5_payzen_secure_payment/TestTemplateItem/testERP5PayzenSecurePayment.py
...e_payment/TestTemplateItem/testERP5PayzenSecurePayment.py
+116
-0
bt5/erp5_payzen_secure_payment/bt/revision
bt5/erp5_payzen_secure_payment/bt/revision
+1
-1
bt5/erp5_payzen_secure_payment/bt/template_test_id_list
bt5/erp5_payzen_secure_payment/bt/template_test_id_list
+1
-0
No files found.
bt5/erp5_payzen_secure_payment/TestTemplateItem/testERP5PayzenSecurePayment.py
0 → 100644
View file @
f5b92a1b
##############################################################################
#
# Copyright (c) 2002-2011 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
import
hashlib
import
DateTime
def
sha1
(
s
):
return
hashlib
.
sha1
(
s
).
hexdigest
()
class
TestERP5PayzenSecurePaymentMixin
(
ERP5TypeTestCase
):
"""
An ERP5 Payzen Secure Payment test case
"""
def
getTitle
(
self
):
return
"ERP5 Payzen Secure Payment"
def
getBusinessTemplateList
(
self
):
"""
Tuple of Business Templates we need to install
"""
return
(
'erp5_base'
,
'erp5_secure_payment'
,
'erp5_payzen_secure_payment'
)
def
afterSetUp
(
self
):
self
.
portal
=
self
.
getPortalObject
()
self
.
service_password
=
'0123456789012345'
self
.
service
=
self
.
portal
.
portal_secure_payments
.
newContent
(
portal_type
=
'Payzen Service'
,
service_password
=
self
.
service_password
)
self
.
stepTic
()
class
TestERP5PayzenSecurePayment
(
TestERP5PayzenSecurePaymentMixin
):
def
test_getSignature_dict_simple
(
self
):
self
.
assertEqual
(
self
.
service
.
_getSignature
({
'key'
:
'value'
},
[
'key'
]),
sha1
(
'value+'
+
self
.
service_password
)
)
def
test_getSignature_dict_key_sort
(
self
):
self
.
assertEqual
(
self
.
service
.
_getSignature
({
'key'
:
'value'
,
'key1'
:
'value1'
},
[
'key'
,
'key1'
]),
sha1
(
'value+value1+'
+
self
.
service_password
)
)
self
.
assertEqual
(
self
.
service
.
_getSignature
({
'key'
:
'value'
,
'key1'
:
'value1'
},
[
'key1'
,
'key'
]),
sha1
(
'value1+value+'
+
self
.
service_password
)
)
def
test_getSignature_dict_date_as_DateTime
(
self
):
now
=
DateTime
.
DateTime
()
d
=
{
'key'
:
now
}
self
.
assertEqual
(
self
.
service
.
_getSignature
(
d
,
[
'key'
]),
sha1
(
now
.
strftime
(
'%Y%m%d'
)
+
'+'
+
self
.
service_password
)
)
# dict was updated
self
.
assertEqual
(
d
[
'key'
],
now
.
strftime
(
'%Y-%m-%dT%H:%M:%S'
))
def
test_getSignature_dict_date_as_DateTime_output_date
(
self
):
now
=
DateTime
.
DateTime
()
d
=
{
'key'
:
now
}
self
.
assertEqual
(
self
.
service
.
_getSignature
(
d
,
[
'key'
],
output_date_format
=
'%Y'
),
sha1
(
now
.
strftime
(
'%Y%m%d'
)
+
'+'
+
self
.
service_password
)
)
# dict was updated with passed format
self
.
assertEqual
(
d
[
'key'
],
now
.
strftime
(
'%Y'
))
def
test_getSignature_dict_date_as_DateTime_signature_format
(
self
):
now
=
DateTime
.
DateTime
()
d
=
{
'key'
:
now
}
self
.
assertEqual
(
self
.
service
.
_getSignature
(
d
,
[
'key'
],
signature_date_format
=
'%Y'
),
sha1
(
now
.
strftime
(
'%Y'
)
+
'+'
+
self
.
service_password
)
)
# dict was updated with passed format
self
.
assertEqual
(
d
[
'key'
],
now
.
strftime
(
'%Y-%m-%dT%H:%M:%S'
))
def
test_getSignature_dict_date_as_string
(
self
):
now
=
DateTime
.
DateTime
()
d
=
{
'keyDaTe'
:
now
.
strftime
(
'%Y-%m-%d %H:%M:%S'
)}
self
.
assertEqual
(
self
.
service
.
_getSignature
(
d
,
[
'keyDaTe'
]),
sha1
(
now
.
strftime
(
'%Y%m%d'
)
+
'+'
+
self
.
service_password
)
)
# dict was updated with passed format
self
.
assertEqual
(
d
[
'keyDaTe'
],
now
.
strftime
(
'%Y-%m-%dT%H:%M:%S'
))
bt5/erp5_payzen_secure_payment/bt/revision
View file @
f5b92a1b
37
\ No newline at end of file
38
\ No newline at end of file
bt5/erp5_payzen_secure_payment/bt/template_test_id_list
0 → 100644
View file @
f5b92a1b
testERP5PayzenSecurePayment
\ No newline at end of file
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