Skip to content
Permalink
Browse files
Merge pull request #44158 from elpaso/server-landingpage-redirect-tests
Additional tests for QGIS_SERVER_LANDING_PAGE_PREFIX redirects
  • Loading branch information
elpaso committed Jul 15, 2021
2 parents bb35470 + af45eb0 commit 8f7ac82f9fdab6e4927877394872bda377d64bfa
Showing with 17 additions and 1 deletion.
  1. +17 −1 tests/src/python/test_qgsserver_landingpage.py
@@ -82,7 +82,7 @@ def setUp(self):
if not os.environ.get('TRAVIS', False):
os.environ['QGIS_SERVER_LANDING_PAGE_PROJECTS_PG_CONNECTIONS'] = "postgresql://localhost:5432?sslmode=disable&dbname=landing_page_test&schema=public"

def ___test_landing_page_redirects(self):
def test_landing_page_redirects(self):
"""Test landing page redirects"""

request = QgsBufferServerRequest('http://server.qgis.org/')
@@ -214,6 +214,22 @@ def _test_valid(uri):
_test_valid('http://server.qgis.org/mylanding/')
_test_valid('http://server.qgis.org/mylanding/index.json')

# Test redirects with prefix
os.environ['QGIS_SERVER_LANDING_PAGE_PREFIX'] = '/ows/catalog'
request = QgsBufferServerRequest('http://server.qgis.org/ows/catalog')
response = QgsBufferServerResponse()
request.setHeader('Accept', 'text/html')
self.server.handleRequest(request, response)
self.assertEqual(response.headers()[
'Location'], 'http://server.qgis.org/ows/catalog/index.html')

request = QgsBufferServerRequest('http://server.qgis.org/ows/catalog/')
response = QgsBufferServerResponse()
request.setHeader('Accept', 'text/html')
self.server.handleRequest(request, response)
self.assertEqual(response.headers()[
'Location'], 'http://server.qgis.org/ows/catalog/index.html')


if __name__ == '__main__':
unittest.main()

0 comments on commit 8f7ac82

Please sign in to comment.