[cpp-sp] branch main updated: Add a test for partial matching.

Scott Cantor cantor.2 at osu.edu
Wed Jun 25 13:28:52 UTC 2025


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=ee84046ac7b431415918a989f678cf0507c90aaf

The following commit(s) were added to refs/heads/main by this push:
     new ee84046a Add a test for partial matching.
ee84046a is described below

commit ee84046ac7b431415918a989f678cf0507c90aaf
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Jun 25 09:28:48 2025 -0400

    Add a test for partial matching.
---
 tests/data/impl/partial-regex-shibboleth.ini | 15 +++++++++
 tests/impl/XMLAccessControlTests.cpp         | 49 ++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+)

diff --git a/tests/data/impl/partial-regex-shibboleth.ini b/tests/data/impl/partial-regex-shibboleth.ini
new file mode 100644
index 00000000..20676c06
--- /dev/null
+++ b/tests/data/impl/partial-regex-shibboleth.ini
@@ -0,0 +1,15 @@
+[global]
+agentID = sp.example.org
+skipHandlers = true
+partialRegexMatching = true
+
+[logging]
+type = console
+defaultLevel = INFO
+
+[logging-categories]
+Shibboleth.AgentConfig = WARN
+Shibboleth.AccessControl = DEBUG
+Shibboleth.RequestMapper = INFO
+Shibboleth.DummyRequest = DEBUG
+
diff --git a/tests/impl/XMLAccessControlTests.cpp b/tests/impl/XMLAccessControlTests.cpp
index 11da2228..acc4d737 100644
--- a/tests/impl/XMLAccessControlTests.cpp
+++ b/tests/impl/XMLAccessControlTests.cpp
@@ -109,6 +109,23 @@ struct XMLAccessControlFixture
     string data_path;
 };
 
+struct PartialRegexXMLAccessControlFixture
+{
+    PartialRegexXMLAccessControlFixture() : data_path(DATA_PATH) {
+        AgentConfig::getConfig().init(nullptr, (data_path + "../partial-regex-shibboleth.ini").c_str(), true);
+    }
+    ~PartialRegexXMLAccessControlFixture() {
+        AgentConfig::getConfig().term();
+    }
+
+    void parse(const string& filename) {
+        xml_parser::read_xml(data_path + filename, tree, xml_parser::no_comments|xml_parser::trim_whitespace);
+    }
+
+    ptree tree;
+    string data_path;
+};
+
 /////////////
 // File pointing to external ACL file that's invalid XML.
 /////////////
@@ -240,6 +257,38 @@ BOOST_FIXTURE_TEST_CASE(XMLAccessControl_inline_UserRegexRule, XMLAccessControlF
     request.m_user = "smith";
     BOOST_CHECK_EQUAL(acl->authorized(request, &session), AccessControl::shib_acl_false);
 
+    request.m_user = "extrajdoe";
+    BOOST_CHECK_EQUAL(acl->authorized(request, &session), AccessControl::shib_acl_false);
+
+    request.m_user = "jdoe";
+    BOOST_CHECK_EQUAL(acl->authorized(request, &session), AccessControl::shib_acl_true);
+}
+
+/////////////
+// Inline ACL test for user regex rule with partial matching
+/////////////
+
+BOOST_FIXTURE_TEST_CASE(XMLAccessControl_inline_UserRegexRule_partial, PartialRegexXMLAccessControlFixture)
+{
+    parse("inline-user-regex-acl.xml");
+    BOOST_CHECK_EQUAL(tree.size(), 1);
+
+    unique_ptr<AccessControl> acl(AgentConfig::getConfig().AccessControlManager.newPlugin(
+        tree.front().second.get<string>("<xmlattr>.type").c_str(), tree.front().second, true));
+
+#ifdef HAVE_CXX14
+    shared_lock locker(*acl);
+#endif
+
+    MappableDummyRequest request;
+    DummySession session;
+
+    request.m_user = "smith";
+    BOOST_CHECK_EQUAL(acl->authorized(request, &session), AccessControl::shib_acl_false);
+
+    request.m_user = "extrajdoe";
+    BOOST_CHECK_EQUAL(acl->authorized(request, &session), AccessControl::shib_acl_true);
+
     request.m_user = "jdoe";
     BOOST_CHECK_EQUAL(acl->authorized(request, &session), AccessControl::shib_acl_true);
 }

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


More information about the commits mailing list