Skip to content

Commit

Permalink
Merge pull request #175 from camptocamp/backport/172-to-7.4
Browse files Browse the repository at this point in the history
[Backport 7.4] Fix dash in MS_MAP_PATTERN
  • Loading branch information
sbrunner authored Jun 4, 2021
2 parents 0485140 + 36a14a5 commit 7d97073
Show file tree
Hide file tree
Showing 8 changed files with 272 additions and 21 deletions.
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,8 @@ build: build-server

.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/ server/build server/target
8 changes: 4 additions & 4 deletions acceptance_tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM camptocamp/c2cwsgiutils:3

COPY . /acceptance_tests/

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
121 changes: 121 additions & 0 deletions acceptance_tests/config/mapserver/AZ_az-0.9.map
Original file line number Diff line number Diff line change
@@ -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
121 changes: 121 additions & 0 deletions acceptance_tests/config/mapserver/AZ_az-0.9/AZ_az-0.9.map
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion acceptance_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
10 changes: 1 addition & 9 deletions acceptance_tests/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: .
20 changes: 19 additions & 1 deletion acceptance_tests/test_map.py
Original file line number Diff line number Diff line change
@@ -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"]
2 changes: 1 addition & 1 deletion server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,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-get update && \
apt-get install --assume-yes --no-install-recommends ca-certificates apache2 libapache2-mod-fcgid curl \
Expand Down

0 comments on commit 7d97073

Please sign in to comment.