Skip to content

Commit faece1c

Browse files
sayborasviktor-kurchenko
authored andcommitted
Adjust cilium tests
Relates: envoyproxy/envoy#39460 Signed-off-by: Tam Mach <[email protected]>
1 parent 5886531 commit faece1c

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

tests/cilium_network_policy_test.cc

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,15 @@ namespace Cilium {
3737

3838
#define ON_CALL_SDS_SECRET_PROVIDER(SECRET_MANAGER, PROVIDER_TYPE, API_TYPE) \
3939
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+
}))
5049

5150
class CiliumNetworkPolicyTest : public ::testing::Test {
5251
protected:
@@ -60,13 +59,14 @@ class CiliumNetworkPolicyTest : public ::testing::Test {
6059
void SetUp() override {
6160
// Mock SDS secrets with a real implementation, which will not return anything if there is no
6261
// 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,
6767
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);
7070

7171
policy_map_ = std::make_shared<NetworkPolicyMap>(factory_context_);
7272
}
@@ -211,6 +211,7 @@ class CiliumNetworkPolicyTest : public ::testing::Test {
211211
}
212212

213213
NiceMock<Server::Configuration::MockFactoryContext> factory_context_;
214+
NiceMock<Secret::MockSecretManager> secret_manager_;
214215
std::shared_ptr<NetworkPolicyMap> policy_map_;
215216
NiceMock<Stats::TestUtil::TestStore> store_;
216217
uint32_t proxy_id_ = 42;

tests/metadata_config_test.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ class MetadataConfigTest : public testing::Test {
6060
logger.setLevel(spdlog::level::trace);
6161
}
6262

63-
ON_CALL(context_, getTransportSocketFactoryContext())
64-
.WillByDefault(ReturnRef(transport_socket_factory_context_));
65-
6663
ON_CALL(context_.server_factory_context_, api()).WillByDefault(testing::ReturnRef(*api_));
6764

6865
ON_CALL(context_.server_factory_context_.dispatcher_, createFilesystemWatcher_())

0 commit comments

Comments
 (0)