diff --git a/plugins/input/postgis/connection_manager.hpp b/plugins/input/postgis/connection_manager.hpp index 899fc9fc2..49dca17f5 100644 --- a/plugins/input/postgis/connection_manager.hpp +++ b/plugins/input/postgis/connection_manager.hpp @@ -67,7 +67,7 @@ public: inline std::string id() const { - return connection_string(); + return connection_string_safe(); } inline std::string connection_string() const diff --git a/test/unit/datasource/postgis.cpp b/test/unit/datasource/postgis.cpp index 5d43bbacc..f5a5add36 100644 --- a/test/unit/datasource/postgis.cpp +++ b/test/unit/datasource/postgis.cpp @@ -28,6 +28,7 @@ #include #include #include +#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 creator(boost::optional("host"), + boost::optional("12345"), + boost::optional("dbname"), + boost::optional("user"), + boost::optional("pass"), + boost::optional("111")); + + CHECK(creator.id() == "host=host port=12345 dbname=dbname user=user connect_timeout=111"); +} + +}