@@ -37,16 +37,15 @@ namespace Cilium {
37
37
38
38
#define ON_CALL_SDS_SECRET_PROVIDER (SECRET_MANAGER, PROVIDER_TYPE, API_TYPE ) \
39
39
ON_CALL (SECRET_MANAGER, findOrCreate##PROVIDER_TYPE##Provider(_, _, _, _)) \
40
- .WillByDefault( \
41
- Invoke ([](const envoy::config::core::v3::ConfigSource& sds_config_source, \
42
- const std::string& config_name, \
43
- Server::Configuration::TransportSocketFactoryContext& secret_provider_context, \
44
- Init::Manager& init_manager) { \
45
- auto secret_provider = Secret::API_TYPE##SdsApi::create ( \
46
- secret_provider_context, sds_config_source, config_name, []() {}); \
47
- init_manager.add (*secret_provider->initTarget ()); \
48
- return secret_provider; \
49
- }))
40
+ .WillByDefault(Invoke([](const envoy::config::core::v3::ConfigSource& sds_config_source, \
41
+ const std::string& config_name, \
42
+ Server::Configuration::ServerFactoryContext& server_context, \
43
+ Init::Manager& init_manager) { \
44
+ auto secret_provider = Secret::API_TYPE##SdsApi::create (server_context, sds_config_source, \
45
+ config_name, []() {}); \
46
+ init_manager.add (*secret_provider->initTarget ()); \
47
+ return secret_provider; \
48
+ }))
50
49
51
50
class CiliumNetworkPolicyTest : public ::testing::Test {
52
51
protected:
@@ -60,13 +59,14 @@ class CiliumNetworkPolicyTest : public ::testing::Test {
60
59
void SetUp () override {
61
60
// Mock SDS secrets with a real implementation, which will not return anything if there is no
62
61
// SDS server. This is only useful for testing functionality with a missing secret.
63
- auto & secret_manager = factory_context_.server_factory_context_ .cluster_manager_
64
- .cluster_manager_factory_ .secretManager ();
65
- ON_CALL_SDS_SECRET_PROVIDER (secret_manager, TlsCertificate, TlsCertificate);
66
- ON_CALL_SDS_SECRET_PROVIDER (secret_manager, CertificateValidationContext,
62
+ ON_CALL (factory_context_.server_factory_context_ , secretManager ())
63
+ .WillByDefault (ReturnRef (secret_manager_));
64
+
65
+ ON_CALL_SDS_SECRET_PROVIDER (secret_manager_, TlsCertificate, TlsCertificate);
66
+ ON_CALL_SDS_SECRET_PROVIDER (secret_manager_, CertificateValidationContext,
67
67
CertificateValidationContext);
68
- ON_CALL_SDS_SECRET_PROVIDER (secret_manager , TlsSessionTicketKeysContext, TlsSessionTicketKeys);
69
- ON_CALL_SDS_SECRET_PROVIDER (secret_manager , GenericSecret, GenericSecret);
68
+ ON_CALL_SDS_SECRET_PROVIDER (secret_manager_ , TlsSessionTicketKeysContext, TlsSessionTicketKeys);
69
+ ON_CALL_SDS_SECRET_PROVIDER (secret_manager_ , GenericSecret, GenericSecret);
70
70
71
71
policy_map_ = std::make_shared<NetworkPolicyMap>(factory_context_);
72
72
}
@@ -211,6 +211,7 @@ class CiliumNetworkPolicyTest : public ::testing::Test {
211
211
}
212
212
213
213
NiceMock<Server::Configuration::MockFactoryContext> factory_context_;
214
+ NiceMock<Secret::MockSecretManager> secret_manager_;
214
215
std::shared_ptr<NetworkPolicyMap> policy_map_;
215
216
NiceMock<Stats::TestUtil::TestStore> store_;
216
217
uint32_t proxy_id_ = 42 ;
0 commit comments