-
Notifications
You must be signed in to change notification settings - Fork 94
Update Envoy to f95f5391b0b8683081ec786ea946026594955fc6 #562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
1a08d1d
e717c91
49106b6
dc0b618
6136e81
30d7f20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,17 +13,20 @@ FilterConfigurationBase::FilterConfigurationBase( | |
|
|
||
| void FilterConfigurationBase::computeEffectiveConfiguration( | ||
| const Envoy::Http::RequestHeaderMap& headers) { | ||
| const auto* request_config_header = headers.get(TestServer::HeaderNames::get().TestServerConfig); | ||
| if (request_config_header) { | ||
| const auto& request_config_header = headers.get(TestServer::HeaderNames::get().TestServerConfig); | ||
| if (request_config_header.size() == 1) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we have an else condition here now? again, taking into consideration receiving more than 1
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, you're right. Done in dc0b618 + explicit tests for the case. |
||
| nighthawk::server::ResponseOptions response_options = *server_config_; | ||
| std::string error_message; | ||
| if (Configuration::mergeJsonConfig(request_config_header->value().getStringView(), | ||
| if (Configuration::mergeJsonConfig(request_config_header[0]->value().getStringView(), | ||
| response_options, error_message)) { | ||
| effective_config_ = | ||
| std::make_shared<const nighthawk::server::ResponseOptions>(std::move(response_options)); | ||
| } else { | ||
| effective_config_ = absl::InvalidArgumentError(error_message); | ||
| } | ||
| } else if (request_config_header.size() > 1) { | ||
| effective_config_ = absl::InvalidArgumentError( | ||
| "Received multiple configuration headers in the request, expected only one."); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,5 +90,29 @@ TEST_P(HttpFilterBaseIntegrationTest, EmptyRequestLevelConfigurationShouldFail) | |
| EXPECT_THAT(response->body(), HasSubstr(kBadConfigErrorSentinel)); | ||
| } | ||
|
|
||
| TEST_P(HttpFilterBaseIntegrationTest, MultipleValidConfigurationHeadersFails) { | ||
| // Make sure we fail when two valid configuration headers are send. | ||
| setRequestLevelConfiguration("{}"); | ||
| appendRequestLevelConfiguration("{}"); | ||
| Envoy::IntegrationStreamDecoderPtr response = getResponse(ResponseOrigin::EXTENSION); | ||
| ASSERT_TRUE(response->complete()); | ||
| EXPECT_THAT(response->body(), | ||
| HasSubstr("Received multiple configuration headers in the request")); | ||
| } | ||
|
|
||
| TEST_P(HttpFilterBaseIntegrationTest, SingleValidPlusEmptyConfigurationHeadersFails) { | ||
| // Make sure we fail when both a valid configuration plus an empty configuration header is send. | ||
| // Note that we could be more flexible and look for the first request header that has a value, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This note seems like it belongs more in the function itself rather than in this test. Also, I might encourage a rephrase of why our approach is reasonable. Without understanding of a real use case for them, we are assuming that any existence of duplicate headers here is in error.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Amended this; also updated the Envoy dep to f95f5391b0b8683081ec786ea946026594955fc6 in here, as that didn't need require any changes on our side modulo updating the revision/sha in
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| // but I think the current behavior is reasonable: just assume the first request header will have | ||
| // the value we are after, and assume that multiple configuration headers indicate accidental user | ||
| // error. | ||
| setRequestLevelConfiguration("{}"); | ||
| appendRequestLevelConfiguration(""); | ||
| Envoy::IntegrationStreamDecoderPtr response = getResponse(ResponseOrigin::EXTENSION); | ||
| ASSERT_TRUE(response->complete()); | ||
| EXPECT_THAT(response->body(), | ||
| HasSubstr("Received multiple configuration headers in the request")); | ||
| } | ||
|
|
||
| } // namespace | ||
| } // namespace Nighthawk | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be the first instance where us just using envoy's .bazelrc isn't great for us. No action required here on this PR, but we should keep an eye on it.