diff options
author | Tor Brede Vekterli <vekterli@oath.com> | 2018-12-13 16:20:22 +0000 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@oath.com> | 2018-12-18 13:06:01 +0000 |
commit | c695946680c4df612adb3e5249bfea1a9bdf9cc3 (patch) | |
tree | 23cbf13cf95ad7d0d951c9b2754b18a708c51c4f /vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/auto_reloading_tls_crypto_engine_test.cpp | |
parent | b488e40f4ed89d73341ccf76bc96cba7a79a94f6 (diff) |
Add TLS statistics to vespalib and expose as metrics via storageserver
Now without unused expiry time extraction.
Diffstat (limited to 'vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/auto_reloading_tls_crypto_engine_test.cpp')
-rw-r--r-- | vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/auto_reloading_tls_crypto_engine_test.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/auto_reloading_tls_crypto_engine_test.cpp b/vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/auto_reloading_tls_crypto_engine_test.cpp index 245368b6a7b..5dc85bc567f 100644 --- a/vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/auto_reloading_tls_crypto_engine_test.cpp +++ b/vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/auto_reloading_tls_crypto_engine_test.cpp @@ -2,6 +2,7 @@ #include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/net/tls/auto_reloading_tls_crypto_engine.h> +#include <vespa/vespalib/net/tls/statistics.h> #include <vespa/vespalib/net/tls/transport_security_options.h> #include <vespa/vespalib/net/tls/transport_security_options_reading.h> #include <vespa/vespalib/net/tls/impl/openssl_tls_context_impl.h> @@ -106,17 +107,11 @@ struct Fixture { } vespalib::string current_cert_chain() const { - auto impl = engine->acquire_current_engine(); - // Leaks implementation details galore, but it's not very likely that we'll use - // anything but OpenSSL (or compatible APIs) in practice... - auto& ctx_impl = dynamic_cast<const impl::OpenSslTlsContextImpl&>(*impl->tls_context()); - return ctx_impl.transport_security_options().cert_chain_pem(); + return engine->acquire_current_engine()->tls_context()->transport_security_options().cert_chain_pem(); } AuthorizationMode current_authorization_mode() const { - auto impl = engine->acquire_current_engine(); - auto& ctx_impl = dynamic_cast<const impl::OpenSslTlsContextImpl&>(*impl->tls_context()); - return ctx_impl.authorization_mode(); + return engine->acquire_current_engine()->tls_context()->authorization_mode(); } }; @@ -143,4 +138,15 @@ TEST_FF("Authorization mode is propagated to engine", Fixture(50ms, Authorizatio EXPECT_EQUAL(AuthorizationMode::LogOnly, f1.current_authorization_mode()); } +TEST_FF("Config reload failure increments failure statistic", Fixture(50ms), TimeBomb(60)) { + auto before = ConfigStatistics::get().snapshot(); + + write_file("test_cert.pem.tmp", "Broken file oh no :("); + rename("test_cert.pem.tmp", "test_cert.pem", false, false); + + while (ConfigStatistics::get().snapshot().subtract(before).failed_config_reloads == 0) { + std::this_thread::sleep_for(10ms); + } +} + TEST_MAIN() { TEST_RUN_ALL(); } |