Skip to content
Snippets Groups Projects
Commit 1c57270a authored by Daniel Hornung's avatar Daniel Hornung
Browse files

WIP TEST: Wrote test which did not fail before.

Probably there should be a similar test for ccaosdb.
parent 6aa71775
Branches
Tags
1 merge request!17F file read error
Pipeline #12564 passed with warnings
Pipeline: caosdb-cppinttest

#12567

    This commit is part of merge request !17. Comments created here will be created in the context of that merge request.
    ...@@ -91,12 +91,13 @@ auto getEnumValueFromName<caosdb::entity::Role>(const std::string &name) -> caos ...@@ -91,12 +91,13 @@ auto getEnumValueFromName<caosdb::entity::Role>(const std::string &name) -> caos
    */ */
    inline auto load_string_file(const path &path) -> std::string { inline auto load_string_file(const path &path) -> std::string {
    std::string result; std::string result;
    try { // TODO(htw)
    // try {
    boost::filesystem::load_string_file(path, result); boost::filesystem::load_string_file(path, result);
    } catch (const std::exception &exc) { // } catch (const std::exception &exc) {
    throw caosdb::exceptions::Exception(StatusCode::FILE_CANNOT_BE_READ , // throw caosdb::exceptions::Exception(StatusCode::FILE_CANNOT_BE_READ ,
    "Cannot read the following file: "+ path.string()); // "Cannot read the following file: "+ path.string());
    } // }
    return result; return result;
    } }
    ......
    ...@@ -109,8 +109,8 @@ auto ConnectionManager::mGetConnection(const std::string &name) const ...@@ -109,8 +109,8 @@ auto ConnectionManager::mGetConnection(const std::string &name) const
    auto connection = ConfigurationManager::GetConnectionConfiguration(name); auto connection = ConfigurationManager::GetConnectionConfiguration(name);
    connections[name] = std::make_shared<Connection>(*connection.release()); connections[name] = std::make_shared<Connection>(*connection.release());
    } catch (const caosdb::exceptions::ConfigurationError &exc) { } catch (const caosdb::exceptions::ConfigurationError &exc) {
    throw caosdb::exceptions::UnknownConnectionError("No connection named '" + name + throw caosdb::exceptions::UnknownConnectionError("Error with the connection named '" + name +
    "' present."); "': " + exc.what());
    } }
    } }
    return this->connections.at(name); return this->connections.at(name);
    ......
    ...@@ -185,6 +185,7 @@ ERROR_RETURN_CODE(GENERIC_ERROR, ...@@ -185,6 +185,7 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
    if (out->_deletable) { if (out->_deletable) {
    return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR; return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR;
    } }
    // TODO(htw) eitehr check for file existence or call CreateCertificateProvider?
    out->wrapped_certificate_provider = out->wrapped_certificate_provider =
    new caosdb::configuration::PemFileCertificateProvider(std::string(path)); new caosdb::configuration::PemFileCertificateProvider(std::string(path));
    out->_deletable = true; out->_deletable = true;
    ......
    ...@@ -65,9 +65,16 @@ TEST_F(test_connection, configure_ssl_localhost_8080) { ...@@ -65,9 +65,16 @@ TEST_F(test_connection, configure_ssl_localhost_8080) {
    } }
    TEST_F(test_connection, connection_manager_unknown_connection) { TEST_F(test_connection, connection_manager_unknown_connection) {
    EXPECT_THROW_MESSAGE(ConnectionManager::GetConnection("test"), EXPECT_THROW_MESSAGE(
    caosdb::exceptions::UnknownConnectionError, ConnectionManager::GetConnection("test"), caosdb::exceptions::UnknownConnectionError,
    "No connection named 'test' present."); "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) { TEST_F(test_connection, connection_manager_get_default_connection) {
    ......
    ...@@ -18,6 +18,16 @@ ...@@ -18,6 +18,16 @@
    "username": "me", "username": "me",
    "password": "secret!" "password": "secret!"
    } }
    },
    "missing": {
    "host": "localhost",
    "port": 8443,
    "server_certificate_path": "/missing",
    "authentication": {
    "type": "plain",
    "username": "me",
    "password": "secret!"
    }
    } }
    }, },
    "logging": { "logging": {
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment