Commit 769b2a11 authored by jan.koester's avatar jan.koester
Browse files

test

parent 4d7b062d
Loading
Loading
Loading
Loading
+5 −0
Changes for CMakeLists.txt: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -80,6 +80,11 @@ add_executable(proxyplus-bootstrap tools/proxyplus-bootstrap.cpp)
target_link_libraries(proxyplus-bootstrap PRIVATE proxyplus_core)
install(TARGETS proxyplus-bootstrap RUNTIME DESTINATION bin)

# Plugin .so modules install here, independent of CMAKE_INSTALL_PREFIX, so they land
# wherever config.yaml's paths.plugins points regardless of prefix (see config/proxyplus.yaml).
set(PROXYPLUS_PLUGIN_INSTALL_DIR "/usr/lib/proxyplus/plugins" CACHE PATH
    "Directory plugin .so modules install into (must match paths.plugins in config.yaml)")

add_subdirectory(plugins/example_dnsbl)
add_subdirectory(plugins/acme_common)
add_subdirectory(plugins/letsencrypt)
+1 −0
Changes for plugins/example_dnsbl/CMakeLists.txt: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
add_library(example_dnsbl MODULE dnsbl_plugin.cpp)
set_target_properties(example_dnsbl PROPERTIES PREFIX "" OUTPUT_NAME "example_dnsbl")
target_compile_features(example_dnsbl PRIVATE cxx_std_20)
install(TARGETS example_dnsbl LIBRARY DESTINATION ${PROXYPLUS_PLUGIN_INSTALL_DIR})
+1 −0
Changes for plugins/letsencrypt/CMakeLists.txt: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -2,3 +2,4 @@ add_library(letsencrypt MODULE letsencrypt_plugin.cpp)
set_target_properties(letsencrypt PROPERTIES PREFIX "" OUTPUT_NAME "letsencrypt")
target_compile_features(letsencrypt PRIVATE cxx_std_20)
target_link_libraries(letsencrypt PRIVATE acme_common)
install(TARGETS letsencrypt LIBRARY DESTINATION ${PROXYPLUS_PLUGIN_INSTALL_DIR})
+1 −0
Changes for plugins/zerossl/CMakeLists.txt: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -2,3 +2,4 @@ add_library(zerossl MODULE zerossl_plugin.cpp eab.cpp)
set_target_properties(zerossl PROPERTIES PREFIX "" OUTPUT_NAME "zerossl")
target_compile_features(zerossl PRIVATE cxx_std_20)
target_link_libraries(zerossl PRIVATE acme_common httppp::httppp json-c::json-c)
install(TARGETS zerossl LIBRARY DESTINATION ${PROXYPLUS_PLUGIN_INSTALL_DIR})
+22 −7
Changes for test/test_configstore.cpp: 22 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -65,7 +65,13 @@ int main() {
        manualProfile.keyTag = std::vector<uint8_t>(16, 0xCD);
        store.putTlsProfile(manualProfile);

        assert(store.listHttpRoutes().size() == 1);
        auto routesBeforeReopen = store.listHttpRoutes();
        assert(routesBeforeReopen.size() == 2);
        // Lower priority sorts first regardless of id/insertion order or pathPrefix length.
        assert(routesBeforeReopen[0].id == "r0");
        assert(routesBeforeReopen[0].priority == 1);
        assert(routesBeforeReopen[1].id == "r1");
        assert(routesBeforeReopen[1].priority == 5);
        assert(store.listSmtpRelayRules().size() == 1);
        auto gpoId = store.gpoIdForPermission("smtp.domains.write", ResourceContext{"", ""});
        assert(gpoId && *gpoId == perm.gpoId);
@@ -95,10 +101,13 @@ int main() {
    {
        ConfigStore store(dir);
        auto routes = store.listHttpRoutes();
        assert(routes.size() == 1);
        assert(routes[0].id == "r1");
        assert(routes[0].domain == "example.com");
        assert(routes[0].upstream == "http://10.0.0.1:8080");
        assert(routes.size() == 2);
        assert(routes[0].id == "r0");
        assert(routes[0].priority == 1);
        assert(routes[1].id == "r1");
        assert(routes[1].domain == "example.com");
        assert(routes[1].upstream == "http://10.0.0.1:8080");
        assert(routes[1].priority == 5);

        auto relays = store.listSmtpRelayRules();
        assert(relays.size() == 1);
@@ -117,13 +126,19 @@ int main() {

        // compact() must fold the WAL into a snapshot without losing data.
        store.compact();
        assert(store.listHttpRoutes().size() == 1);
        auto compacted = store.listHttpRoutes();
        assert(compacted.size() == 2);
        assert(compacted[0].id == "r0" && compacted[0].priority == 1);
        assert(compacted[1].id == "r1" && compacted[1].priority == 5);
    }

    // Reopen again after compact(): must still be intact, now loaded from the snapshot.
    {
        ConfigStore store(dir);
        assert(store.listHttpRoutes().size() == 1);
        auto routes = store.listHttpRoutes();
        assert(routes.size() == 2);
        assert(routes[0].id == "r0" && routes[0].priority == 1);
        assert(routes[1].id == "r1" && routes[1].priority == 5);
        assert(store.listSmtpRelayRules().size() == 1);
        assert(store.listTlsProfiles().size() == 2);
    }