Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Additional tests for QGIS_SERVER_LANDING_PAGE_PREFIX redirects
Related to #41354
  • Loading branch information
elpaso committed Jul 14, 2021
1 parent 298a451 commit af45eb0
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/src/python/test_qgsserver_landingpage.py
Expand Up @@ -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/')
Expand Down Expand Up @@ -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 af45eb0

Please sign in to comment.