Compare commits
No commits in common. "c9b120823632bff5be0dd4410c92e44c173307eb" and "76a8369434753f07e160c118836431be6d725abf" have entirely different histories.
c9b1208236
...
76a8369434
2 changed files with 2 additions and 38 deletions
20
app.py
20
app.py
|
@ -68,27 +68,11 @@ class Oas3Handler(tornado.web.RequestHandler, metaclass=ABCMeta):
|
||||||
self.finish()
|
self.finish()
|
||||||
|
|
||||||
|
|
||||||
class ValidateHandler(tornado.web.RequestHandler, metaclass=ABCMeta):
|
def make_app(_auth_provider=None):
|
||||||
def post(self):
|
|
||||||
self.set_header("Content-Type", "application/json")
|
|
||||||
|
|
||||||
entity = self.request.body.decode()
|
|
||||||
|
|
||||||
# TODO call validator
|
|
||||||
validation_result = {
|
|
||||||
"valid": "true"
|
|
||||||
}
|
|
||||||
|
|
||||||
self.write(validation_result)
|
|
||||||
self.finish()
|
|
||||||
|
|
||||||
|
|
||||||
def make_app():
|
|
||||||
version_path = r"/v[0-9]"
|
version_path = r"/v[0-9]"
|
||||||
return tornado.web.Application([
|
return tornado.web.Application([
|
||||||
(version_path + r"/health", HealthHandler),
|
(version_path + r"/health", HealthHandler),
|
||||||
(version_path + r"/oas3", Oas3Handler),
|
(version_path + r"/oas3", Oas3Handler),
|
||||||
(version_path + r"/validate", ValidateHandler),
|
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
@ -97,7 +81,7 @@ def main():
|
||||||
|
|
||||||
# Setup
|
# Setup
|
||||||
|
|
||||||
util.run_tornado_server(make_app(),
|
util.run_tornado_server(make_app(auth_provider),
|
||||||
server_port=port)
|
server_port=port)
|
||||||
|
|
||||||
# Teardown
|
# Teardown
|
||||||
|
|
20
test.py
20
test.py
|
@ -38,25 +38,5 @@ class TestBaseAPI(tornado.testing.AsyncHTTPTestCase):
|
||||||
self.assertEqual(response.body.decode(), oas3f.read(), "OAS3 content differs from spec file!")
|
self.assertEqual(response.body.decode(), oas3f.read(), "OAS3 content differs from spec file!")
|
||||||
|
|
||||||
|
|
||||||
class TestValidation(tornado.testing.AsyncHTTPTestCase):
|
|
||||||
"""Validation test cases"""
|
|
||||||
def get_app(self):
|
|
||||||
return make_app()
|
|
||||||
|
|
||||||
def test_null_validation(self):
|
|
||||||
entity = {}
|
|
||||||
|
|
||||||
response = self.fetch('/v0/validate',
|
|
||||||
method='POST',
|
|
||||||
body=json.dumps(entity))
|
|
||||||
|
|
||||||
self.assertEqual(200, response.code, "Validation must always return 200")
|
|
||||||
|
|
||||||
validation_result = json.loads(response.body.decode())
|
|
||||||
|
|
||||||
self.assertIn('valid', validation_result, "Key 'valid' expected in validation result")
|
|
||||||
self.assertTrue(validation_result['valid'], "Validation result is expected to be valid==true")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in a new issue