[cpp-sp] branch main updated: Add unit test for exclusive file creation behavior.

Codeberg noreply at shibboleth.net
Fri Sep 18 15:10:57 UTC 2026


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

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

View the commit online:
https://codeberg.org/Shibboleth/cpp-sp/commit/f33b8f71ca669231e54eaa81d4182443a6258c47

The following commit(s) were added to refs/heads/main by this push:
     new f33b8f71 Add unit test for exclusive file creation behavior.
f33b8f71 is described below

commit f33b8f71ca669231e54eaa81d4182443a6258c47
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Fri Sep 18 11:10:46 2026 -0400

    Add unit test for exclusive file creation behavior.
---
 tests/session/impl/FilesystemSessionCacheTests.cpp | 38 ++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/tests/session/impl/FilesystemSessionCacheTests.cpp b/tests/session/impl/FilesystemSessionCacheTests.cpp
index 203d041e..5db68717 100644
--- a/tests/session/impl/FilesystemSessionCacheTests.cpp
+++ b/tests/session/impl/FilesystemSessionCacheTests.cpp
@@ -32,6 +32,12 @@
 #include <boost/test/unit_test.hpp>
 #include <boost/property_tree/ini_parser.hpp>
 
+#include <fcntl.h>
+#ifdef WIN32
+# include <io.h>
+#endif
+
+
 using namespace shibsp;
 using namespace boost::property_tree;
 using namespace std;
@@ -100,6 +106,38 @@ struct FilesystemFixture
     string data_path;
 };
 
+BOOST_FIXTURE_TEST_CASE(FilesystemSessionCache_open_behavior, FilesystemFixture)
+{
+    bool started = AgentConfig::getConfig().start();
+    BOOST_CHECK(started);
+
+    string path = string(DATA_PATH) + "sanitycheck";
+
+#ifdef WIN32
+    int f = _open(path.c_str(), _O_CREAT | _O_EXCL, _S_IREAD | _S_IWRITE);
+#else
+    int f = open(path.c_str(), O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
+#endif
+    BOOST_CHECK(f >= 0);
+#ifdef WIN32
+    _close(f);
+#else
+    close(f);
+#endif
+
+    // Make sure subsequent open fails with those flags.
+#ifdef WIN32
+    f = _open(path.c_str(), _O_CREAT | _O_EXCL, _S_IREAD | _S_IWRITE);
+#else
+    f = open(path.c_str(), O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
+#endif
+    BOOST_CHECK(f < 0);
+
+    // Cleanup.
+    int ret = std::remove(path.c_str());
+    BOOST_CHECK(ret == 0);
+}
+
 BOOST_FIXTURE_TEST_CASE(FilesystemSessionCache_invalid_attributes, FilesystemFixture)
 {
     bool started = AgentConfig::getConfig().start();

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


More information about the commits mailing list