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
f6100207
Commit
f6100207
authored
Aug 20, 2018
by
Sheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed quotes
parent
0fb6caa9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
+16
-16
test_app.py
tests/test_app.py
+16
-16
No files found.
tests/test_app.py
View file @
f6100207
...
@@ -63,35 +63,35 @@ class TestApp(AsyncHTTPTestCase):
...
@@ -63,35 +63,35 @@ class TestApp(AsyncHTTPTestCase):
response
=
self
.
fetch
(
'/'
)
response
=
self
.
fetch
(
'/'
)
self
.
assertEqual
(
response
.
code
,
200
)
self
.
assertEqual
(
response
.
code
,
200
)
body
=
'hostname=&port=&username=&password'
body
=
'hostname=&port=&username=&password'
response
=
self
.
fetch
(
'/'
,
method
=
"POST"
,
body
=
body
)
response
=
self
.
fetch
(
'/'
,
method
=
'POST'
,
body
=
body
)
self
.
assertIn
(
b
'"status": "The hostname field is required"'
,
response
.
body
)
# noqa
self
.
assertIn
(
b
'"status": "The hostname field is required"'
,
response
.
body
)
# noqa
body
=
'hostname=127.0.0.1&port=&username=&password'
body
=
'hostname=127.0.0.1&port=&username=&password'
response
=
self
.
fetch
(
'/'
,
method
=
"POST"
,
body
=
body
)
response
=
self
.
fetch
(
'/'
,
method
=
'POST'
,
body
=
body
)
self
.
assertIn
(
b
'"status": "The port field is required"'
,
response
.
body
)
self
.
assertIn
(
b
'"status": "The port field is required"'
,
response
.
body
)
body
=
'hostname=127.0.0.1&port=port&username=&password'
body
=
'hostname=127.0.0.1&port=port&username=&password'
response
=
self
.
fetch
(
'/'
,
method
=
"POST"
,
body
=
body
)
response
=
self
.
fetch
(
'/'
,
method
=
'POST'
,
body
=
body
)
self
.
assertIn
(
b
'"status": "Invalid port'
,
response
.
body
)
self
.
assertIn
(
b
'"status": "Invalid port'
,
response
.
body
)
body
=
'hostname=127.0.0.1&port=70000&username=&password'
body
=
'hostname=127.0.0.1&port=70000&username=&password'
response
=
self
.
fetch
(
'/'
,
method
=
"POST"
,
body
=
body
)
response
=
self
.
fetch
(
'/'
,
method
=
'POST'
,
body
=
body
)
self
.
assertIn
(
b
'"status": "Invalid port'
,
response
.
body
)
self
.
assertIn
(
b
'"status": "Invalid port'
,
response
.
body
)
body
=
'hostname=127.0.0.1&port=7000&username=&password'
body
=
'hostname=127.0.0.1&port=7000&username=&password'
response
=
self
.
fetch
(
'/'
,
method
=
"POST"
,
body
=
body
)
response
=
self
.
fetch
(
'/'
,
method
=
'POST'
,
body
=
body
)
self
.
assertIn
(
b
'"status": "The username field is required"'
,
response
.
body
)
# noqa
self
.
assertIn
(
b
'"status": "The username field is required"'
,
response
.
body
)
# noqa
def
test_app_with_wrong_credentials
(
self
):
def
test_app_with_wrong_credentials
(
self
):
response
=
self
.
fetch
(
'/'
)
response
=
self
.
fetch
(
'/'
)
self
.
assertEqual
(
response
.
code
,
200
)
self
.
assertEqual
(
response
.
code
,
200
)
response
=
self
.
fetch
(
'/'
,
method
=
"POST"
,
body
=
self
.
body
+
's'
)
response
=
self
.
fetch
(
'/'
,
method
=
'POST'
,
body
=
self
.
body
+
's'
)
self
.
assertIn
(
b
'Authentication failed.'
,
response
.
body
)
self
.
assertIn
(
b
'Authentication failed.'
,
response
.
body
)
def
test_app_with_correct_credentials
(
self
):
def
test_app_with_correct_credentials
(
self
):
response
=
self
.
fetch
(
'/'
)
response
=
self
.
fetch
(
'/'
)
self
.
assertEqual
(
response
.
code
,
200
)
self
.
assertEqual
(
response
.
code
,
200
)
response
=
self
.
fetch
(
'/'
,
method
=
"POST"
,
body
=
self
.
body
)
response
=
self
.
fetch
(
'/'
,
method
=
'POST'
,
body
=
self
.
body
)
data
=
json
.
loads
(
to_str
(
response
.
body
))
data
=
json
.
loads
(
to_str
(
response
.
body
))
self
.
assertIsNone
(
data
[
'status'
])
self
.
assertIsNone
(
data
[
'status'
])
self
.
assertIsNotNone
(
data
[
'id'
])
self
.
assertIsNotNone
(
data
[
'id'
])
...
@@ -104,7 +104,7 @@ class TestApp(AsyncHTTPTestCase):
...
@@ -104,7 +104,7 @@ class TestApp(AsyncHTTPTestCase):
response
=
yield
client
.
fetch
(
url
)
response
=
yield
client
.
fetch
(
url
)
self
.
assertEqual
(
response
.
code
,
200
)
self
.
assertEqual
(
response
.
code
,
200
)
response
=
yield
client
.
fetch
(
url
,
method
=
"POST"
,
body
=
self
.
body
)
response
=
yield
client
.
fetch
(
url
,
method
=
'POST'
,
body
=
self
.
body
)
data
=
json
.
loads
(
to_str
(
response
.
body
))
data
=
json
.
loads
(
to_str
(
response
.
body
))
self
.
assertIsNone
(
data
[
'status'
])
self
.
assertIsNone
(
data
[
'status'
])
self
.
assertIsNotNone
(
data
[
'id'
])
self
.
assertIsNotNone
(
data
[
'id'
])
...
@@ -130,9 +130,9 @@ class TestApp(AsyncHTTPTestCase):
...
@@ -130,9 +130,9 @@ class TestApp(AsyncHTTPTestCase):
content_type
,
body
=
encode_multipart_formdata
(
self
.
body_dict
.
items
(),
content_type
,
body
=
encode_multipart_formdata
(
self
.
body_dict
.
items
(),
files
)
files
)
headers
=
{
headers
=
{
"Content-Type"
:
content_type
,
'content-length'
:
str
(
len
(
body
))
'Content-Type'
:
content_type
,
'content-length'
:
str
(
len
(
body
))
}
}
response
=
yield
client
.
fetch
(
url
,
method
=
"POST"
,
headers
=
headers
,
response
=
yield
client
.
fetch
(
url
,
method
=
'POST'
,
headers
=
headers
,
body
=
body
)
body
=
body
)
data
=
json
.
loads
(
to_str
(
response
.
body
))
data
=
json
.
loads
(
to_str
(
response
.
body
))
self
.
assertIsNone
(
data
[
'status'
])
self
.
assertIsNone
(
data
[
'status'
])
...
@@ -159,9 +159,9 @@ class TestApp(AsyncHTTPTestCase):
...
@@ -159,9 +159,9 @@ class TestApp(AsyncHTTPTestCase):
content_type
,
body
=
encode_multipart_formdata
(
self
.
body_dict
.
items
(),
content_type
,
body
=
encode_multipart_formdata
(
self
.
body_dict
.
items
(),
files
)
files
)
headers
=
{
headers
=
{
"Content-Type"
:
content_type
,
'content-length'
:
str
(
len
(
body
))
'Content-Type'
:
content_type
,
'content-length'
:
str
(
len
(
body
))
}
}
response
=
yield
client
.
fetch
(
url
,
method
=
"POST"
,
headers
=
headers
,
response
=
yield
client
.
fetch
(
url
,
method
=
'POST'
,
headers
=
headers
,
body
=
body
)
body
=
body
)
data
=
json
.
loads
(
to_str
(
response
.
body
))
data
=
json
.
loads
(
to_str
(
response
.
body
))
self
.
assertIsNotNone
(
data
[
'status'
])
self
.
assertIsNotNone
(
data
[
'status'
])
...
@@ -180,11 +180,11 @@ class TestApp(AsyncHTTPTestCase):
...
@@ -180,11 +180,11 @@ class TestApp(AsyncHTTPTestCase):
content_type
,
body
=
encode_multipart_formdata
(
self
.
body_dict
.
items
(),
content_type
,
body
=
encode_multipart_formdata
(
self
.
body_dict
.
items
(),
files
)
files
)
headers
=
{
headers
=
{
"Content-Type"
:
content_type
,
'content-length'
:
str
(
len
(
body
))
'Content-Type'
:
content_type
,
'content-length'
:
str
(
len
(
body
))
}
}
with
self
.
assertRaises
(
HTTPError
):
with
self
.
assertRaises
(
HTTPError
):
yield
client
.
fetch
(
url
,
method
=
"POST"
,
headers
=
headers
,
body
=
body
)
yield
client
.
fetch
(
url
,
method
=
'POST'
,
headers
=
headers
,
body
=
body
)
@tornado.testing.gen_test
@tornado.testing.gen_test
def
test_app_with_correct_credentials_user_robey
(
self
):
def
test_app_with_correct_credentials_user_robey
(
self
):
...
@@ -193,7 +193,7 @@ class TestApp(AsyncHTTPTestCase):
...
@@ -193,7 +193,7 @@ class TestApp(AsyncHTTPTestCase):
response
=
yield
client
.
fetch
(
url
)
response
=
yield
client
.
fetch
(
url
)
self
.
assertEqual
(
response
.
code
,
200
)
self
.
assertEqual
(
response
.
code
,
200
)
response
=
yield
client
.
fetch
(
url
,
method
=
"POST"
,
body
=
self
.
body
)
response
=
yield
client
.
fetch
(
url
,
method
=
'POST'
,
body
=
self
.
body
)
data
=
json
.
loads
(
to_str
(
response
.
body
))
data
=
json
.
loads
(
to_str
(
response
.
body
))
self
.
assertIsNone
(
data
[
'status'
])
self
.
assertIsNone
(
data
[
'status'
])
self
.
assertIsNotNone
(
data
[
'id'
])
self
.
assertIsNotNone
(
data
[
'id'
])
...
@@ -214,7 +214,7 @@ class TestApp(AsyncHTTPTestCase):
...
@@ -214,7 +214,7 @@ class TestApp(AsyncHTTPTestCase):
self
.
assertEqual
(
response
.
code
,
200
)
self
.
assertEqual
(
response
.
code
,
200
)
body
=
self
.
body
.
replace
(
'robey'
,
'bar'
)
body
=
self
.
body
.
replace
(
'robey'
,
'bar'
)
response
=
yield
client
.
fetch
(
url
,
method
=
"POST"
,
body
=
body
)
response
=
yield
client
.
fetch
(
url
,
method
=
'POST'
,
body
=
body
)
data
=
json
.
loads
(
to_str
(
response
.
body
))
data
=
json
.
loads
(
to_str
(
response
.
body
))
self
.
assertIsNone
(
data
[
'status'
])
self
.
assertIsNone
(
data
[
'status'
])
self
.
assertIsNotNone
(
data
[
'id'
])
self
.
assertIsNotNone
(
data
[
'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