diff --git a/include/caosdb/utility.h b/include/caosdb/utility.h index 763646f3da9cf446ed3d9dfe144672acb36d4349..568f8c9bc330356b37ad6c757f85b99d48188776 100644 --- a/include/caosdb/utility.h +++ b/include/caosdb/utility.h @@ -91,12 +91,13 @@ auto getEnumValueFromName<caosdb::entity::Role>(const std::string &name) -> caos */ inline auto load_string_file(const path &path) -> std::string { std::string result; - try { + // TODO(htw) + // try { boost::filesystem::load_string_file(path, result); - } catch (const std::exception &exc) { - throw caosdb::exceptions::Exception(StatusCode::FILE_CANNOT_BE_READ , - "Cannot read the following file: "+ path.string()); - } + // } catch (const std::exception &exc) { + // throw caosdb::exceptions::Exception(StatusCode::FILE_CANNOT_BE_READ , + // "Cannot read the following file: "+ path.string()); + // } return result; } diff --git a/src/caosdb/connection.cpp b/src/caosdb/connection.cpp index d6782f8ffa42238888998bdff65dc666fbf55c18..9d27c5c2b14ca0df8ada7ddc8bf5250059291c46 100644 --- a/src/caosdb/connection.cpp +++ b/src/caosdb/connection.cpp @@ -109,8 +109,8 @@ auto ConnectionManager::mGetConnection(const std::string &name) const auto connection = ConfigurationManager::GetConnectionConfiguration(name); connections[name] = std::make_shared<Connection>(*connection.release()); } catch (const caosdb::exceptions::ConfigurationError &exc) { - throw caosdb::exceptions::UnknownConnectionError("No connection named '" + name + - "' present."); + throw caosdb::exceptions::UnknownConnectionError("Error with the connection named '" + name + + "': " + exc.what()); } } return this->connections.at(name); diff --git a/src/ccaosdb.cpp b/src/ccaosdb.cpp index d5165c98e64b7084a395a710a5bd1b98019f9edb..c506e446eab6f4491af12884a01ca4c8814ae649 100644 --- a/src/ccaosdb.cpp +++ b/src/ccaosdb.cpp @@ -185,6 +185,7 @@ ERROR_RETURN_CODE(GENERIC_ERROR, if (out->_deletable) { return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR; } + // TODO(htw) eitehr check for file existence or call CreateCertificateProvider? out->wrapped_certificate_provider = new caosdb::configuration::PemFileCertificateProvider(std::string(path)); out->_deletable = true; diff --git a/test/test_connection.cpp b/test/test_connection.cpp index 99391536edf031fbe4a326f56e24f68e5a50b5d3..86eae20e971819a8911182ec4887299b1a85764c 100644 --- a/test/test_connection.cpp +++ b/test/test_connection.cpp @@ -65,9 +65,16 @@ TEST_F(test_connection, configure_ssl_localhost_8080) { } TEST_F(test_connection, connection_manager_unknown_connection) { - EXPECT_THROW_MESSAGE(ConnectionManager::GetConnection("test"), - caosdb::exceptions::UnknownConnectionError, - "No connection named 'test' present."); + EXPECT_THROW_MESSAGE( + ConnectionManager::GetConnection("test"), caosdb::exceptions::UnknownConnectionError, + "Error with the connection named 'test': The connection 'test' has not been defined."); +} + +TEST_F(test_connection, connection_missing_certificate) { + EXPECT_THROW_MESSAGE( + ConnectionManager::GetConnection("missing"), caosdb::exceptions::UnknownConnectionError, + std::string("Error with the connection named 'missing': ") + + "File does not exist (server_certificate_path): /missing"); } TEST_F(test_connection, connection_manager_get_default_connection) { diff --git a/test/test_data/test_caosdb_client.json b/test/test_data/test_caosdb_client.json index 2007413021b332c3bd32686363e241804a8d62ab..276c542f75353090b28918ab0ef9b33f9f0815e1 100644 --- a/test/test_data/test_caosdb_client.json +++ b/test/test_data/test_caosdb_client.json @@ -13,6 +13,16 @@ "local-caosdb": { "host": "localhost", "port": 8443, + "authentication": { + "type": "plain", + "username": "me", + "password": "secret!" + } + }, + "missing": { + "host": "localhost", + "port": 8443, + "server_certificate_path": "/missing", "authentication": { "type": "plain", "username": "me",