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
1a3880ec
Commit
1a3880ec
authored
Aug 26, 2018
by
Sheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Raise InvalidException for empty required value
parent
5519a170
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
+7
-7
test_app.py
tests/test_app.py
+4
-4
handler.py
webssh/handler.py
+3
-3
No files found.
tests/test_app.py
View file @
1a3880ec
...
...
@@ -87,17 +87,17 @@ class TestApp(AsyncHTTPTestCase):
body
=
'hostname=&port=&username=&password'
response
=
self
.
fetch
(
'/'
,
method
=
'POST'
,
body
=
body
)
self
.
assertEqual
(
response
.
code
,
400
)
self
.
assertIn
(
b
'Missing
argument
hostname'
,
response
.
body
)
self
.
assertIn
(
b
'Missing
value
hostname'
,
response
.
body
)
body
=
'hostname=127.0.0.1&port=&username=&password'
response
=
self
.
fetch
(
'/'
,
method
=
'POST'
,
body
=
body
)
self
.
assertEqual
(
response
.
code
,
400
)
self
.
assertIn
(
b
'Missing
argument
port'
,
response
.
body
)
self
.
assertIn
(
b
'Missing
value
port'
,
response
.
body
)
body
=
'hostname=127.0.0.1&port=7000&username=&password'
response
=
self
.
fetch
(
'/'
,
method
=
'POST'
,
body
=
body
)
self
.
assertEqual
(
response
.
code
,
400
)
self
.
assertIn
(
b
'Missing
argument
username'
,
response
.
body
)
self
.
assertIn
(
b
'Missing
value
username'
,
response
.
body
)
def
test_app_with_invalid_form_for_invalid_value
(
self
):
body
=
'hostname=127.0.0&port=22&username=&password'
...
...
@@ -234,7 +234,7 @@ class TestApp(AsyncHTTPTestCase):
ws
=
yield
tornado
.
websocket
.
websocket_connect
(
ws_url
)
msg
=
yield
ws
.
read_message
()
self
.
assertIsNone
(
msg
)
self
.
assertIn
(
'Missing
argument
id'
,
ws
.
close_reason
)
self
.
assertIn
(
'Missing
value
id'
,
ws
.
close_reason
)
@tornado.testing.gen_test
def
test_app_with_correct_credentials_but_wrong_id
(
self
):
...
...
webssh/handler.py
View file @
1a3880ec
...
...
@@ -55,7 +55,7 @@ class MixinHandler(object):
def
get_value
(
self
,
name
):
value
=
self
.
get_argument
(
name
)
if
not
value
:
raise
tornado
.
web
.
MissingArgumentError
(
name
)
raise
InvalidException
(
'Missing value {}'
.
format
(
name
)
)
return
value
def
get_real_client_addr
(
self
):
...
...
@@ -261,8 +261,8 @@ class WsockHandler(MixinHandler, tornado.websocket.WebSocketHandler):
logging
.
info
(
'Connected from {}:{}'
.
format
(
*
self
.
src_addr
))
try
:
worker_id
=
self
.
get_value
(
'id'
)
except
tornado
.
web
.
MissingArgumentError
as
exc
:
self
.
close
(
reason
=
exc
.
log_message
)
except
(
tornado
.
web
.
MissingArgumentError
,
InvalidException
)
as
exc
:
self
.
close
(
reason
=
str
(
exc
)
)
raise
else
:
worker
=
workers
.
get
(
worker_id
)
...
...
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