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
Klaus Wölfel
slapos.core
Commits
6c3040ba
Commit
6c3040ba
authored
Oct 24, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initiate testing of instance access.
parent
1558d49b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
5 deletions
+45
-5
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSSlapTool.py
...r/bt5/slapos_cloud/TestTemplateItem/testSlapOSSlapTool.py
+44
-4
master/bt5/slapos_cloud/bt/revision
master/bt5/slapos_cloud/bt/revision
+1
-1
No files found.
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSSlapTool.py
View file @
6c3040ba
...
@@ -12,8 +12,7 @@ import xml.dom.ext
...
@@ -12,8 +12,7 @@ import xml.dom.ext
import
StringIO
import
StringIO
import
difflib
import
difflib
class
TestSlapOSSlapToolComputerAccess
(
testSlapOSMixin
):
class
TestSlapOSSlapToolMixin
(
testSlapOSMixin
):
def
generateNewId
(
self
):
def
generateNewId
(
self
):
return
self
.
portal
.
portal_ids
.
generateNewId
(
return
self
.
portal
.
portal_ids
.
generateNewId
(
id_group
=
(
'slapos_core_test'
))
id_group
=
(
'slapos_core_test'
))
...
@@ -32,7 +31,7 @@ class TestSlapOSSlapToolComputerAccess(testSlapOSMixin):
...
@@ -32,7 +31,7 @@ class TestSlapOSSlapToolComputerAccess(testSlapOSMixin):
'id="param">%s</parameter></instance>'
%
self
.
generateNewId
()
'id="param">%s</parameter></instance>'
%
self
.
generateNewId
()
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
super
(
TestSlapOSSlapTool
ComputerAccess
,
self
).
afterSetUp
()
super
(
TestSlapOSSlapTool
Mixin
,
self
).
afterSetUp
()
self
.
portal_slap
=
self
.
portal
.
portal_slap
self
.
portal_slap
=
self
.
portal
.
portal_slap
new_id
=
self
.
generateNewId
()
new_id
=
self
.
generateNewId
()
...
@@ -50,7 +49,6 @@ class TestSlapOSSlapToolComputerAccess(testSlapOSMixin):
...
@@ -50,7 +49,6 @@ class TestSlapOSSlapToolComputerAccess(testSlapOSMixin):
self
.
tic
()
self
.
tic
()
self
.
computer_id
=
self
.
computer
.
getReference
()
self
.
computer_id
=
self
.
computer
.
getReference
()
self
.
login
(
self
.
computer_id
)
def
beforeTearDown
(
self
):
def
beforeTearDown
(
self
):
pass
pass
...
@@ -181,6 +179,7 @@ class TestSlapOSSlapToolComputerAccess(testSlapOSMixin):
...
@@ -181,6 +179,7 @@ class TestSlapOSSlapToolComputerAccess(testSlapOSMixin):
self
.
tic
()
self
.
tic
()
class
TestSlapOSSlapToolComputerAccess
(
TestSlapOSSlapToolMixin
):
def
_getPartitionXml
(
self
):
def
_getPartitionXml
(
self
):
return
"""
\
return
"""
\
<?xml version='1.0' encoding='UTF-8'?>
<?xml version='1.0' encoding='UTF-8'?>
...
@@ -510,6 +509,7 @@ class TestSlapOSSlapToolComputerAccess(testSlapOSMixin):
...
@@ -510,6 +509,7 @@ class TestSlapOSSlapToolComputerAccess(testSlapOSMixin):
self
.
portal_slap
.
getComputerInformation
.
im_func
.
func_name
)
self
.
portal_slap
.
getComputerInformation
.
im_func
.
func_name
)
def
test_not_accessed_getComputerStatus
(
self
):
def
test_not_accessed_getComputerStatus
(
self
):
self
.
login
(
self
.
computer_id
)
created_at
=
rfc1123_date
(
DateTime
())
created_at
=
rfc1123_date
(
DateTime
())
response
=
self
.
portal_slap
.
getComputerStatus
(
self
.
computer_id
)
response
=
self
.
portal_slap
.
getComputerStatus
(
self
.
computer_id
)
self
.
assertEqual
(
200
,
response
.
status
)
self
.
assertEqual
(
200
,
response
.
status
)
...
@@ -548,6 +548,7 @@ class TestSlapOSSlapToolComputerAccess(testSlapOSMixin):
...
@@ -548,6 +548,7 @@ class TestSlapOSSlapToolComputerAccess(testSlapOSMixin):
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
def
test_accessed_getComputerStatus
(
self
):
def
test_accessed_getComputerStatus
(
self
):
self
.
login
(
self
.
computer_id
)
self
.
portal_slap
.
getComputerInformation
(
self
.
computer_id
)
self
.
portal_slap
.
getComputerInformation
(
self
.
computer_id
)
created_at
=
rfc1123_date
(
DateTime
())
created_at
=
rfc1123_date
(
DateTime
())
response
=
self
.
portal_slap
.
getComputerStatus
(
self
.
computer_id
)
response
=
self
.
portal_slap
.
getComputerStatus
(
self
.
computer_id
)
...
@@ -586,3 +587,42 @@ class TestSlapOSSlapToolComputerAccess(testSlapOSMixin):
...
@@ -586,3 +587,42 @@ class TestSlapOSSlapToolComputerAccess(testSlapOSMixin):
)
)
self
.
assertEqual
(
expected_xml
,
got_xml
,
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
class
TestSlapOSSlapToolInstanceAccess
(
TestSlapOSSlapToolMixin
):
def
test_getComputerPartitionCertificate
(
self
):
self
.
_makeComplexComputer
()
self
.
login
(
self
.
start_requested_software_instance
.
getReference
())
response
=
self
.
portal_slap
.
getComputerPartitionCertificate
(
self
.
computer_id
,
self
.
start_requested_software_instance
.
getAggregateValue
(
portal_type
=
'Computer Partition'
).
getReference
())
self
.
assertEqual
(
200
,
response
.
status
)
self
.
assertEqual
(
'public, max-age=0, must-revalidate'
,
response
.
headers
.
get
(
'cache-control'
))
self
.
assertEqual
(
'REMOTE_USER'
,
response
.
headers
.
get
(
'vary'
))
self
.
assertTrue
(
'last-modified'
in
response
.
headers
)
self
.
assertEqual
(
'text/xml; charset=utf-8'
,
response
.
headers
.
get
(
'content-type'
))
# check returned XML
xml_fp
=
StringIO
.
StringIO
()
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
response
.
body
),
stream
=
xml_fp
)
xml_fp
.
seek
(
0
)
got_xml
=
xml_fp
.
read
()
expected_xml
=
"""
\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<dictionary id='i2'>
<string>certificate</string>
<string>%(instance_certificate)s</string>
<string>key</string>
<string>%(instance_key)s</string>
</dictionary>
</marshal>
"""
%
dict
(
instance_certificate
=
self
.
start_requested_software_instance
.
getSslCertificate
(),
instance_key
=
self
.
start_requested_software_instance
.
getSslKey
()
)
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
master/bt5/slapos_cloud/bt/revision
View file @
6c3040ba
80
81
\ No newline at end of file
\ 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