Loading test/test_configstore.cpp +40 −9 Changes for test/test_configstore.cpp: 40 added lines, 9 removed lines. Original line number Diff line number Diff line #include <algorithm> #include <cassert> #include <cstdlib> #include <iostream> Loading Loading @@ -41,6 +42,18 @@ int main() { tlsProfile.selfSigned = true; store.putTlsProfile(tlsProfile); // Operator-supplied cert (neither ACME nor self-signed): certPem is plaintext, the // "encrypted" key fields are opaque bytes as far as ConfigStore is concerned -- it // just needs to round-trip them, not decrypt them (see src/tls/CertSeal.h). TlsProfileRecord manualProfile; manualProfile.profile = "shop"; manualProfile.domains = {"shop.example.com"}; manualProfile.certPem = "-----BEGIN CERTIFICATE-----\nfakecertdata\n-----END CERTIFICATE-----\n"; manualProfile.encryptedKeyPem = {1, 2, 3, 4, 5}; manualProfile.keyNonce = std::vector<uint8_t>(12, 0xAB); manualProfile.keyTag = std::vector<uint8_t>(16, 0xCD); store.putTlsProfile(manualProfile); assert(store.listHttpRoutes().size() == 1); assert(store.listSmtpRelayRules().size() == 1); auto gpoId = store.gpoIdForPermission("smtp.domains.write", ResourceContext{"", ""}); Loading @@ -48,10 +61,23 @@ int main() { assert(store.version() > 0); auto profiles = store.listTlsProfiles(); assert(profiles.size() == 1); assert(profiles[0].selfSigned); assert(!profiles[0].acmeEnabled); assert(profiles[0].domains == tlsProfile.domains); assert(profiles.size() == 2); auto findProfile = [&](const std::string &name) { return std::find_if(profiles.begin(), profiles.end(), [&](const auto &p) { return p.profile == name; }); }; auto internal = findProfile("internal"); assert(internal != profiles.end()); assert(internal->selfSigned); assert(!internal->acmeEnabled); assert(internal->domains == tlsProfile.domains); auto shop = findProfile("shop"); assert(shop != profiles.end()); assert(shop->certPem == manualProfile.certPem); assert(shop->encryptedKeyPem == manualProfile.encryptedKeyPem); assert(shop->keyNonce == manualProfile.keyNonce); assert(shop->keyTag == manualProfile.keyTag); } // Reopen: WAL replay must reconstruct identical state. Loading @@ -68,9 +94,15 @@ int main() { assert(relays[0].smarthost == "smtp.example.com:587"); auto profiles = store.listTlsProfiles(); assert(profiles.size() == 1); assert(profiles[0].profile == "internal"); assert(profiles[0].selfSigned); assert(profiles.size() == 2); auto internal = std::find_if(profiles.begin(), profiles.end(), [](const auto &p) { return p.profile == "internal"; }); assert(internal != profiles.end()); assert(internal->selfSigned); auto shop = std::find_if(profiles.begin(), profiles.end(), [](const auto &p) { return p.profile == "shop"; }); assert(shop != profiles.end()); assert(!shop->certPem.empty()); // compact() must fold the WAL into a snapshot without losing data. store.compact(); Loading @@ -82,8 +114,7 @@ int main() { ConfigStore store(dir); assert(store.listHttpRoutes().size() == 1); assert(store.listSmtpRelayRules().size() == 1); assert(store.listTlsProfiles().size() == 1); assert(store.listTlsProfiles()[0].selfSigned); assert(store.listTlsProfiles().size() == 2); } std::system(("rm -rf " + dir).c_str()); Loading Loading
test/test_configstore.cpp +40 −9 Changes for test/test_configstore.cpp: 40 added lines, 9 removed lines. Original line number Diff line number Diff line #include <algorithm> #include <cassert> #include <cstdlib> #include <iostream> Loading Loading @@ -41,6 +42,18 @@ int main() { tlsProfile.selfSigned = true; store.putTlsProfile(tlsProfile); // Operator-supplied cert (neither ACME nor self-signed): certPem is plaintext, the // "encrypted" key fields are opaque bytes as far as ConfigStore is concerned -- it // just needs to round-trip them, not decrypt them (see src/tls/CertSeal.h). TlsProfileRecord manualProfile; manualProfile.profile = "shop"; manualProfile.domains = {"shop.example.com"}; manualProfile.certPem = "-----BEGIN CERTIFICATE-----\nfakecertdata\n-----END CERTIFICATE-----\n"; manualProfile.encryptedKeyPem = {1, 2, 3, 4, 5}; manualProfile.keyNonce = std::vector<uint8_t>(12, 0xAB); manualProfile.keyTag = std::vector<uint8_t>(16, 0xCD); store.putTlsProfile(manualProfile); assert(store.listHttpRoutes().size() == 1); assert(store.listSmtpRelayRules().size() == 1); auto gpoId = store.gpoIdForPermission("smtp.domains.write", ResourceContext{"", ""}); Loading @@ -48,10 +61,23 @@ int main() { assert(store.version() > 0); auto profiles = store.listTlsProfiles(); assert(profiles.size() == 1); assert(profiles[0].selfSigned); assert(!profiles[0].acmeEnabled); assert(profiles[0].domains == tlsProfile.domains); assert(profiles.size() == 2); auto findProfile = [&](const std::string &name) { return std::find_if(profiles.begin(), profiles.end(), [&](const auto &p) { return p.profile == name; }); }; auto internal = findProfile("internal"); assert(internal != profiles.end()); assert(internal->selfSigned); assert(!internal->acmeEnabled); assert(internal->domains == tlsProfile.domains); auto shop = findProfile("shop"); assert(shop != profiles.end()); assert(shop->certPem == manualProfile.certPem); assert(shop->encryptedKeyPem == manualProfile.encryptedKeyPem); assert(shop->keyNonce == manualProfile.keyNonce); assert(shop->keyTag == manualProfile.keyTag); } // Reopen: WAL replay must reconstruct identical state. Loading @@ -68,9 +94,15 @@ int main() { assert(relays[0].smarthost == "smtp.example.com:587"); auto profiles = store.listTlsProfiles(); assert(profiles.size() == 1); assert(profiles[0].profile == "internal"); assert(profiles[0].selfSigned); assert(profiles.size() == 2); auto internal = std::find_if(profiles.begin(), profiles.end(), [](const auto &p) { return p.profile == "internal"; }); assert(internal != profiles.end()); assert(internal->selfSigned); auto shop = std::find_if(profiles.begin(), profiles.end(), [](const auto &p) { return p.profile == "shop"; }); assert(shop != profiles.end()); assert(!shop->certPem.empty()); // compact() must fold the WAL into a snapshot without losing data. store.compact(); Loading @@ -82,8 +114,7 @@ int main() { ConfigStore store(dir); assert(store.listHttpRoutes().size() == 1); assert(store.listSmtpRelayRules().size() == 1); assert(store.listTlsProfiles().size() == 1); assert(store.listTlsProfiles()[0].selfSigned); assert(store.listTlsProfiles().size() == 2); } std::system(("rm -rf " + dir).c_str()); Loading