diff --git a/Dockerfile b/Dockerfile index e62d1f51..9438ad6b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -77,7 +77,7 @@ ENV APACHE_CONFDIR=/etc/apache2 \ LANG=C \ TERM=linux \ MS_MAPFILE=/etc/mapserver/mapserver.map \ - MS_MAP_PATTERN=^\\/etc\\/mapserver\\/([^\\.][_A-Za-z0-9\\-\\.]+\\/{1})*([_A-Za-z0-9\\-\\.]+\\.map)$ + MS_MAP_PATTERN=^\\/etc\\/mapserver\\/([^\\.][-_A-Za-z0-9\\.]+\\/{1})*([-_A-Za-z0-9\\.]+\\.map)$ RUN apt update && \ apt upgrade --assume-yes && \ diff --git a/Makefile b/Makefile index 2e680048..cff6b88c 100644 --- a/Makefile +++ b/Makefile @@ -19,10 +19,8 @@ build: .PHONY: acceptance acceptance: build + (cd acceptance_tests/ && docker-compose down) + (cd acceptance_tests/ && docker-compose build) (cd acceptance_tests/ && docker-compose up -d) - (cd acceptance_tests/ && docker-compose exec -T acceptance bash -c 'cd /acceptance_tests ; py.test -vv --color=yes --junitxml /tmp/junitxml/results.xml') + (cd acceptance_tests/ && docker-compose exec -T acceptance py.test -vv --color=yes --junitxml /tmp/junitxml/results.xml) (cd acceptance_tests/ && docker-compose down) - -.PHONY: clean -clean: - rm -rf acceptance_tests/junitxml/ diff --git a/acceptance_tests/Dockerfile b/acceptance_tests/Dockerfile index da621e48..135ac54c 100644 --- a/acceptance_tests/Dockerfile +++ b/acceptance_tests/Dockerfile @@ -1,8 +1,8 @@ -FROM camptocamp/c2cwsgiutils:5 - -COPY . /acceptance_tests/ +FROM camptocamp/c2cwsgiutils:3 WORKDIR /acceptance_tests +COPY . ./ + +CMD ["tail", "-f", "/dev/null"] -CMD tail -f /dev/null -CMD py.test -vv --color=yes --junitxml /tmp/junitxml/results.xml +ENV C2C_REQUESTS_DEFAULT_TIMEOUT=10 diff --git a/acceptance_tests/config/mapserver/AZ_az-0.9.map b/acceptance_tests/config/mapserver/AZ_az-0.9.map new file mode 100644 index 00000000..ed7b1bd5 --- /dev/null +++ b/acceptance_tests/config/mapserver/AZ_az-0.9.map @@ -0,0 +1,121 @@ +MAP + NAME "test" + + EXTENT -180 -90 180 90 + UNITS METERS + + # RESOLUTION and DEFRESOLUTION default to 96. If you + # change RESOLUTION to some other value, also change + # DEFRESOLUTION. See + # http://mapserver.org/development/rfc/ms-rfc-55.html + RESOLUTION 96 ## Also set in Openlayers especially for legends + DEFRESOLUTION 96 + + # MAXSIZE shouldn't be less than 5000 for MF print on A3 + MAXSIZE 5000 + + SHAPEPATH '/var/sig/c2cgeoportal' + + IMAGECOLOR 255 255 255 + STATUS ON + + #FONTSET "fonts.conf" + #SYMBOLSET "symbol.sym" + + OUTPUTFORMAT + NAME jpeg + DRIVER "AGG/JPEG" + MIMETYPE "image/jpeg" + IMAGEMODE RGB + EXTENSION "jpeg" + FORMATOPTION "QUALITY=75,PROGRESSIVE=TRUE" + END + + OUTPUTFORMAT + NAME png + DRIVER AGG/PNG + MIMETYPE "image/png" + IMAGEMODE RGBA + EXTENSION "png" + FORMATOPTION "INTERLACE=OFF" + FORMATOPTION "QUANTIZE_DITHER=OFF" + FORMATOPTION "QUANTIZE_FORCE=ON" + FORMATOPTION "QUANTIZE_COLORS=256" + END + + OUTPUTFORMAT + NAME "geojson" + DRIVER "OGR/GEOJSON" + MIMETYPE "application/json; subtype=geojson; charset=utf-8" + FORMATOPTION "STORAGE=stream" + FORMATOPTION "FORM=SIMPLE" + END + + PROJECTION + "init=epsg:4326" + END + + WEB + METADATA + "wms_title" "test" + "wms_abstract" "MapServer Docker test" + #"wms_onlineresource" "http://mapserver//mapserv" + "wms_srs" "EPSG:4326" + "wms_encoding" "UTF-8" + "wms_enable_request" "*" + "wfs_enable_request" "!*" + "wfs_encoding" "UTF-8" + "wfs_getfeature_formatlist" "gml,geojson" + END + END + + LEGEND + LABEL + ENCODING "UTF-8" + TYPE TRUETYPE + FONT "Arial" + SIZE 9 + END + END + + LAYER + NAME "polygons" + TYPE POLYGON + TEMPLATE fooOnlyForWMSGetFeatureInfo # For GetFeatureInfo + EXTENT -180 -90 180 90 + CONNECTIONTYPE postgis + PROCESSING "CLOSE_CONNECTION=DEFER" # For performance + CONNECTION "user=www-data password=www-data dbname=test host=db" + DATA "geom FROM (SELECT * FROM polygons) AS foo USING unique name USING srid=4326" + METADATA + "wms_title" "polygons" # For WMS + "wms_srs" "EPSG:4326" # For WMS + + "wfs_enable_request" "*" # Enable WFS for this layer + "gml_include_items" "all" # For GetFeatureInfo and WFS GetFeature (QueryBuilder) + "ows_geom_type" "Polygon" # For returning geometries in GetFeatureInfo + "ows_geometries" "geom" # For returning geometries in GetFeatureInfo + "wfs_featureid" "name" + + "wms_metadataurl_href" "http://www.example.com/bar" # For metadata URL + "wms_metadataurl_format" "text/html" # For metadata URL + "wms_metadataurl_type" "TC211" # For metadata URL + END + STATUS ON + PROJECTION + "init=epsg:4326" + END + CLASS + NAME "polygon" + STYLE + OUTLINECOLOR 255 0 0 + WIDTH 2 + END + STYLE + COLOR 255 0 0 + OPACITY 40 + END + END + END + +END diff --git a/acceptance_tests/config/mapserver/AZ_az-0.9/AZ_az-0.9.map b/acceptance_tests/config/mapserver/AZ_az-0.9/AZ_az-0.9.map new file mode 100644 index 00000000..ed7b1bd5 --- /dev/null +++ b/acceptance_tests/config/mapserver/AZ_az-0.9/AZ_az-0.9.map @@ -0,0 +1,121 @@ +MAP + NAME "test" + + EXTENT -180 -90 180 90 + UNITS METERS + + # RESOLUTION and DEFRESOLUTION default to 96. If you + # change RESOLUTION to some other value, also change + # DEFRESOLUTION. See + # http://mapserver.org/development/rfc/ms-rfc-55.html + RESOLUTION 96 ## Also set in Openlayers especially for legends + DEFRESOLUTION 96 + + # MAXSIZE shouldn't be less than 5000 for MF print on A3 + MAXSIZE 5000 + + SHAPEPATH '/var/sig/c2cgeoportal' + + IMAGECOLOR 255 255 255 + STATUS ON + + #FONTSET "fonts.conf" + #SYMBOLSET "symbol.sym" + + OUTPUTFORMAT + NAME jpeg + DRIVER "AGG/JPEG" + MIMETYPE "image/jpeg" + IMAGEMODE RGB + EXTENSION "jpeg" + FORMATOPTION "QUALITY=75,PROGRESSIVE=TRUE" + END + + OUTPUTFORMAT + NAME png + DRIVER AGG/PNG + MIMETYPE "image/png" + IMAGEMODE RGBA + EXTENSION "png" + FORMATOPTION "INTERLACE=OFF" + FORMATOPTION "QUANTIZE_DITHER=OFF" + FORMATOPTION "QUANTIZE_FORCE=ON" + FORMATOPTION "QUANTIZE_COLORS=256" + END + + OUTPUTFORMAT + NAME "geojson" + DRIVER "OGR/GEOJSON" + MIMETYPE "application/json; subtype=geojson; charset=utf-8" + FORMATOPTION "STORAGE=stream" + FORMATOPTION "FORM=SIMPLE" + END + + PROJECTION + "init=epsg:4326" + END + + WEB + METADATA + "wms_title" "test" + "wms_abstract" "MapServer Docker test" + #"wms_onlineresource" "http://mapserver//mapserv" + "wms_srs" "EPSG:4326" + "wms_encoding" "UTF-8" + "wms_enable_request" "*" + "wfs_enable_request" "!*" + "wfs_encoding" "UTF-8" + "wfs_getfeature_formatlist" "gml,geojson" + END + END + + LEGEND + LABEL + ENCODING "UTF-8" + TYPE TRUETYPE + FONT "Arial" + SIZE 9 + END + END + + LAYER + NAME "polygons" + TYPE POLYGON + TEMPLATE fooOnlyForWMSGetFeatureInfo # For GetFeatureInfo + EXTENT -180 -90 180 90 + CONNECTIONTYPE postgis + PROCESSING "CLOSE_CONNECTION=DEFER" # For performance + CONNECTION "user=www-data password=www-data dbname=test host=db" + DATA "geom FROM (SELECT * FROM polygons) AS foo USING unique name USING srid=4326" + METADATA + "wms_title" "polygons" # For WMS + "wms_srs" "EPSG:4326" # For WMS + + "wfs_enable_request" "*" # Enable WFS for this layer + "gml_include_items" "all" # For GetFeatureInfo and WFS GetFeature (QueryBuilder) + "ows_geom_type" "Polygon" # For returning geometries in GetFeatureInfo + "ows_geometries" "geom" # For returning geometries in GetFeatureInfo + "wfs_featureid" "name" + + "wms_metadataurl_href" "http://www.example.com/bar" # For metadata URL + "wms_metadataurl_format" "text/html" # For metadata URL + "wms_metadataurl_type" "TC211" # For metadata URL + END + STATUS ON + PROJECTION + "init=epsg:4326" + END + CLASS + NAME "polygon" + STYLE + OUTLINECOLOR 255 0 0 + WIDTH 2 + END + STYLE + COLOR 255 0 0 + OPACITY 40 + END + END + END + +END diff --git a/acceptance_tests/conftest.py b/acceptance_tests/conftest.py index 5a489437..9e11f7db 100644 --- a/acceptance_tests/conftest.py +++ b/acceptance_tests/conftest.py @@ -24,6 +24,7 @@ def connection_map(): Fixture that returns a connection to a running batch container. """ utils.wait_url( - BASE_URL_MAP + "?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&TYPENAME=polygons&featureId=xxx" + BASE_URL_MAP + + "?MAP=/etc/mapserver/mapserver.map&SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&TYPENAME=polygons&featureId=xxx" ) return Connection(BASE_URL_MAP, "http://localhost") diff --git a/acceptance_tests/docker-compose.yaml b/acceptance_tests/docker-compose.yaml index d9ae2eb3..44cb3f92 100644 --- a/acceptance_tests/docker-compose.yaml +++ b/acceptance_tests/docker-compose.yaml @@ -38,12 +38,4 @@ services: - ./config/db/:/docker-entrypoint-initdb.d acceptance: - image: camptocamp/c2cwsgiutils:3 - command: - - tail - - -f - - /dev/null - volumes: - - .:/acceptance_tests - environment: - C2C_REQUESTS_DEFAULT_TIMEOUT: '10' + build: . diff --git a/acceptance_tests/test_map.py b/acceptance_tests/test_map.py index c5933a0c..d807c404 100644 --- a/acceptance_tests/test_map.py +++ b/acceptance_tests/test_map.py @@ -1,7 +1,25 @@ -def test_get_capabilities(connection_map): +def test_get_std_map(connection_map): ns = "{http://www.opengis.net/wms}" answer = connection_map.get_xml( "?MAP=/etc/mapserver/mapserver.map&SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.3.0" ) assert [e.text for e in answer.findall("%sService/%sTitle" % (ns, ns))] == ["test"] assert [e.text for e in answer.findall(".//%sLayer/%sName" % (ns, ns))] == ["test", "polygons"] + + +def test_get_multi_char_map(connection_map): + ns = "{http://www.opengis.net/wms}" + answer = connection_map.get_xml( + "?MAP=/etc/mapserver/AZ_az-0.9.map&SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.3.0" + ) + assert [e.text for e in answer.findall("%sService/%sTitle" % (ns, ns))] == ["test"] + assert [e.text for e in answer.findall(".//%sLayer/%sName" % (ns, ns))] == ["test", "polygons"] + + +def test_get_folder_map(connection_map): + ns = "{http://www.opengis.net/wms}" + answer = connection_map.get_xml( + "?MAP=/etc/mapserver/AZ_az-0.9/AZ_az-0.9.map&SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.3.0" + ) + assert [e.text for e in answer.findall("%sService/%sTitle" % (ns, ns))] == ["test"] + assert [e.text for e in answer.findall(".//%sLayer/%sName" % (ns, ns))] == ["test", "polygons"]