/* * Runs against a Squid reverse proxy with HTTP Basic Auth in front of the * public Nominatim (see scripts/squid/deploy-proxy-env.sh). Only the outcome * is checked: the size of the live response and Squid's error page change * over time and between Squid versions. */ \set VERBOSITY terse CREATE SERVER osm_http_auth FOREIGN DATA WRAPPER nominatim_fdw OPTIONS (url 'http://172.19.42.102:3128'); CREATE USER MAPPING FOR postgres SERVER osm_http_auth OPTIONS (user 'nominatimuser', password 'nominatimpass'); /* must return HTTP 200 */ SELECT osm_id, display_name FROM nominatim_search( server_name => 'osm_http_auth', q => 'einsteinstraße 60, münster, germany'); osm_id | display_name ----------+----------------------------------------------------------------------------------------------------------------------------------------------- 88291927 | Center for Information Technology, 60, Einsteinstraße, Neutor, Innenstadtring, Münster-Mitte, Münster, North Rhine-Westphalia, 48149, Germany (1 row) ALTER USER MAPPING FOR postgres SERVER osm_http_auth OPTIONS (SET user 'foo', SET password 'bar'); /* invalid credentials, must fail (HTTP 401) */ SELECT osm_id, display_name FROM nominatim_search( server_name => 'osm_http_auth', q => 'einsteinstraße 60, münster, germany'); ERROR: the server returned HTTP status 401 DROP SERVER osm_http_auth CASCADE; NOTICE: drop cascades to user mapping for postgres on server osm_http_auth