/proc/self/cwd/test/mocks/router/mocks.cc
Line | Count | Source (jump to first uncovered line) |
1 | | #include "mocks.h" |
2 | | |
3 | | #include <chrono> |
4 | | |
5 | | #include "gmock/gmock.h" |
6 | | #include "gtest/gtest.h" |
7 | | |
8 | | using testing::_; |
9 | | using testing::DoAll; |
10 | | using testing::Invoke; |
11 | | using testing::NiceMock; |
12 | | using testing::Return; |
13 | | using testing::ReturnPointee; |
14 | | using testing::ReturnRef; |
15 | | using testing::SaveArg; |
16 | | |
17 | | namespace Envoy { |
18 | | namespace Router { |
19 | | |
20 | 1 | MockDirectResponseEntry::MockDirectResponseEntry() = default; |
21 | 1 | MockDirectResponseEntry::~MockDirectResponseEntry() = default; |
22 | | |
23 | 11.9k | TestRetryPolicy::TestRetryPolicy() { num_retries_ = 1; } |
24 | | |
25 | 11.9k | TestRetryPolicy::~TestRetryPolicy() = default; |
26 | | |
27 | 11.9k | MockInternalRedirectPolicy::MockInternalRedirectPolicy() { |
28 | 11.9k | ON_CALL(*this, enabled()).WillByDefault(Return(false)); |
29 | 11.9k | } |
30 | | |
31 | 5 | MockRetryState::MockRetryState() = default; |
32 | | |
33 | 0 | void MockRetryState::expectHeadersRetry() { |
34 | 0 | EXPECT_CALL(*this, shouldRetryHeaders(_, _, _)) |
35 | 0 | .WillOnce(Invoke([this](const Http::ResponseHeaderMap&, const Http::RequestHeaderMap&, |
36 | 0 | DoRetryHeaderCallback callback) { |
37 | 0 | callback_ = [callback]() { callback(false); }; |
38 | 0 | return RetryStatus::Yes; |
39 | 0 | })); |
40 | 0 | } |
41 | | |
42 | 0 | void MockRetryState::expectHedgedPerTryTimeoutRetry() { |
43 | 0 | EXPECT_CALL(*this, shouldHedgeRetryPerTryTimeout(_)) |
44 | 0 | .WillOnce(DoAll(SaveArg<0>(&callback_), Return(RetryStatus::Yes))); |
45 | 0 | } |
46 | | |
47 | 0 | void MockRetryState::expectResetRetry() { |
48 | 0 | EXPECT_CALL(*this, shouldRetryReset(_, _, _, _)) |
49 | 0 | .WillOnce(Invoke([this](const Http::StreamResetReason, RetryState::Http3Used, |
50 | 0 | DoRetryResetCallback callback, bool) { |
51 | 0 | callback_ = [callback]() { callback(false); }; |
52 | 0 | return RetryStatus::Yes; |
53 | 0 | })); |
54 | 0 | } |
55 | | |
56 | 5 | MockRetryState::~MockRetryState() = default; |
57 | | |
58 | 0 | MockRateLimitPolicyEntry::MockRateLimitPolicyEntry() { |
59 | 0 | ON_CALL(*this, disableKey()).WillByDefault(ReturnRef(disable_key_)); |
60 | 0 | } |
61 | | |
62 | 0 | MockRateLimitPolicyEntry::~MockRateLimitPolicyEntry() = default; |
63 | | |
64 | 23.9k | MockRateLimitPolicy::MockRateLimitPolicy() { |
65 | 23.9k | ON_CALL(*this, getApplicableRateLimit(_)).WillByDefault(ReturnRef(rate_limit_policy_entry_)); |
66 | 23.9k | ON_CALL(*this, empty()).WillByDefault(Return(true)); |
67 | 23.9k | } |
68 | | |
69 | 23.9k | MockRateLimitPolicy::~MockRateLimitPolicy() = default; |
70 | | |
71 | 1 | MockShadowWriter::MockShadowWriter() = default; |
72 | 1 | MockShadowWriter::~MockShadowWriter() = default; |
73 | | |
74 | 11.9k | MockVirtualHost::MockVirtualHost() { |
75 | 11.9k | ON_CALL(*this, name()).WillByDefault(ReturnRef(name_)); |
76 | 11.9k | ON_CALL(*this, rateLimitPolicy()).WillByDefault(ReturnRef(rate_limit_policy_)); |
77 | 11.9k | ON_CALL(*this, metadata()).WillByDefault(ReturnRef(metadata_)); |
78 | 11.9k | ON_CALL(*this, typedMetadata()).WillByDefault(ReturnRef(typed_metadata_)); |
79 | 11.9k | ON_CALL(*this, virtualCluster(_)).WillByDefault(Return(&virtual_cluster_)); |
80 | 11.9k | } |
81 | | |
82 | 11.9k | MockVirtualHost::~MockVirtualHost() = default; |
83 | | |
84 | 11.9k | MockHashPolicy::MockHashPolicy() = default; |
85 | 11.9k | MockHashPolicy::~MockHashPolicy() = default; |
86 | | |
87 | 11.9k | MockMetadataMatchCriteria::MockMetadataMatchCriteria() = default; |
88 | 11.9k | MockMetadataMatchCriteria::~MockMetadataMatchCriteria() = default; |
89 | | |
90 | 11.9k | MockTlsContextMatchCriteria::MockTlsContextMatchCriteria() = default; |
91 | 11.9k | MockTlsContextMatchCriteria::~MockTlsContextMatchCriteria() = default; |
92 | | |
93 | 11.9k | MockPathMatchCriterion::MockPathMatchCriterion() { |
94 | 11.9k | ON_CALL(*this, matchType()).WillByDefault(ReturnPointee(&type_)); |
95 | 11.9k | ON_CALL(*this, matcher()).WillByDefault(ReturnPointee(&matcher_)); |
96 | 11.9k | } |
97 | | |
98 | 11.9k | MockPathMatchCriterion::~MockPathMatchCriterion() = default; |
99 | | |
100 | 11.9k | MockRouteEntry::MockRouteEntry() { |
101 | 11.9k | ON_CALL(*this, clusterName()).WillByDefault(ReturnRef(cluster_name_)); |
102 | 11.9k | ON_CALL(*this, getRequestHostValue(_)) |
103 | 11.9k | .WillByDefault([](const Http::RequestHeaderMap& headers) -> std::string { |
104 | 0 | return std::string(headers.getHostValue()); |
105 | 0 | }); |
106 | 11.9k | ON_CALL(*this, opaqueConfig()).WillByDefault(ReturnRef(opaque_config_)); |
107 | 11.9k | ON_CALL(*this, rateLimitPolicy()).WillByDefault(ReturnRef(rate_limit_policy_)); |
108 | 11.9k | ON_CALL(*this, retryPolicy()).WillByDefault(ReturnRef(retry_policy_)); |
109 | 11.9k | ON_CALL(*this, internalRedirectPolicy()).WillByDefault(ReturnRef(internal_redirect_policy_)); |
110 | 11.9k | ON_CALL(*this, retryShadowBufferLimit()) |
111 | 11.9k | .WillByDefault(Return(std::numeric_limits<uint32_t>::max())); |
112 | 11.9k | ON_CALL(*this, shadowPolicies()).WillByDefault(ReturnRef(shadow_policies_)); |
113 | 11.9k | ON_CALL(*this, timeout()).WillByDefault(Return(std::chrono::milliseconds(10))); |
114 | 11.9k | ON_CALL(*this, includeVirtualHostRateLimits()).WillByDefault(Return(true)); |
115 | 11.9k | ON_CALL(*this, pathMatchCriterion()).WillByDefault(ReturnRef(path_match_criterion_)); |
116 | 11.9k | ON_CALL(*this, upgradeMap()).WillByDefault(ReturnRef(upgrade_map_)); |
117 | 11.9k | ON_CALL(*this, hedgePolicy()).WillByDefault(ReturnRef(hedge_policy_)); |
118 | 11.9k | ON_CALL(*this, connectConfig()).WillByDefault(Invoke([this]() { |
119 | 5 | return connect_config_.has_value() ? makeOptRef(connect_config_.value()) : absl::nullopt; |
120 | 5 | })); |
121 | 11.9k | ON_CALL(*this, earlyDataPolicy()).WillByDefault(ReturnRef(early_data_policy_)); |
122 | 11.9k | path_matcher_ = std::make_shared<testing::NiceMock<MockPathMatcher>>(); |
123 | 11.9k | ON_CALL(*this, pathMatcher()).WillByDefault(ReturnRef(path_matcher_)); |
124 | 11.9k | path_rewriter_ = std::make_shared<testing::NiceMock<MockPathRewriter>>(); |
125 | 11.9k | ON_CALL(*this, pathRewriter()).WillByDefault(ReturnRef(path_rewriter_)); |
126 | 11.9k | ON_CALL(*this, routeStatsContext()).WillByDefault(Return(RouteStatsContextOptRef())); |
127 | 11.9k | } |
128 | | |
129 | 11.9k | MockRouteEntry::~MockRouteEntry() = default; |
130 | | |
131 | 2.39k | MockConfig::MockConfig() : route_(new NiceMock<MockRoute>()) { |
132 | 2.39k | ON_CALL(*this, route(_, _, _)).WillByDefault(Return(route_)); |
133 | 2.39k | ON_CALL(*this, route(_, _, _, _)).WillByDefault(Return(route_)); |
134 | 2.39k | ON_CALL(*this, internalOnlyHeaders()).WillByDefault(ReturnRef(internal_only_headers_)); |
135 | 2.39k | ON_CALL(*this, name()).WillByDefault(ReturnRef(name_)); |
136 | 2.39k | ON_CALL(*this, usesVhds()).WillByDefault(Return(false)); |
137 | 2.39k | ON_CALL(*this, metadata()).WillByDefault(ReturnRef(metadata_)); |
138 | 2.39k | ON_CALL(*this, typedMetadata()).WillByDefault(ReturnRef(typed_metadata_)); |
139 | 2.39k | } |
140 | | |
141 | 2.39k | MockConfig::~MockConfig() = default; |
142 | | |
143 | 11.9k | MockDecorator::MockDecorator() { |
144 | 11.9k | ON_CALL(*this, getOperation()).WillByDefault(ReturnRef(operation_)); |
145 | 11.9k | ON_CALL(*this, propagate()).WillByDefault(Return(true)); |
146 | 11.9k | } |
147 | 11.9k | MockDecorator::~MockDecorator() = default; |
148 | | |
149 | 11.9k | MockRouteTracing::MockRouteTracing() = default; |
150 | 11.9k | MockRouteTracing::~MockRouteTracing() = default; |
151 | | |
152 | 11.9k | MockRoute::MockRoute() { |
153 | 11.9k | ON_CALL(*this, routeEntry()).WillByDefault(Return(&route_entry_)); |
154 | 11.9k | ON_CALL(*this, decorator()).WillByDefault(Return(&decorator_)); |
155 | 11.9k | ON_CALL(*this, tracingConfig()).WillByDefault(Return(nullptr)); |
156 | 11.9k | ON_CALL(*this, metadata()).WillByDefault(ReturnRef(metadata_)); |
157 | 11.9k | ON_CALL(*this, typedMetadata()).WillByDefault(ReturnRef(typed_metadata_)); |
158 | 11.9k | ON_CALL(*this, routeName()).WillByDefault(ReturnRef(route_name_)); |
159 | 11.9k | ON_CALL(*this, virtualHost()).WillByDefault(ReturnRef(virtual_host_)); |
160 | 11.9k | } |
161 | 11.9k | MockRoute::~MockRoute() = default; |
162 | | |
163 | 1.19k | MockRouteConfigProvider::MockRouteConfigProvider() { |
164 | 1.19k | ON_CALL(*this, config()).WillByDefault(Return(route_config_)); |
165 | 1.19k | ON_CALL(*this, configCast()).WillByDefault(Return(route_config_)); |
166 | 1.19k | } |
167 | 1.19k | MockRouteConfigProvider::~MockRouteConfigProvider() = default; |
168 | | |
169 | 0 | MockRouteConfigProviderManager::MockRouteConfigProviderManager() = default; |
170 | 0 | MockRouteConfigProviderManager::~MockRouteConfigProviderManager() = default; |
171 | | |
172 | 1.19k | MockScopedConfig::MockScopedConfig() { |
173 | 1.19k | ON_CALL(*this, getRouteConfig(_)).WillByDefault(Return(route_config_)); |
174 | 1.19k | } |
175 | 1.19k | MockScopedConfig::~MockScopedConfig() = default; |
176 | | |
177 | | MockScopedRouteConfigProvider::MockScopedRouteConfigProvider() |
178 | 1.19k | : config_(std::make_shared<MockScopedConfig>()) { |
179 | 1.19k | ON_CALL(*this, getConfig()).WillByDefault(Return(config_)); |
180 | 1.19k | ON_CALL(*this, apiType()).WillByDefault(Return(ApiType::Delta)); |
181 | 1.19k | } |
182 | 1.19k | MockScopedRouteConfigProvider::~MockScopedRouteConfigProvider() = default; |
183 | | |
184 | 1.19k | MockScopeKeyBuilder::MockScopeKeyBuilder() { |
185 | 1.19k | ON_CALL(*this, computeScopeKey(_)) |
186 | 1.19k | .WillByDefault(Invoke([](const Http::HeaderMap&) -> ScopeKeyPtr { return nullptr; })); |
187 | 1.19k | } |
188 | 1.19k | MockScopeKeyBuilder::~MockScopeKeyBuilder() = default; |
189 | | |
190 | 5 | MockGenericConnPool::MockGenericConnPool() { ON_CALL(*this, host()).WillByDefault(Return(host_)); } |
191 | 5 | MockGenericConnPool::~MockGenericConnPool() = default; |
192 | | |
193 | 0 | MockGenericConnectionPoolCallbacks::MockGenericConnectionPoolCallbacks() { |
194 | 0 | ON_CALL(*this, upstreamToDownstream()).WillByDefault(ReturnRef(upstream_to_downstream_)); |
195 | 0 | } |
196 | | |
197 | 0 | MockClusterSpecifierPlugin::MockClusterSpecifierPlugin() { |
198 | 0 | ON_CALL(*this, route(_, _)).WillByDefault(Return(nullptr)); |
199 | 0 | } |
200 | | |
201 | 0 | MockClusterSpecifierPluginFactoryConfig::MockClusterSpecifierPluginFactoryConfig() { |
202 | 0 | ON_CALL(*this, createClusterSpecifierPlugin(_, _)).WillByDefault(Return(nullptr)); |
203 | 0 | } |
204 | | |
205 | | } // namespace Router |
206 | | } // namespace Envoy |