Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
Xiaowu Zhang
slapos.core
Commits
5fce544a
Commit
5fce544a
authored
Oct 16, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check computer request and cert manipulation.
parent
aafb86eb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
189 additions
and
0 deletions
+189
-0
master/product/Vifib/tests/testVifibSlapComputer.py
master/product/Vifib/tests/testVifibSlapComputer.py
+169
-0
master/product/Vifib/tests/testVifibSlapWebService.py
master/product/Vifib/tests/testVifibSlapWebService.py
+20
-0
No files found.
master/product/Vifib/tests/testVifibSlapComputer.py
0 → 100644
View file @
5fce544a
from
Products.ERP5Type.tests.Sequence
import
SequenceList
import
transaction
import
unittest
from
testVifibSlapWebService
import
TestVifibSlapWebServiceMixin
class
TestVifibSlapComputer
(
TestVifibSlapWebServiceMixin
):
def
stepCheckRequestedComputerCertificate
(
self
,
sequence
,
**
kw
):
computer
=
sequence
[
'requested_computer'
]
sequence
[
'computer_reference'
]
=
computer
.
_computer_id
certificate_dict
=
computer
.
getCertificateDict
()
self
.
assertTrue
(
'certificate'
in
certificate_dict
)
self
.
assertTrue
(
'key'
in
certificate_dict
)
self
.
assertNotEqual
(
None
,
certificate_dict
[
'certificate'
])
self
.
assertNotEqual
(
None
,
certificate_dict
[
'key'
])
self
.
assertTrue
(
certificate_dict
[
'key'
].
startswith
(
'-----BEGIN PRIVATE KEY-----'
))
self
.
assertTrue
(
'-----BEGIN CERTIFICATE-----'
in
\
certificate_dict
[
'certificate'
])
computer
=
self
.
portal
.
portal_catalog
.
getResultValue
(
reference
=
sequence
[
'computer_reference'
],
portal_type
=
'Computer'
)
self
.
assertNotEqual
(
None
,
computer
.
getDestinationReference
())
sequence
[
'certificate_reference'
]
=
computer
.
getDestinationReference
()
def
test_request
(
self
):
sequence_list
=
SequenceList
()
sequence_string
=
'
\
SlapLoginTestVifibAdmin
\
SetComputerTitle
\
RequestComputer
\
CleanTic
\
CheckRequestedComputerCertificate
\
SlapLogout
\
'
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
def
stepCheckSecondRequestComputer
(
self
,
sequence
,
**
kw
):
computer
=
sequence
[
'requested_computer'
]
self
.
assertEqual
(
computer
.
_computer_id
,
sequence
[
'computer_reference'
])
certificate_dict
=
computer
.
getCertificateDict
()
self
.
assertTrue
(
'certificate'
in
certificate_dict
)
self
.
assertTrue
(
'key'
in
certificate_dict
)
self
.
assertEqual
(
None
,
certificate_dict
[
'certificate'
])
self
.
assertEqual
(
None
,
certificate_dict
[
'key'
])
computer_document
=
self
.
portal
.
portal_catalog
.
getResultValue
(
reference
=
sequence
[
'computer_reference'
],
portal_type
=
'Computer'
)
self
.
assertEqual
(
sequence
[
'certificate_reference'
],
computer_document
.
getDestinationReference
())
def
test_request_twice
(
self
):
sequence_list
=
SequenceList
()
sequence_string
=
'
\
SlapLoginTestVifibAdmin
\
SetComputerTitle
\
RequestComputer
\
CleanTic
\
CheckRequestedComputerCertificate
\
RequestComputer
\
CleanTic
\
CheckSecondRequestComputer
\
SlapLogout
\
'
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
def
stepCheckDoubleRequestRaisesNotImplementedError
(
self
,
sequence
,
**
kw
):
person
=
self
.
portal
.
ERP5Site_getAuthenticatedMemberPersonValue
()
person
.
requestComputer
(
computer_title
=
sequence
[
'computer_title'
])
transaction
.
commit
()
self
.
assertRaises
(
NotImplementedError
,
person
.
requestComputer
,
computer_title
=
sequence
[
'computer_title'
])
def
test_request_twice_activity
(
self
):
sequence_list
=
SequenceList
()
sequence_string
=
'
\
LoginTestVifibAdmin
\
SetComputerTitle
\
CheckDoubleRequestRaisesNotImplementedError
\
Logout
\
'
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
def
stepCheckComputerNoCertificate
(
self
,
sequence
,
**
kw
):
computer
=
self
.
portal
.
portal_catalog
.
getResultValue
(
reference
=
sequence
[
'computer_reference'
],
portal_type
=
'Computer'
)
self
.
assertEqual
(
None
,
computer
.
getDestinationReference
())
def
test_revokeCertificate
(
self
):
sequence_list
=
SequenceList
()
sequence_string
=
'
\
SlapLoginTestVifibAdmin
\
SetComputerTitle
\
RequestComputer
\
CleanTic
\
CheckRequestedComputerCertificate
\
RevokeComputerCertificate
\
CheckComputerNoCertificate
\
SlapLogout
\
'
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
def
stepCheckRevokeComputerCertificateRaisesValueError
(
self
,
sequence
,
**
kw
):
computer
=
self
.
portal
.
portal_catalog
.
getResultValue
(
reference
=
sequence
[
'computer_reference'
],
portal_type
=
'Computer'
)
self
.
assertRaises
(
ValueError
,
computer
.
revokeCertificate
)
def
test_revokeCertificateRevoked
(
self
):
sequence_list
=
SequenceList
()
sequence_string
=
'
\
SlapLoginTestVifibAdmin
\
SetComputerTitle
\
RequestComputer
\
CleanTic
\
CheckRequestedComputerCertificate
\
RevokeComputerCertificate
\
CheckComputerNoCertificate
\
SlapLogout
\
LoginTestVifibAdmin
\
CheckRevokeComputerCertificateRaisesValueError
\
Logout
\
'
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
def
test_getCertificate
(
self
):
sequence_list
=
SequenceList
()
sequence_string
=
'
\
SlapLoginTestVifibAdmin
\
SetComputerTitle
\
RequestComputer
\
CleanTic
\
CheckRequestedComputerCertificate
\
RevokeComputerCertificate
\
CheckComputerNoCertificate
\
GetComputerCertificate
\
CleanTic
\
CheckRequestedComputerCertificate
\
SlapLogout
\
'
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
def
stepCheckGetComputerCertificateRaisesValueError
(
self
,
sequence
,
**
kw
):
computer
=
self
.
portal
.
portal_catalog
.
getResultValue
(
reference
=
sequence
[
'computer_reference'
],
portal_type
=
'Computer'
)
self
.
assertRaises
(
ValueError
,
computer
.
getCertificate
)
def
test_getCertificateNotRevoked
(
self
):
sequence_list
=
SequenceList
()
sequence_string
=
'
\
SlapLoginTestVifibAdmin
\
SetComputerTitle
\
RequestComputer
\
CleanTic
\
CheckRequestedComputerCertificate
\
SlapLogout
\
LoginTestVifibAdmin
\
CheckGetComputerCertificateRaisesValueError
\
Logout
\
'
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestVifibSlapComputer
))
return
suite
master/product/Vifib/tests/testVifibSlapWebService.py
View file @
5fce544a
...
...
@@ -672,6 +672,26 @@ class TestVifibSlapWebServiceMixin(testVifibMixin):
sequence
[
'computer_title'
]
=
str
(
random
())
self
.
slap
.
requestComputer
(
sequence
[
'computer_title'
])
def
stepSetComputerTitle
(
self
,
sequence
,
**
kw
):
sequence
[
'computer_title'
]
=
str
(
random
())
def
stepRequestComputer
(
self
,
sequence
,
**
kw
):
self
.
slap
=
slap
.
slap
()
self
.
slap
.
initializeConnection
(
self
.
server_url
,
timeout
=
None
)
sequence
[
'requested_computer'
]
=
self
.
slap
.
requestComputer
(
sequence
[
'computer_title'
])
def
stepRevokeComputerCertificate
(
self
,
sequence
,
**
kw
):
self
.
slap
=
slap
.
slap
()
self
.
slap
.
initializeConnection
(
self
.
server_url
,
timeout
=
None
)
self
.
slap
.
revokeComputerCertificate
(
sequence
[
'computer_reference'
])
def
stepGetComputerCertificate
(
self
,
sequence
,
**
kw
):
self
.
slap
=
slap
.
slap
()
self
.
slap
.
initializeConnection
(
self
.
server_url
,
timeout
=
None
)
sequence
[
'requested_computer'
]
=
self
.
slap
.
getComputerCertificate
(
sequence
[
'computer_reference'
])
def
stepSetComputerCoordinatesFromComputerTitle
(
self
,
sequence
,
**
kw
):
computer
=
self
.
portal
.
portal_catalog
.
getResultValue
(
title
=
sequence
[
'computer_title'
],
portal_type
=
'Computer'
)
...
...
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