From 3a740231deab2abf335d5cad9a80d466c783be7d Mon Sep 17 00:00:00 2001 From: Andrei Paplauski Date: Mar 26 2020 09:54:46 +0000 Subject: [PATCH 1/3] Add version requirements for Flask to deal with redirections problem Flask v1.0.3 fixed this bug https://github.com/pallets/flask/issues/2984. Resolves: FACTORY-5859 --- diff --git a/requirements.txt b/requirements.txt index 0c9cb18..e3451e5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ pdc-client pyOpenSSL python-fedora sqlalchemy -Flask +Flask>=1.0.3 Flask-Migrate Flask-SQLAlchemy Flask-Login From dd3b09de212197567285e99d10e069153583a3dd Mon Sep 17 00:00:00 2001 From: Andrei Paplauski Date: Mar 26 2020 09:56:33 +0000 Subject: [PATCH 2/3] Add test to test redirections works fine with and without trailing slash --- diff --git a/tests/test_views.py b/tests/test_views.py index 4e8e838..d5f03b1 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -589,6 +589,15 @@ class TestViews(helpers.ModelsTestCase): self.assertEqual(data['depends_on_events'], [event1.id]) self.assertEqual(data['depending_events'], []) + def test_trailing_slash(self): + urls = ('/api/2/builds', '/api/2/events') + for url in urls: + response = self.client.get(url, follow_redirects=True) + self.assertEqual(response.status_code, 200) + url = url + '/' + response = self.client.get(url, follow_redirects=True) + self.assertEqual(response.status_code, 200) + class TestViewsMultipleFilterValues(helpers.ModelsTestCase): def setUp(self): From 76ae710b3e6a7726f3d3412587a402721e032c00 Mon Sep 17 00:00:00 2001 From: Andrei Paplauski Date: Mar 27 2020 11:24:08 +0000 Subject: [PATCH 3/3] Remove code repetition from test --- diff --git a/tests/test_views.py b/tests/test_views.py index d5f03b1..8187dfb 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -590,13 +590,11 @@ class TestViews(helpers.ModelsTestCase): self.assertEqual(data['depending_events'], []) def test_trailing_slash(self): - urls = ('/api/2/builds', '/api/2/events') + urls = ('/api/2/builds', '/api/2/builds/', + '/api/2/events', '/api/2/events/') for url in urls: response = self.client.get(url, follow_redirects=True) self.assertEqual(response.status_code, 200) - url = url + '/' - response = self.client.get(url, follow_redirects=True) - self.assertEqual(response.status_code, 200) class TestViewsMultipleFilterValues(helpers.ModelsTestCase):