Skip to content
Snippets Groups Projects
Commit 9461376b authored by slobinger's avatar slobinger
Browse files

Merge branch '27-proxy-registration-for-all-methods' into 'master'

Resolve "Proxy muss alle HTTP-Methoden unterstützen"

Closes #27

See merge request !19
parents 95ede555 ef9106aa
Branches
No related tags found
1 merge request!19Resolve "Proxy muss alle HTTP-Methoden unterstützen"
Pipeline #
python3-sams-classes (1.0.2) unstable; urgency=medium
* fixed issue #27 "Proxy muss alle HTTP-Methoden unterstützen"
-- Lobinger <slobinger@justus.zib.de> Mon, 19 Jun 2017 16:42:21 +0200
python3-sams-classes (1.0.1) unstable; urgency=medium python3-sams-classes (1.0.1) unstable; urgency=medium
* fixed issue #20 "Basis-Pfad (/) bei API über Proxy nicht aufrufbar" * fixed issue #20 "Basis-Pfad (/) bei API über Proxy nicht aufrufbar"
......
...@@ -57,11 +57,15 @@ class SAMSApp: ...@@ -57,11 +57,15 @@ class SAMSApp:
self.__blueprint.add_url_rule( self.__blueprint.add_url_rule(
rule = self._generate_url(urlPart = proxy.urlRule), rule = self._generate_url(urlPart = proxy.urlRule),
endpoint = self.__blueprint.name.replace('.', '_') + '_proxy_' + str(i), endpoint = self.__blueprint.name.replace('.', '_') + '_proxy_' + str(i),
view_func = proxy.proxy) view_func = proxy.proxy,
methods = ['GET', 'POST', 'DELETE', 'UPDATE','PATCH', 'OPTIONS', 'PUT',
'HEAD'])
self.__blueprint.add_url_rule( self.__blueprint.add_url_rule(
rule = self._generate_url(urlPart = proxy.rootUrlRule), rule = self._generate_url(urlPart = proxy.rootUrlRule),
endpoint = self.__blueprint.name.replace('.', '_') + '_proxy_' + str(i), endpoint = self.__blueprint.name.replace('.', '_') + '_proxy_' + str(i),
view_func = proxy.proxy) view_func = proxy.proxy,
methods = ['GET', 'POST', 'DELETE', 'UPDATE','PATCH', 'OPTIONS', 'PUT',
'HEAD'])
i += 1 i += 1
@staticmethod @staticmethod
......
__version__ = '1.0.0' __version__ = '1.0.2'
\ No newline at end of file \ No newline at end of file
...@@ -239,12 +239,20 @@ class TestSAMSAppWithThreadedApi(unittest.TestCase): ...@@ -239,12 +239,20 @@ class TestSAMSAppWithThreadedApi(unittest.TestCase):
} }
) )
self.flaskApp.register_blueprint(testApp.blueprint) self.flaskApp.register_blueprint(testApp.blueprint)
self.assertGreater(len(list(self.flaskApp.url_map.iter_rules())), 1) thApp = FlaskInThread(self.flaskApp, host="localhost", port=5000)
thApp.start()
time.sleep(0.01)
with self.subTest('test flask url_map'):
self.assertGreater(len(list(self.flaskApp.url_map.iter_rules())), 1)
for path in ('/api/hello', '/api/'): for path in ('/api/hello', '/api/'):
with self.subTest(path): for method in ( 'GET', 'POST', 'DELETE', 'UPDATE', 'PATCH', 'OPTIONS',
with self.flaskApp.test_client(self) as client: 'PUT', 'HEAD'):
response = client.get(path) with self.subTest('test path ' + path + ' method ' + method):
response = requests.request(method = method,
url = 'http://localhost:5000' + path)
self.assertIs(response.status_code, 200) self.assertIs(response.status_code, 200)
requests.get('http://localhost:5000/shutdown')
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment