postgis: Exclude password from ConnectionCreator::id()

- Password is not necessary for connection identification
- When password is not required by the database,
  user can accidentally use multiple different passwords
  without noticing.
  This leads to allocating more connection pools
  and increase of connection consumption.
This commit is contained in:
Jiri Drbalek 2018-05-03 10:21:10 +02:00
parent d8dbe11fd0
commit ab05de48df
2 changed files with 19 additions and 1 deletions

View file

@ -67,7 +67,7 @@ public:
inline std::string id() const
{
return connection_string();
return connection_string_safe();
}
inline std::string connection_string() const

View file

@ -28,6 +28,7 @@
#include <mapnik/geometry/geometry_type.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/util/fs.hpp>
#include "../../../plugins/input/postgis/connection_manager.hpp"
/*
Compile and run just this test:
@ -406,3 +407,20 @@ TEST_CASE("postgis") {
}
}
TEST_CASE("ConnectionCreator") {
SECTION("ConnectionCreator::id() should not expose password")
{
ConnectionCreator<Connection> creator(boost::optional<std::string>("host"),
boost::optional<std::string>("12345"),
boost::optional<std::string>("dbname"),
boost::optional<std::string>("user"),
boost::optional<std::string>("pass"),
boost::optional<std::string>("111"));
CHECK(creator.id() == "host=host port=12345 dbname=dbname user=user connect_timeout=111");
}
}