Skip to content

Commit

Permalink
Added configuration file tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
sdlime committed Feb 16, 2022
1 parent ee952f8 commit b16ac2a
Show file tree
Hide file tree
Showing 22 changed files with 175 additions and 0 deletions.
Empty file added msautotest/config/empty1.conf
Empty file.
2 changes: 2 additions & 0 deletions msautotest/config/empty2.conf
@@ -0,0 +1,2 @@
CONFIG
END
6 changes: 6 additions & 0 deletions msautotest/config/expected/empty1_conf.txt
@@ -0,0 +1,6 @@
Content-Type: text/html

<HTML>
<HEAD><TITLE>MapServer Message</TITLE></HEAD><BODY BGCOLOR="#FFFFFF">
msLoadConfig(): Unknown identifier. First token must be CONFIG, this doesn&#39;t look like a mapserver config file.
</BODY></HTML>
6 changes: 6 additions & 0 deletions msautotest/config/expected/empty2_conf.txt
@@ -0,0 +1,6 @@
Content-Type: text/html

<HTML>
<HEAD><TITLE>MapServer Message</TITLE></HEAD><BODY BGCOLOR="#FFFFFF">
msCGILoadMap(): Web application error. CGI variable &quot;map&quot; fails to validate.
</BODY></HTML>
Binary file added msautotest/config/expected/hello_world.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions msautotest/config/expected/invalid1_conf.txt
@@ -0,0 +1,6 @@
Content-Type: text/html

<HTML>
<HEAD><TITLE>MapServer Message</TITLE></HEAD><BODY BGCOLOR="#FFFFFF">
msLoadConfig(): Unknown identifier. Parsing error near (INVALID):(line 2)
</BODY></HTML>
6 changes: 6 additions & 0 deletions msautotest/config/expected/invalid2_conf.txt
@@ -0,0 +1,6 @@
Content-Type: text/html

<HTML>
<HEAD><TITLE>MapServer Message</TITLE></HEAD><BODY BGCOLOR="#FFFFFF">
msLoadConfig(): Premature End-of-File.
</BODY></HTML>
6 changes: 6 additions & 0 deletions msautotest/config/expected/missing_conf.txt
@@ -0,0 +1,6 @@
Content-Type: text/html

<HTML>
<HEAD><TITLE>MapServer Message</TITLE></HEAD><BODY BGCOLOR="#FFFFFF">
msLoadConfig(): Unable to access file. See mapserver.org/config_file.html for more information.
</BODY></HTML>
6 changes: 6 additions & 0 deletions msautotest/config/expected/ms_map_no_path1_conf.txt
@@ -0,0 +1,6 @@
Content-Type: text/html

<HTML>
<HEAD><TITLE>MapServer Message</TITLE></HEAD><BODY BGCOLOR="#FFFFFF">
msCGILoadMap(): Web application error. CGI variable &quot;map&quot; not found in configuration and this server is not configured for full paths.
</BODY></HTML>
6 changes: 6 additions & 0 deletions msautotest/config/expected/ms_map_no_path2_conf_failure1.txt
@@ -0,0 +1,6 @@
Content-Type: text/html

<HTML>
<HEAD><TITLE>MapServer Message</TITLE></HEAD><BODY BGCOLOR="#FFFFFF">
msCGILoadMap(): Web application error. CGI variable &quot;map&quot; not found in configuration and this server is not configured for full paths.
</BODY></HTML>
6 changes: 6 additions & 0 deletions msautotest/config/expected/ms_map_no_path2_conf_failure2.txt
@@ -0,0 +1,6 @@
Content-Type: text/html

<HTML>
<HEAD><TITLE>MapServer Message</TITLE></HEAD><BODY BGCOLOR="#FFFFFF">
msCGILoadMap(): Web application error. CGI variable &quot;map&quot; not found in configuration and this server is not configured for full paths.
</BODY></HTML>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions msautotest/config/expected/ms_map_pattern_conf.txt
@@ -0,0 +1,6 @@
Content-Type: text/html

<HTML>
<HEAD><TITLE>MapServer Message</TITLE></HEAD><BODY BGCOLOR="#FFFFFF">
msCGILoadMap(): Web application error. CGI variable &quot;map&quot; fails to validate.
</BODY></HTML>
7 changes: 7 additions & 0 deletions msautotest/config/expected/ms_map_pattern_conf_bad_regex.txt
@@ -0,0 +1,7 @@
Content-Type: text/html

<HTML>
<HEAD><TITLE>MapServer Message</TITLE></HEAD><BODY BGCOLOR="#FFFFFF">
msCGILoadMap(): Web application error. CGI variable &quot;map&quot; fails to validate.
msEvalRegex(): Regular expression error. Failed to compile expression ([A-Z*).
</BODY></HTML>
34 changes: 34 additions & 0 deletions msautotest/config/hello_world.map
@@ -0,0 +1,34 @@
# RUN_PARMS: hello_world.png [MAPSERV] QUERY_STRING="map=[MAPFILE]&mode=map" > [RESULT_DEMIME]
# RUN_PARMS: missing_conf.txt [MAPSERV] -conf missing.conf QUERY_STRING="map=[MAPFILE]&mode=map" > [RESULT_DEVERSION]
# RUN_PARMS: empty1_conf.txt [MAPSERV] -conf empty1.conf QUERY_STRING="map=[MAPFILE]&mode=map" > [RESULT_DEVERSION]
# RUN_PARMS: empty2_conf.txt [MAPSERV] -conf empty2.conf QUERY_STRING="map=[MAPFILE]&mode=map" > [RESULT_DEVERSION]
# RUN_PARMS: invalid1_conf.txt [MAPSERV] -conf invalid1.conf QUERY_STRING="map=[MAPFILE]&mode=map" > [RESULT_DEVERSION]
# RUN_PARMS: invalid2_conf.txt [MAPSERV] -conf invalid2.conf QUERY_STRING="map=[MAPFILE]&mode=map" > [RESULT_DEVERSION]
# RUN_PARMS: ms_map_no_path1_conf.txt [MAPSERV] -conf ms_map_no_path1.conf QUERY_STRING="map=[MAPFILE]&mode=map" > [RESULT_DEVERSION]
# RUN_PARMS: ms_map_no_path2_conf_success.png [MAPSERV] -conf ms_map_no_path2.conf QUERY_STRING="map=HELLO_WORLD&mode=map" > [RESULT_DEMIME]
# RUN_PARMS: ms_map_no_path2_conf_failure1.txt [MAPSERV] -conf ms_map_no_path2.conf QUERY_STRING="map=invalid&mode=map" > [RESULT_DEVERSION]
# RUN_PARMS: ms_map_no_path2_conf_failure2.txt [MAPSERV] -conf ms_map_no_path2.conf QUERY_STRING="map=[MAPFILE]&mode=map" > [RESULT_DEVERSION]
# RUN_PARMS: ms_map_pattern_conf.txt [MAPSERV] -conf ms_map_pattern.conf QUERY_STRING="map=[MAPFILE]&mode=map" > [RESULT_DEVERSION]
# RUN_PARMS: ms_map_pattern_conf_bad_regex.txt [MAPSERV] -conf ms_map_pattern_bad_regex.conf QUERY_STRING="map=[MAPFILE]&mode=map" > [RESULT_DEVERSION]

MAP
NAME 'hello_world'
EXTENT 1 1 100 100
SIZE 300 300

LAYER
NAME 'hello_world'
STATUS DEFAULT
TYPE POINT
FEATURE
POINTS 50 50 END
END
CLASS
TEXT 'Hello World!'
LABEL
SIZE MEDIUM
COLOR 0 0 0
END
END
END
END
4 changes: 4 additions & 0 deletions msautotest/config/invalid1.conf
@@ -0,0 +1,4 @@
CONFIG
INVALID
END
END
3 changes: 3 additions & 0 deletions msautotest/config/invalid2.conf
@@ -0,0 +1,3 @@
CONFIG
ENV
END
5 changes: 5 additions & 0 deletions msautotest/config/ms_map_no_path1.conf
@@ -0,0 +1,5 @@
CONFIG
ENV
MS_MAP_NO_PATH "1"
END
END
8 changes: 8 additions & 0 deletions msautotest/config/ms_map_no_path2.conf
@@ -0,0 +1,8 @@
CONFIG
ENV
MS_MAP_NO_PATH "1"
END
MAPS
"HELLO_WORLD" "hello_world.map"
END
END
5 changes: 5 additions & 0 deletions msautotest/config/ms_map_pattern.conf
@@ -0,0 +1,5 @@
CONFIG
ENV
MS_MAP_PATTERN "^/opt/mapserver"
END
END
5 changes: 5 additions & 0 deletions msautotest/config/ms_map_pattern_bad_regex.conf
@@ -0,0 +1,5 @@
CONFIG
ENV
MS_MAP_PATTERN "[A-Z*"
END
END
48 changes: 48 additions & 0 deletions msautotest/config/run_test.py
@@ -0,0 +1,48 @@
#!/usr/bin/env python
###############################################################################
# $Id$
#
# Project: MapServer
# Purpose: Test harnass script for MapServer autotest.
# Author: Frank Warmerdam, warmerdam@pobox.com
#
###############################################################################
# Copyright (c) 2002, Frank Warmerdam <warmerdam@pobox.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
###############################################################################

import os
import pytest
import sys

sys.path.append( '../pymod' )

import mstestlib

@pytest.mark.parametrize('map,out_file,command', mstestlib.get_pytests(os.path.dirname(os.path.abspath(__file__))))
def test(map, out_file, command, extra_args):
mstestlib.run_pytest(map, out_file, command, extra_args)


###############################################################################
# main()

if __name__ == '__main__':
sys.exit(mstestlib.pytest_main())

0 comments on commit b16ac2a

Please sign in to comment.