Skip to content

Commit

Permalink
fix rate limit descriptors
Browse files Browse the repository at this point in the history
Signed-off-by: wangbaiping(wbpcode) <[email protected]>
  • Loading branch information
wbpcode committed Dec 11, 2024
1 parent 8c523e5 commit 18489a3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions test/extensions/rate_limit_descriptors/expr/config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class RateLimitPolicyEntryTest : public testing::Test {
absl::Status creation_status;
rate_limit_entry_ =
std::make_unique<Router::RateLimitPolicyEntryImpl>(rate_limit, context_, creation_status);
THROW_IF_NOT_OK(creation_status);
THROW_IF_NOT_OK_REF(creation_status);
}

NiceMock<Server::Configuration::MockServerFactoryContext> context_;
Expand Down Expand Up @@ -84,8 +84,9 @@ TEST_F(RateLimitPolicyEntryTest, ExpressionText) {
Http::TestRequestHeaderMapImpl header{{"x-header-name", "test_value"}};

rate_limit_entry_->populateDescriptors(descriptors_, "service_cluster", header, stream_info_);
EXPECT_THAT(std::vector<Envoy::RateLimit::Descriptor>({{{{"my_descriptor_name", "test_value"}}}}),
testing::ContainerEq(descriptors_));
EXPECT_THAT(
std::vector<Envoy::RateLimit::Descriptor>({{{{{"my_descriptor_name", "test_value"}}}}}),
testing::ContainerEq(descriptors_));
}

TEST_F(RateLimitPolicyEntryTest, ExpressionTextMalformed) {
Expand Down Expand Up @@ -143,7 +144,7 @@ TEST_F(RateLimitPolicyEntryTest, ExpressionParsed) {
Http::TestRequestHeaderMapImpl header{{":method", "GET"}};

rate_limit_entry_->populateDescriptors(descriptors_, "service_cluster", header, stream_info_);
EXPECT_THAT(std::vector<Envoy::RateLimit::Descriptor>({{{{"my_descriptor_name", "true"}}}}),
EXPECT_THAT(std::vector<Envoy::RateLimit::Descriptor>({{{{{"my_descriptor_name", "true"}}}}}),
testing::ContainerEq(descriptors_));
}

Expand Down Expand Up @@ -211,7 +212,7 @@ TEST_F(RateLimitPolicyEntryTest, ExpressionTextErrorSkip) {
setupTest(yaml);

rate_limit_entry_->populateDescriptors(descriptors_, "service_cluster", header_, stream_info_);
EXPECT_THAT(std::vector<Envoy::RateLimit::Descriptor>({{{{"test_key", "a"}}}}),
EXPECT_THAT(std::vector<Envoy::RateLimit::Descriptor>({{{{{"test_key", "a"}}}}}),
testing::ContainerEq(descriptors_));
}
#endif
Expand Down

0 comments on commit 18489a3

Please sign in to comment.