Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
webssh
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
郑天保
webssh
Commits
6cfd981e
Commit
6cfd981e
authored
Aug 29, 2018
by
Sheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tested server error
parent
49226fbf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
6 deletions
+73
-6
test_app.py
tests/test_app.py
+66
-2
handler.py
webssh/handler.py
+4
-1
index.html
webssh/templates/index.html
+3
-3
No files found.
tests/test_app.py
View file @
6cfd981e
...
@@ -25,7 +25,7 @@ except ImportError:
...
@@ -25,7 +25,7 @@ except ImportError:
handler
.
DELAY
=
0.1
handler
.
DELAY
=
0.1
class
TestApp
(
AsyncHTTPTestCase
):
class
TestApp
Basic
(
AsyncHTTPTestCase
):
running
=
[
True
]
running
=
[
True
]
sshserver_port
=
2200
sshserver_port
=
2200
...
@@ -63,7 +63,7 @@ class TestApp(AsyncHTTPTestCase):
...
@@ -63,7 +63,7 @@ class TestApp(AsyncHTTPTestCase):
print
(
'='
*
20
)
print
(
'='
*
20
)
def
get_httpserver_options
(
self
):
def
get_httpserver_options
(
self
):
options
=
super
(
TestApp
,
self
)
.
get_httpserver_options
()
options
=
super
(
TestApp
Basic
,
self
)
.
get_httpserver_options
()
options
.
update
(
max_body_size
=
max_body_size
)
options
.
update
(
max_body_size
=
max_body_size
)
return
options
return
options
...
@@ -420,3 +420,67 @@ class TestApp(AsyncHTTPTestCase):
...
@@ -420,3 +420,67 @@ class TestApp(AsyncHTTPTestCase):
self
.
assertIsNone
(
data
[
'id'
])
self
.
assertIsNone
(
data
[
'id'
])
self
.
assertIsNone
(
data
[
'encoding'
])
self
.
assertIsNone
(
data
[
'encoding'
])
self
.
assertIn
(
'Bad authentication type'
,
data
[
'status'
])
self
.
assertIn
(
'Bad authentication type'
,
data
[
'status'
])
class
OtherTestBase
(
AsyncHTTPTestCase
):
sshserver_port
=
3300
headers
=
{
'Cookie'
:
'_xsrf=yummy'
}
debug
=
False
body
=
{
'hostname'
:
'127.0.0.1'
,
'port'
:
''
,
'username'
:
'robey'
,
'password'
:
'foo'
,
'_xsrf'
:
'yummy'
}
def
get_app
(
self
):
self
.
body
.
update
(
port
=
str
(
self
.
sshserver_port
))
loop
=
self
.
io_loop
options
.
debug
=
self
.
debug
options
.
policy
=
random
.
choice
([
'warning'
,
'autoadd'
])
options
.
hostFile
=
''
options
.
sysHostFile
=
''
app
=
make_app
(
make_handlers
(
loop
,
options
),
get_app_settings
(
options
))
return
app
def
setUp
(
self
):
print
(
'='
*
20
)
self
.
running
=
True
OtherTestBase
.
sshserver_port
+=
1
t
=
threading
.
Thread
(
target
=
run_ssh_server
,
args
=
(
self
.
sshserver_port
,
self
.
running
)
)
t
.
setDaemon
(
True
)
t
.
start
()
super
(
OtherTestBase
,
self
)
.
setUp
()
def
tearDown
(
self
):
self
.
running
=
False
print
(
'='
*
20
)
super
(
OtherTestBase
,
self
)
.
tearDown
()
class
TestAppInDebug
(
OtherTestBase
):
debug
=
True
def
my_assertIn
(
self
,
part
,
whole
):
if
swallow_http_errors
:
self
.
assertIn
(
part
,
whole
)
else
:
self
.
assertIn
(
b
'Uncaught exception'
,
whole
)
def
test_server_error
(
self
):
response
=
self
.
fetch
(
'/?error=generate'
,
method
=
'GET'
)
self
.
my_assertIn
(
b
'Internal Server Error'
,
response
.
body
)
def
test_html
(
self
):
response
=
self
.
fetch
(
'/'
,
method
=
'GET'
)
self
.
assertNotIn
(
b
'required>'
,
response
.
body
)
class
TestAppMiscell
(
OtherTestBase
):
debug
=
False
webssh/handler.py
View file @
6cfd981e
...
@@ -222,7 +222,10 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
...
@@ -222,7 +222,10 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
future
.
set_result
(
worker
)
future
.
set_result
(
worker
)
def
get
(
self
):
def
get
(
self
):
self
.
render
(
'index.html'
)
debug
=
self
.
settings
.
get
(
'debug'
,
False
)
if
debug
and
self
.
get_argument
(
'error'
,
u''
):
raise
ValueError
(
'Uncaught exception'
)
self
.
render
(
'index.html'
,
debug
=
debug
)
@tornado.gen.coroutine
@tornado.gen.coroutine
def
post
(
self
):
def
post
(
self
):
...
...
webssh/templates/index.html
View file @
6cfd981e
...
@@ -28,17 +28,17 @@
...
@@ -28,17 +28,17 @@
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col"
>
<div
class=
"col"
>
<label
for=
"Hostname"
>
Hostname
</label>
<label
for=
"Hostname"
>
Hostname
</label>
<input
class=
"form-control"
type=
"text"
id=
"hostname"
name=
"hostname"
value=
""
required
>
<input
class=
"form-control"
type=
"text"
id=
"hostname"
name=
"hostname"
value=
""
{%
if
not
debug
%}
required
{%
end
%}
>
</div>
</div>
<div
class=
"col"
>
<div
class=
"col"
>
<label
for=
"Port"
>
Port
</label>
<label
for=
"Port"
>
Port
</label>
<input
class=
"form-control"
type=
"number"
id=
"port"
name=
"port"
min=
1
max=
65535
value=
""
required
>
<input
class=
"form-control"
type=
"number"
id=
"port"
name=
"port"
value=
""
{%
if
not
debug
%}
min=
1
max=
65535
required
{%
end
%}
>
</div>
</div>
</div>
</div>
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col"
>
<div
class=
"col"
>
<label
for=
"Username"
>
Username
</label>
<label
for=
"Username"
>
Username
</label>
<input
class=
"form-control"
type=
"text"
id=
"username"
name=
"username"
value=
""
required
>
<input
class=
"form-control"
type=
"text"
id=
"username"
name=
"username"
value=
""
{%
if
not
debug
%}
required
{%
end
%}
>
</div>
</div>
<div
class=
"col"
>
<div
class=
"col"
>
<label
for=
"Username"
>
Private Key
</label>
<label
for=
"Username"
>
Private Key
</label>
...
...
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