]> git.openstreetmap.org Git - nominatim.git/commitdiff
fix syntax errors and update tests
authorSarah Hoffmann <lonvia@denofr.de>
Sun, 12 Jun 2016 20:33:37 +0000 (22:33 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Sun, 12 Jun 2016 20:51:13 +0000 (22:51 +0200)
Some of the tests with bad parameters now return a HTTP 400.

lib/Geocode.php
lib/template/details-error-html.php
lib/website.php
tests/features/api/reverse_simple.feature
tests/features/api/search_params.feature
tests/features/api/search_simple.feature
website/lookup.php
website/reverse.php

index aa65cb69faebc22bf37e8f899c761f9260e8f117..876a40b585692e9017f9cba2762d87ec97287575 100644 (file)
 
                        $sSQL .= " order by importance desc";
                        if (CONST_Debug) { echo "<hr>"; var_dump($sSQL); }
-                       $aSearchResults = chksql($this->oDB->getAll($sSQL);
+                       $aSearchResults = chksql($this->oDB->getAll($sSQL),
                                                 "Could not get details for place.");
 
                        return $aSearchResults;
                                $sViewboxCentreSQL .= ")'::geometry,4326)";
 
                                $sSQL = "select st_buffer(".$sViewboxCentreSQL.",".(float)($_GET['routewidth']/69).")";
-                               $this->sViewboxSmallSQL = chksql($this->oDB->getOne($sSQL);
+                               $this->sViewboxSmallSQL = chksql($this->oDB->getOne($sSQL),
                                                                 "Could not get small viewbox.");
                                $this->sViewboxSmallSQL = "'".$this->sViewboxSmallSQL."'::geometry";
 
                                                                        $sSQL .= " limit ".$this->iLimit;
 
                                                                if (CONST_Debug) { var_dump($sSQL); }
-                                                               $aViewBoxPlaceIDs = chksql($this->oDB->getAll($sSQL));
+                                                               $aViewBoxPlaceIDs = chksql($this->oDB->getAll($sSQL),
                                                                                           "Could not get places for search terms.");
-                                                               }
                                                                //var_dump($aViewBoxPlaceIDs);
                                                                // Did we have an viewbox matches?
                                                                $aPlaceIDs = array();
 
                                                }
 
-                                               if (PEAR::IsError($aPlaceIDs))
-                                               {
-                                                       failInternalError("Could not get place IDs from tokens." ,$sSQL, $aPlaceIDs);
-                                               }
-
                                                if (CONST_Debug) { echo "<br><b>Place IDs:</b> "; var_Dump($aPlaceIDs); }
 
                                                foreach($aPlaceIDs as $iPlaceID)
index f93cca4d6917240147c98598a8567ce9c29e2abe..bc00f84d6e97d88639722850bfd68ce5e561fa17 100644 (file)
@@ -11,9 +11,6 @@
 
        function osmMapUrl($aFeature)
        {
-               $sLon = $aFeature['error_x'];
-               $sLat = $aFeature['error_y'];
-
                if (isset($sFeature['error_x']) && isset($sFeature['error_y']))
                {
                        $sBaseUrl = '//www.openstreetmap.org/';
@@ -23,8 +20,7 @@
                                $sBaseUrl += $sOSMType.'/'.$aFeature['osm_id'];
                        }
 
-                               return '<a href="'.$sBaseUrl.'?mlat='.$sLat.'&mlon='.$sLon.'">view on osm.org</a>';
-                       }
+                       return '<a href="'.$sBaseUrl.'?mlat='.$aFeature['error_y'].'&mlon='.$aFeature['error_x'].'">view on osm.org</a>';
                }
                return '';
        }
index 22ec08f10ed999bc6c069d402b5fb1bb0ee776d2..23cec940c0a9e882a84287aa2fb37fa4da8f7e09 100644 (file)
@@ -100,7 +100,7 @@ INTERNALFAIL;
        {
                if (!isset($_GET[$sName])) return $bDefault;
 
-               if (!preg_match('/^[+-][0-9]+$/', $_GET[$sName]))
+               if (!preg_match('/^[+-]?[0-9]+$/', $_GET[$sName]))
                {
                        userError("Integer number expected for parameter '$sName'");
                }
index 5d79fd4b8af1e22bb61343fe2d7af3d5ba620171..6100f54c623df10155e320cafccb771f4cf84729 100644 (file)
@@ -99,35 +99,35 @@ Feature: Simple Reverse Tests
           | lat
           | 51.51
         When sending an API call reverse
-        Then exactly 0 results are returned
+        Then a HTTP 400 is returned
 
     Scenario: Missing lat parameter
         Given the request parameters
           | lon
           | -79.39114
         When sending an API call reverse
-        Then exactly 0 results are returned
+        Then a HTTP 400 is returned
 
     Scenario: Missing osm_id parameter
         Given the request parameters
           | osm_type
           | N
         When sending an API call reverse
-        Then exactly 0 results are returned
+        Then a HTTP 400 is returned
 
     Scenario: Missing osm_type parameter
         Given the request parameters
           | osm_id
           | 3498564
         When sending an API call reverse
-        Then exactly 0 results are returned
+        Then a HTTP 400 is returned
 
     Scenario Outline: Bad format for lat or lon
         Given the request parameters
           | lat   | lon   |
           | <lat> | <lon> |
         When sending an API call reverse
-        Then exactly 0 results are returned
+        Then a HTTP 400 is returned
 
     Examples:
      | lat      | lon
@@ -137,4 +137,4 @@ Feature: Simple Reverse Tests
      | 48.966.0 | 8.4482
      | 48.966   | 8.448.2
      | Nan      | 8.448
-     | 48.966   | Nan
\ No newline at end of file
+     | 48.966   | Nan
index 150d6bdcf45479d1255eeca63afc262347de31e3..0b21d5584e6c164b13542a3fa9fe81f95c72aa0c 100644 (file)
@@ -187,7 +187,6 @@ Feature: Search queries
         | 0.0
         | 0.5
         | 999
-        | nan
 
     Scenario Outline: Search with polygon threshold (xml)
         Given the request parameters
@@ -203,7 +202,14 @@ Feature: Search queries
         | 0.0
         | 0.5
         | 999
-        | nan
+
+    Scenario Outline: Search with invalid polygon threshold (xml)
+        Given the request parameters
+          | polygon_geojson | polygon_threshold
+          | 1               | <th>
+        When sending xml search query "switzerland"
+        Then a HTTP 400 is returned
+
 
     Scenario Outline: Search with extratags
         Given the request parameters
index 2cb27b7cf61be0c3237f23220d804bf876374d18..0020cc2e4e9afb91ab4485c88d0e9c4d6bc4be8b 100644 (file)
@@ -61,7 +61,7 @@ Feature: Simple Tests
           | format
           | fd$#
         When sending search query "Berlin"
-        Then the result is valid html
+        Then a HTTP 400 is returned
 
     Scenario Outline: Simple Searches
         When sending search query "<query>"
index 60bd60ebd156f2cacf1b252628d4afb9fa1765a2..9d0cea4cc3602d4dd22b840c53cb79b2f621821a 100755 (executable)
@@ -5,6 +5,7 @@
        require_once(CONST_BasePath.'/lib/init-website.php');
        require_once(CONST_BasePath.'/lib/log.php');
        require_once(CONST_BasePath.'/lib/PlaceLookup.php');
+       require_once(CONST_BasePath.'/lib/output.php');
 
        if (strpos(CONST_BulkUserIPs, ','.$_SERVER["REMOTE_ADDR"].',') !== false)
        {
@@ -38,7 +39,7 @@
        $oPlaceLookup->setIncludeExtraTags(getParamBool('extratags', false));
        $oPlaceLookup->setIncludeNameDetails(getParamBool('namedetails', false));
 
-       $aOsmIds = explode(',', $getParamString('osm_ids', ''));
+       $aOsmIds = explode(',', getParamString('osm_ids', ''));
 
        if (count($aOsmIds) > CONST_Places_Max_ID_count)
        {
index 17b8a2ca08178a6eb1c15d3f69fce3fabedcafff..7f5eca78e5cea47237dbcbf5279761f0f38403ad 100755 (executable)
@@ -56,8 +56,8 @@
        $hLog = logStart($oDB, 'reverse', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
 
 
-       $sOsmType = getParamSet('osmtype', array('N', 'W', 'R'));
-       $iOsmId = getParamInt('osmid', -1);
+       $sOsmType = getParamSet('osm_type', array('N', 'W', 'R'));
+       $iOsmId = getParamInt('osm_id', -1);
        $fLat = getParamFloat('lat');
        $fLon = getParamFloat('lon');
        if ($sOsmType && $iOsmId > 0)