[cpp-sp] branch main updated: Finalize config tests.

Scott Cantor cantor.2 at osu.edu
Tue Nov 26 19:05:27 UTC 2024


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch main
in repository cpp-sp.

View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=aff486c568e2efa838bb6ba39c3266c282f13469

The following commit(s) were added to refs/heads/main by this push:
     new aff486c5 Finalize config tests.
aff486c5 is described below

commit aff486c568e2efa838bb6ba39c3266c282f13469
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Nov 26 14:05:23 2024 -0500

    Finalize config tests.
---
 tests/AgentConfigTests.cpp | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/tests/AgentConfigTests.cpp b/tests/AgentConfigTests.cpp
index e799069a..154a7b98 100644
--- a/tests/AgentConfigTests.cpp
+++ b/tests/AgentConfigTests.cpp
@@ -18,6 +18,8 @@
  * Unit tests for agent config machinery and logging.
  */
 
+#include <stdexcept>
+
 #include <boost/test/unit_test.hpp>
 #include <boost/property_tree/ini_parser.hpp>
 
@@ -38,8 +40,9 @@ struct AC_Fixture {
 class exceptionCheck {
 public:
     exceptionCheck(const string& msg) : m_msg(msg) {}
-    bool check_message(const ini_parser_error& e) {
-        return e.message().compare(m_msg) == 0;
+    bool check_message(const exception& e) {
+        cout << e.what() << endl;
+        return m_msg.compare(e.what()) == 0;
     }
 private:
     string m_msg;
@@ -47,39 +50,43 @@ private:
 
 BOOST_FIXTURE_TEST_CASE(AgentConfig_init_bad_path, AC_Fixture)
 {
-    // No throw.
     BOOST_CHECK(!AgentConfig::getConfig().init(nullptr, (data_path + "missing.ini").c_str(), false));
 
-    exceptionCheck checker("cannot open file");
-
-    // Throw.
+    exceptionCheck checker("./data/missing.ini: cannot open file");
     BOOST_CHECK_EXCEPTION(AgentConfig::getConfig().init(nullptr, (data_path + "missing.ini").c_str(), true),
         ini_parser_error, checker.check_message);
 }
 
 BOOST_FIXTURE_TEST_CASE(AgentConfig_init_bad_format, AC_Fixture)
 {
-    exceptionCheck checker_unmatched("unmatched '['");
+    exceptionCheck checker_unmatched("./data/unmatched_shibboleth.ini(1): unmatched '['");
     BOOST_CHECK_EXCEPTION(AgentConfig::getConfig().init(nullptr, (data_path + "unmatched_shibboleth.ini").c_str(), true),
         ini_parser_error, checker_unmatched.check_message);
 
-    exceptionCheck checker_dupsection("duplicate section name");
+    exceptionCheck checker_dupsection("./data/dupsection_shibboleth.ini(4): duplicate section name");
     BOOST_CHECK_EXCEPTION(AgentConfig::getConfig().init(nullptr, (data_path + "dupsection_shibboleth.ini").c_str(), true),
         ini_parser_error, checker_dupsection.check_message);
 
-    exceptionCheck checker_noequals("'=' character not found in line");
+    exceptionCheck checker_noequals("./data/noequals_shibboleth.ini(2): '=' character not found in line");
     BOOST_CHECK_EXCEPTION(AgentConfig::getConfig().init(nullptr, (data_path + "noequals_shibboleth.ini").c_str(), true),
         ini_parser_error, checker_noequals.check_message);
 
-    exceptionCheck checker_dupproperty("duplicate key name");
+    exceptionCheck checker_dupproperty("./data/dupproperty_shibboleth.ini(3): duplicate key name");
     BOOST_CHECK_EXCEPTION(AgentConfig::getConfig().init(nullptr, (data_path + "dupproperty_shibboleth.ini").c_str(), true),
         ini_parser_error, checker_dupproperty.check_message);
 
-    exceptionCheck checker_nokey("key expected");
+    exceptionCheck checker_nokey("./data/nokey_shibboleth.ini(2): key expected");
     BOOST_CHECK_EXCEPTION(AgentConfig::getConfig().init(nullptr, (data_path + "nokey_shibboleth.ini").c_str(), true),
         ini_parser_error, checker_nokey.check_message);
 }
 
+BOOST_AUTO_TEST_CASE(AgentConfig_term_without_init)
+{
+    exceptionCheck checker_term("Library terminated without initialization.");
+    BOOST_CHECK_EXCEPTION(AgentConfig::getConfig().term(),
+        runtime_error, checker_term.check_message);
+}
+
 BOOST_FIXTURE_TEST_CASE(AgentConfig_init_success, AC_Fixture)
 {
     BOOST_CHECK(AgentConfig::getConfig().init(nullptr, (data_path + "shibboleth.ini").c_str(), true));

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list