Skip to content

Commit eb3e8ed

Browse files
committed
server access control test: replace hardcoded temporary directory
1 parent 00715a6 commit eb3e8ed

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/server/qgsserver.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ QString QgsServer::configPath( const QString& defaultConfigPath, const QMap<QStr
268268
if ( !projectFile.isEmpty() )
269269
{
270270
cfPath = projectFile;
271+
QgsDebugMsg( QString( "QGIS_PROJECT_FILE:%1" ).arg( cfPath ) );
271272
}
272273
else
273274
{
@@ -279,6 +280,7 @@ QString QgsServer::configPath( const QString& defaultConfigPath, const QMap<QStr
279280
else
280281
{
281282
cfPath = paramIt.value();
283+
QgsDebugMsg( QString( "MAP:%1" ).arg( cfPath ) );
282284
}
283285
}
284286
return cfPath;
@@ -357,7 +359,7 @@ bool QgsServer::init( int & argc, char ** argv )
357359
QgsMessageLog::logMessage( "PkgData PATH: " + QgsApplication::pkgDataPath(), "Server", QgsMessageLog::INFO );
358360
QgsMessageLog::logMessage( "User DB PATH: " + QgsApplication::qgisUserDbFilePath(), "Server", QgsMessageLog::INFO );
359361
QgsMessageLog::logMessage( "Auth DB PATH: " + QgsApplication::qgisAuthDbFilePath(), "Server", QgsMessageLog::INFO );
360-
QgsMessageLog::logMessage( "SVG PATHS: " + QgsApplication::svgPaths().join( ":" ), "Server", QgsMessageLog::INFO );
362+
QgsMessageLog::logMessage( "SVG PATHS: " + QgsApplication::svgPaths().join( QDir::separator() ), "Server", QgsMessageLog::INFO );
361363

362364
QgsApplication::createDB(); //init qgis.db (e.g. necessary for user crs)
363365

tests/src/python/test_qgsserver_accesscontrol.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from osgeo.gdalconst import GA_ReadOnly
2323
from qgis.server import QgsServer, QgsAccessControlFilter
2424
from qgis.core import QgsRenderChecker
25+
import tempfile
2526

2627

2728
XML_NS = \
@@ -990,7 +991,7 @@ def _post_restricted(self, data, query_string=None):
990991
return result
991992

992993
def _img_diff(self, image, control_image, max_diff):
993-
temp_image = "/tmp/%s_result.png" % control_image
994+
temp_image = path.join(tempfile.gettempdir(), "%s_result.png" % control_image)
994995
with open(temp_image, "w") as f:
995996
f.write(image)
996997

@@ -1006,23 +1007,23 @@ def _img_diff_error(self, response, headers, image, max_diff=10):
10061007
"Content type is wrong: %s" % headers.get("Content-Type"))
10071008
test, report = self._img_diff(response, image, max_diff)
10081009

1009-
result_img = check_output(["base64", "/tmp/" + image + "_result.png"])
1010-
message = "Image is wrong\n%s\nImage:\necho '%s' | base64 -d > /tmp/%s_result.png" % (
1011-
report, result_img.strip(), image
1010+
result_img = check_output(["base64", path.join(tempfile.gettempdir(), image + "_result.png")])
1011+
message = "Image is wrong\n%s\nImage:\necho '%s' | base64 -d >%s/%s_result.png" % (
1012+
report, result_img.strip(), tempfile.gettempdir(), image
10121013
)
10131014

1014-
if path.isfile("/tmp/" + image + "_result_diff.png"):
1015-
diff_img = check_output(["base64", "/tmp/" + image + "_result_diff.png"])
1016-
message += "\nDiff:\necho '%s' | base64 -d > /tmp/%s_result_diff.png" % (
1017-
diff_img.strip(), image
1015+
if path.isfile(path.join(tempfile.gettempdir(), image + "_result_diff.png")):
1016+
diff_img = check_output(["base64", path.join(tempfile.gettempdir(), image + "_result_diff.png")])
1017+
message += "\nDiff:\necho '%s' | base64 -d > %s/%s_result_diff.png" % (
1018+
diff_img.strip(), tempfile.gettempdir(), image
10181019
)
10191020
self.assertTrue(test, message)
10201021

10211022
def _geo_img_diff(self, image_1, image_2):
10221023

1023-
with open("/tmp/" + image_2, "w") as f:
1024+
with open(path.join(tempfile.gettempdir(), image_2), "w") as f:
10241025
f.write(image_1)
1025-
image_1 = gdal.Open("/tmp/" + image_2, GA_ReadOnly)
1026+
image_1 = gdal.Open(path.join(tempfile.gettempdir(), image_2), GA_ReadOnly)
10261027

10271028
image_2 = gdal.Open(self.testdata_path + "/results/" + image_2, GA_ReadOnly)
10281029

0 commit comments

Comments
 (0)