Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Rafael Monnerat
slapos
Commits
26741e83
Commit
26741e83
authored
Oct 02, 2019
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slaprunner: test for web services
parent
1a5df533
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
0 deletions
+77
-0
software/slaprunner/test/setup.py
software/slaprunner/test/setup.py
+1
-0
software/slaprunner/test/test.py
software/slaprunner/test/test.py
+76
-0
No files found.
software/slaprunner/test/setup.py
View file @
26741e83
...
...
@@ -49,6 +49,7 @@ setup(name=name,
'psutil'
,
'paramiko'
,
'six'
,
'requests'
,
],
zip_safe
=
True
,
test_suite
=
'test'
,
...
...
software/slaprunner/test/test.py
View file @
26741e83
...
...
@@ -26,14 +26,18 @@
##############################################################################
import
os
import
unittest
import
paramiko
import
contextlib
import
base64
import
hashlib
import
subprocess
from
six.moves.urllib.parse
import
urlparse
from
six.moves.urllib.parse
import
quote
from
six.moves.urllib.parse
import
urljoin
from
six.moves.configparser
import
ConfigParser
import
requests
from
slapos.recipe.librecipe
import
generateHashFromFiles
from
slapos.testing.testcase
import
makeModuleSetUpAndTestCaseClass
...
...
@@ -48,6 +52,78 @@ class SlaprunnerTestCase(SlapOSInstanceTestCase):
__partition_reference__
=
's'
class
TestWeb
(
SlaprunnerTestCase
):
def
test_slaprunner
(
self
):
# slaprunner main interface is password protected
parameter_dict
=
self
.
computer_partition
.
getConnectionParameterDict
()
url
=
parameter_dict
[
'url'
]
resp
=
requests
.
get
(
url
,
verify
=
False
)
self
.
assertEqual
(
requests
.
codes
.
unauthorized
,
resp
.
status_code
)
resp
=
requests
.
get
(
url
,
verify
=
False
,
auth
=
(
parameter_dict
[
'init-user'
],
parameter_dict
[
'init-password'
]))
self
.
assertEqual
(
requests
.
codes
.
ok
,
resp
.
status_code
)
self
.
assertIn
(
'SlapOS'
,
resp
.
text
)
def
test_shellinabox
(
self
):
# shellinabox exists at /shellinabox and is password protected
parameter_dict
=
self
.
computer_partition
.
getConnectionParameterDict
()
url
=
urljoin
(
parameter_dict
[
'url'
],
'/shellinabox'
)
resp
=
requests
.
get
(
url
,
verify
=
False
)
self
.
assertEqual
(
requests
.
codes
.
unauthorized
,
resp
.
status_code
)
resp
=
requests
.
get
(
url
,
verify
=
False
,
auth
=
(
parameter_dict
[
'init-user'
],
parameter_dict
[
'init-password'
]))
self
.
assertEqual
(
requests
.
codes
.
ok
,
resp
.
status_code
)
self
.
assertIn
(
'ShellInABox'
,
resp
.
text
)
self
.
assertNotIn
(
'SlapOS'
,
resp
.
text
)
def
test_public_url
(
self
):
# ~/srv/runner/public/ is served over http
parameter_dict
=
self
.
computer_partition
.
getConnectionParameterDict
()
public_url
=
parameter_dict
[
'public-url'
]
hello_file
=
os
.
path
.
join
(
self
.
computer_partition_root_path
,
'srv'
,
'runner'
,
'public'
,
'hello.html'
)
self
.
addCleanup
(
os
.
remove
,
hello_file
)
with
open
(
hello_file
,
'w'
)
as
f
:
f
.
write
(
'<b>Hello</b>'
)
index
=
requests
.
get
(
public_url
,
verify
=
False
)
self
.
assertEqual
(
requests
.
codes
.
ok
,
index
.
status_code
)
self
.
assertIn
(
'hello.html'
,
index
.
text
)
hello
=
requests
.
get
(
urljoin
(
public_url
,
'hello.html'
),
verify
=
False
)
self
.
assertEqual
(
requests
.
codes
.
ok
,
hello
.
status_code
)
self
.
assertIn
(
'<b>Hello</b>'
,
hello
.
text
)
# git seems broken, these are 404 now...
@
unittest
.
expectedFailure
def
test_git_private
(
self
):
parameter_dict
=
self
.
computer_partition
.
getConnectionParameterDict
()
url
=
parameter_dict
[
'git-private'
]
resp
=
requests
.
get
(
url
,
verify
=
False
)
self
.
assertEqual
(
requests
.
codes
.
unauthorized
,
resp
.
status_code
)
resp
=
requests
.
get
(
url
,
verify
=
False
,
auth
=
(
parameter_dict
[
'init-user'
],
parameter_dict
[
'init-password'
]))
self
.
assertEqual
(
requests
.
codes
.
ok
,
resp
.
status_code
)
@
unittest
.
expectedFailure
def
test_git_public
(
self
):
parameter_dict
=
self
.
computer_partition
.
getConnectionParameterDict
()
url
=
parameter_dict
[
'git-public'
]
resp
=
requests
.
get
(
url
,
verify
=
False
)
self
.
assertEqual
(
requests
.
codes
.
ok
,
resp
.
status_code
)
class
TestSSH
(
SlaprunnerTestCase
):
@
classmethod
def
getInstanceParameterDict
(
cls
):
...
...
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