]> git.openstreetmap.org Git - nominatim.git/blob - test/bdd/api/search/simple.feature
set exception handler by request format, not always HTML
[nominatim.git] / test / bdd / api / search / simple.feature
1 @APIDB
2 Feature: Simple Tests
3     Simple tests for internal server errors and response format.
4
5     Scenario Outline: Testing different parameters
6         When sending search query "Hamburg"
7           | param       | value   |
8           | <parameter> | <value> |
9         Then at least 1 result is returned
10         When sending html search query "Hamburg"
11           | param       | value   |
12           | <parameter> | <value> |
13         Then at least 1 result is returned
14         When sending xml search query "Hamburg"
15           | param       | value   |
16           | <parameter> | <value> |
17         Then at least 1 result is returned
18         When sending json search query "Hamburg"
19           | param       | value   |
20           | <parameter> | <value> |
21         Then at least 1 result is returned
22         When sending jsonv2 search query "Hamburg"
23           | param       | value   |
24           | <parameter> | <value> |
25         Then at least 1 result is returned
26         When sending geojson search query "Hamburg"
27           | param       | value   |
28           | <parameter> | <value> |
29         Then at least 1 result is returned
30         When sending geocodejson search query "Hamburg"
31           | param       | value   |
32           | <parameter> | <value> |
33         Then at least 1 result is returned
34
35     Examples:
36      | parameter        | value |
37      | addressdetails   | 1 |
38      | addressdetails   | 0 |
39      | polygon          | 1 |
40      | polygon          | 0 |
41      | polygon_text     | 1 |
42      | polygon_text     | 0 |
43      | polygon_kml      | 1 |
44      | polygon_kml      | 0 |
45      | polygon_geojson  | 1 |
46      | polygon_geojson  | 0 |
47      | polygon_svg      | 1 |
48      | polygon_svg      | 0 |
49      | accept-language  | de,en |
50      | countrycodes     | de |
51      | bounded          | 1 |
52      | bounded          | 0 |
53      | exclude_place_ids| 385252,1234515 |
54      | limit            | 1000 |
55      | dedupe           | 1 |
56      | dedupe           | 0 |
57      | extratags        | 1 |
58      | extratags        | 0 |
59      | namedetails      | 1 |
60      | namedetails      | 0 |
61
62     Scenario: Search with invalid output format
63         When sending search query "Berlin"
64           | format |
65           | fd$# |
66         Then a HTTP 400 is returned
67
68     Scenario Outline: Simple Searches
69         When sending search query "<query>"
70         Then the result is valid html
71         When sending html search query "<query>"
72         Then the result is valid html
73         When sending xml search query "<query>"
74         Then the result is valid xml
75         When sending json search query "<query>"
76         Then the result is valid json
77         When sending jsonv2 search query "<query>"
78         Then the result is valid json
79         When sending geojson search query "<query>"
80         Then the result is valid geojson
81
82     Examples:
83      | query |
84      | New York, New York |
85      | France |
86      | 12, Main Street, Houston |
87      | München |
88      | 東京都 |
89      | hotels in nantes |
90      | xywxkrf |
91      | gh; foo() |
92      | %#$@*&l;der#$! |
93      | 234 |
94      | 47.4,8.3 |
95
96     Scenario: Empty XML search
97         When sending xml search query "xnznxvcx"
98         Then result header contains
99           | attr        | value |
100           | querystring | xnznxvcx |
101           | polygon     | false |
102           | more_url    | .*q=xnznxvcx.*format=xml |
103
104     Scenario: Empty XML search with special XML characters
105         When sending xml search query "xfdghn&zxn"xvbyx<vxx>cssdex"
106         Then result header contains
107           | attr        | value |
108           | querystring | xfdghn&zxn"xvbyx<vxx>cssdex |
109           | polygon     | false |
110           | more_url    | .*q=xfdghn%26zxn%22xvbyx%3Cvxx%3Ecssdex.*format=xml |
111
112     Scenario: Empty XML search with viewbox
113         When sending xml search query "xnznxvcx"
114           | viewbox |
115           | 12,33,77,45.13 |
116         Then result header contains
117           | attr        | value |
118           | querystring | xnznxvcx |
119           | polygon     | false |
120           | viewbox     | 12,33,77,45.13 |
121
122     Scenario: Empty XML search with viewboxlbrt
123         When sending xml search query "xnznxvcx"
124           | viewboxlbrt |
125           | 12,34.13,77,45 |
126         Then result header contains
127           | attr        | value |
128           | querystring | xnznxvcx |
129           | polygon     | false |
130           | viewbox     | 12,34.13,77,45 |
131
132     Scenario: Empty XML search with viewboxlbrt and viewbox
133         When sending xml search query "pub"
134           | viewbox        | viewboxblrt |
135           | 12,33,77,45.13 | 1,2,3,4 |
136         Then result header contains
137           | attr        | value |
138           | querystring | pub |
139           | polygon     | false |
140           | viewbox     | 12,33,77,45.13 |
141
142     Scenario Outline: Empty XML search with polygon values
143         When sending xml search query "xnznxvcx"
144           | param   | value |
145           | polygon | <polyval> |
146         Then result header contains
147           | attr        | value |
148           | polygon     | <result> |
149
150     Examples:
151      | result | polyval |
152      | false  | 0 |
153      | true   | 1 |
154      | true   | True |
155      | true   | true |
156      | true   | false |
157      | true   | FALSE |
158      | true   | yes |
159      | true   | no |
160      | true   | '; delete from foobar; select ' |
161
162     Scenario: Empty XML search with exluded place ids
163         When sending xml search query "jghrleoxsbwjer"
164           | exclude_place_ids |
165           | 123,76,342565 |
166         Then result header contains
167           | attr              | value |
168           | exclude_place_ids | 123,76,342565 |
169
170     Scenario: Empty XML search with bad exluded place ids
171         When sending xml search query "jghrleoxsbwjer"
172           | exclude_place_ids |
173           | , |
174         Then result header has not attributes exclude_place_ids
175
176     Scenario Outline: Wrapping of legal jsonp search requests
177         When sending json search query "Tokyo"
178             | param        | value |
179             |json_callback | <data> |
180         Then result header contains
181             | attr         | value |
182             | json_func    | <result> |
183
184     Examples:
185      | data    | result |
186      | foo     | foo |
187      | FOO     | FOO |
188      | __world | __world |
189      | $me     | \$me |
190      | m1[4]   | m1\[4\] |
191      | d_r[$d] | d_r\[\$d\] |
192
193     Scenario Outline: Wrapping of illegal jsonp search requests
194         When sending json search query "Tokyo"
195             | param        | value |
196             |json_callback | <data> |
197         Then a json user error is returned
198
199     Examples:
200       | data |
201       | 1asd |
202       | bar(foo) |
203       | XXX['bad'] |
204       | foo; evil |
205
206     Scenario: Ignore jsonp parameter for anything but json
207         When sending json search query "Malibu"
208           | json_callback |
209           | 234 |
210         Then a HTTP 400 is returned
211         When sending xml search query "Malibu"
212           | json_callback |
213           | 234 |
214         Then the result is valid xml
215         When sending html search query "Malibu"
216           | json_callback |
217           | 234 |
218         Then the result is valid html
219
220     Scenario: Empty JSON search
221         When sending json search query "YHlERzzx"
222         Then exactly 0 results are returned
223
224     Scenario: Empty JSONv2 search
225         When sending jsonv2 search query "Flubb XdfESSaZx"
226         Then exactly 0 results are returned
227
228     Scenario: Search for non-existing coordinates
229         When sending json search query "-21.0,-33.0"
230         Then exactly 0 results are returned
231
232     Scenario: Country code selection is retained in more URL (#596)
233         When sending xml search query "Vaduz"
234           | countrycodes |
235           | pl,1,,invalid,undefined,%3Cb%3E,bo,, |
236         Then result header contains
237           | attr     | value |
238           | more_url | .*&countrycodes=pl%2Cbo&.* |
239
240     Scenario Outline: Search with debug prints valid HTML
241         When sending html search query "<query>"
242           | extratags | addressdetails | namedetails | debug |
243           | 1         | 1              | 1           | 1     |
244         Then the result is valid html
245
246         Examples:
247           | query |
248           | 10, Alvierweg, 9490, Vaduz |
249           | Hamburg |