|
|
|
@ -180,7 +180,8 @@ TEST_F(XdsRouterFilterTest, GenerateFilterConfig) { |
|
|
|
|
XdsExtension extension = MakeXdsExtension(Router()); |
|
|
|
|
auto config = filter_->GenerateFilterConfig(decode_context_, |
|
|
|
|
std::move(extension), &errors_); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status("unexpected errors"); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status( |
|
|
|
|
absl::StatusCode::kInvalidArgument, "unexpected errors"); |
|
|
|
|
ASSERT_TRUE(config.has_value()); |
|
|
|
|
EXPECT_EQ(config->config_proto_type_name, filter_->ConfigProtoName()); |
|
|
|
|
EXPECT_EQ(config->config, Json()) << JsonDump(config->config); |
|
|
|
@ -191,7 +192,8 @@ TEST_F(XdsRouterFilterTest, GenerateFilterConfigTypedStruct) { |
|
|
|
|
extension.value = Json(); |
|
|
|
|
auto config = filter_->GenerateFilterConfig(decode_context_, |
|
|
|
|
std::move(extension), &errors_); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
status.message(), |
|
|
|
@ -207,7 +209,8 @@ TEST_F(XdsRouterFilterTest, GenerateFilterConfigUnparseable) { |
|
|
|
|
extension.value = absl::string_view(serialized_resource); |
|
|
|
|
auto config = filter_->GenerateFilterConfig(decode_context_, |
|
|
|
|
std::move(extension), &errors_); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
status.message(), |
|
|
|
@ -221,7 +224,8 @@ TEST_F(XdsRouterFilterTest, GenerateFilterConfigOverride) { |
|
|
|
|
XdsExtension extension = MakeXdsExtension(Router()); |
|
|
|
|
auto config = filter_->GenerateFilterConfigOverride( |
|
|
|
|
decode_context_, std::move(extension), &errors_); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
status.message(), |
|
|
|
@ -308,7 +312,8 @@ INSTANTIATE_TEST_SUITE_P(XdsFaultFilter, XdsFaultInjectionFilterConfigTest, |
|
|
|
|
TEST_P(XdsFaultInjectionFilterConfigTest, EmptyConfig) { |
|
|
|
|
XdsExtension extension = MakeXdsExtension(HTTPFault()); |
|
|
|
|
auto config = GenerateConfig(std::move(extension)); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status("unexpected errors"); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status( |
|
|
|
|
absl::StatusCode::kInvalidArgument, "unexpected errors"); |
|
|
|
|
ASSERT_TRUE(config.has_value()); |
|
|
|
|
EXPECT_EQ(config->config_proto_type_name, filter_->ConfigProtoName()); |
|
|
|
|
EXPECT_EQ(config->config, Json(Json::Object())) << JsonDump(config->config); |
|
|
|
@ -327,7 +332,8 @@ TEST_P(XdsFaultInjectionFilterConfigTest, BasicConfig) { |
|
|
|
|
fault.mutable_max_active_faults()->set_value(10); |
|
|
|
|
XdsExtension extension = MakeXdsExtension(fault); |
|
|
|
|
auto config = GenerateConfig(std::move(extension)); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status("unexpected errors"); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status( |
|
|
|
|
absl::StatusCode::kInvalidArgument, "unexpected errors"); |
|
|
|
|
ASSERT_TRUE(config.has_value()); |
|
|
|
|
EXPECT_EQ(config->config_proto_type_name, filter_->ConfigProtoName()); |
|
|
|
|
EXPECT_EQ(JsonDump(config->config), |
|
|
|
@ -346,7 +352,8 @@ TEST_P(XdsFaultInjectionFilterConfigTest, HttpAbortCode) { |
|
|
|
|
abort->set_http_status(404); |
|
|
|
|
XdsExtension extension = MakeXdsExtension(fault); |
|
|
|
|
auto config = GenerateConfig(std::move(extension)); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status("unexpected errors"); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status( |
|
|
|
|
absl::StatusCode::kInvalidArgument, "unexpected errors"); |
|
|
|
|
ASSERT_TRUE(config.has_value()); |
|
|
|
|
EXPECT_EQ(config->config_proto_type_name, filter_->ConfigProtoName()); |
|
|
|
|
EXPECT_EQ(JsonDump(config->config), "{\"abortCode\":\"UNIMPLEMENTED\"}"); |
|
|
|
@ -358,7 +365,8 @@ TEST_P(XdsFaultInjectionFilterConfigTest, HeaderAbortAndDelay) { |
|
|
|
|
fault.mutable_delay()->mutable_header_delay(); |
|
|
|
|
XdsExtension extension = MakeXdsExtension(fault); |
|
|
|
|
auto config = GenerateConfig(std::move(extension)); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status("unexpected errors"); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status( |
|
|
|
|
absl::StatusCode::kInvalidArgument, "unexpected errors"); |
|
|
|
|
ASSERT_TRUE(config.has_value()); |
|
|
|
|
EXPECT_EQ(config->config_proto_type_name, filter_->ConfigProtoName()); |
|
|
|
|
EXPECT_EQ( |
|
|
|
@ -375,7 +383,8 @@ TEST_P(XdsFaultInjectionFilterConfigTest, InvalidGrpcStatusCode) { |
|
|
|
|
fault.mutable_abort()->set_grpc_status(17); |
|
|
|
|
XdsExtension extension = MakeXdsExtension(fault); |
|
|
|
|
auto config = GenerateConfig(std::move(extension)); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ(status.message(), |
|
|
|
|
"errors validating filter config: [" |
|
|
|
@ -390,7 +399,8 @@ TEST_P(XdsFaultInjectionFilterConfigTest, InvalidDuration) { |
|
|
|
|
fault.mutable_delay()->mutable_fixed_delay()->set_seconds(315576000001); |
|
|
|
|
XdsExtension extension = MakeXdsExtension(fault); |
|
|
|
|
auto config = GenerateConfig(std::move(extension)); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ(status.message(), |
|
|
|
|
"errors validating filter config: [" |
|
|
|
@ -404,7 +414,8 @@ TEST_P(XdsFaultInjectionFilterConfigTest, TypedStruct) { |
|
|
|
|
XdsExtension extension = MakeXdsExtension(HTTPFault()); |
|
|
|
|
extension.value = Json(); |
|
|
|
|
auto config = GenerateConfig(std::move(extension)); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ(status.message(), |
|
|
|
|
"errors validating filter config: [" |
|
|
|
@ -418,7 +429,8 @@ TEST_P(XdsFaultInjectionFilterConfigTest, Unparseable) { |
|
|
|
|
std::string serialized_resource("\0", 1); |
|
|
|
|
extension.value = absl::string_view(serialized_resource); |
|
|
|
|
auto config = GenerateConfig(std::move(extension)); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ(status.message(), |
|
|
|
|
"errors validating filter config: [" |
|
|
|
@ -464,7 +476,8 @@ TEST_F(XdsRbacFilterTest, GenerateFilterConfig) { |
|
|
|
|
XdsExtension extension = MakeXdsExtension(RBAC()); |
|
|
|
|
auto config = filter_->GenerateFilterConfig(decode_context_, |
|
|
|
|
std::move(extension), &errors_); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status("unexpected errors"); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status( |
|
|
|
|
absl::StatusCode::kInvalidArgument, "unexpected errors"); |
|
|
|
|
ASSERT_TRUE(config.has_value()); |
|
|
|
|
EXPECT_EQ(config->config_proto_type_name, filter_->ConfigProtoName()); |
|
|
|
|
EXPECT_EQ(config->config, Json(Json::Object())) << JsonDump(config->config); |
|
|
|
@ -475,7 +488,8 @@ TEST_F(XdsRbacFilterTest, GenerateFilterConfigTypedStruct) { |
|
|
|
|
extension.value = Json(); |
|
|
|
|
auto config = filter_->GenerateFilterConfig(decode_context_, |
|
|
|
|
std::move(extension), &errors_); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
status.message(), |
|
|
|
@ -491,7 +505,8 @@ TEST_F(XdsRbacFilterTest, GenerateFilterConfigUnparseable) { |
|
|
|
|
extension.value = absl::string_view(serialized_resource); |
|
|
|
|
auto config = filter_->GenerateFilterConfig(decode_context_, |
|
|
|
|
std::move(extension), &errors_); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
status.message(), |
|
|
|
@ -505,7 +520,8 @@ TEST_F(XdsRbacFilterTest, GenerateFilterConfigOverride) { |
|
|
|
|
XdsExtension extension = MakeXdsExtension(RBACPerRoute()); |
|
|
|
|
auto config = filter_->GenerateFilterConfigOverride( |
|
|
|
|
decode_context_, std::move(extension), &errors_); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status("unexpected errors"); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status( |
|
|
|
|
absl::StatusCode::kInvalidArgument, "unexpected errors"); |
|
|
|
|
ASSERT_TRUE(config.has_value()); |
|
|
|
|
EXPECT_EQ(config->config_proto_type_name, filter_->OverrideConfigProtoName()); |
|
|
|
|
EXPECT_EQ(config->config, Json(Json::Object())) << JsonDump(config->config); |
|
|
|
@ -516,7 +532,8 @@ TEST_F(XdsRbacFilterTest, GenerateFilterConfigOverrideTypedStruct) { |
|
|
|
|
extension.value = Json(); |
|
|
|
|
auto config = filter_->GenerateFilterConfigOverride( |
|
|
|
|
decode_context_, std::move(extension), &errors_); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ(status.message(), |
|
|
|
|
"errors validating filter config: [" |
|
|
|
@ -531,7 +548,8 @@ TEST_F(XdsRbacFilterTest, GenerateFilterConfigOverrideUnparseable) { |
|
|
|
|
extension.value = absl::string_view(serialized_resource); |
|
|
|
|
auto config = filter_->GenerateFilterConfigOverride( |
|
|
|
|
decode_context_, std::move(extension), &errors_); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ(status.message(), |
|
|
|
|
"errors validating filter config: [" |
|
|
|
@ -572,7 +590,8 @@ INSTANTIATE_TEST_SUITE_P(XdsRbacFilter, XdsRbacFilterConfigTest, |
|
|
|
|
|
|
|
|
|
TEST_P(XdsRbacFilterConfigTest, EmptyConfig) { |
|
|
|
|
auto config = GenerateConfig(RBAC()); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status("unexpected errors"); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status( |
|
|
|
|
absl::StatusCode::kInvalidArgument, "unexpected errors"); |
|
|
|
|
ASSERT_TRUE(config.has_value()); |
|
|
|
|
EXPECT_EQ(config->config_proto_type_name, |
|
|
|
|
GetParam() ? filter_->OverrideConfigProtoName() |
|
|
|
@ -658,7 +677,8 @@ TEST_P(XdsRbacFilterConfigTest, AllPermissionTypes) { |
|
|
|
|
// or
|
|
|
|
|
policy.add_permissions()->mutable_or_rules()->add_rules()->set_any(true); |
|
|
|
|
auto config = GenerateConfig(rbac); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status("unexpected errors"); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status( |
|
|
|
|
absl::StatusCode::kInvalidArgument, "unexpected errors"); |
|
|
|
|
ASSERT_TRUE(config.has_value()); |
|
|
|
|
EXPECT_EQ(config->config_proto_type_name, |
|
|
|
|
GetParam() ? filter_->OverrideConfigProtoName() |
|
|
|
@ -784,7 +804,8 @@ TEST_P(XdsRbacFilterConfigTest, AllPrincipalTypes) { |
|
|
|
|
// or
|
|
|
|
|
policy.add_principals()->mutable_or_ids()->add_ids()->set_any(true); |
|
|
|
|
auto config = GenerateConfig(rbac); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status("unexpected errors"); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status( |
|
|
|
|
absl::StatusCode::kInvalidArgument, "unexpected errors"); |
|
|
|
|
ASSERT_TRUE(config.has_value()); |
|
|
|
|
EXPECT_EQ(config->config_proto_type_name, |
|
|
|
|
GetParam() ? filter_->OverrideConfigProtoName() |
|
|
|
@ -834,7 +855,8 @@ TEST_P(XdsRbacFilterConfigTest, InvalidFieldsInPolicy) { |
|
|
|
|
policy.mutable_condition(); |
|
|
|
|
policy.mutable_checked_condition(); |
|
|
|
|
auto config = GenerateConfig(rbac); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ(status.message(), |
|
|
|
|
absl::StrCat("errors validating filter config: [" |
|
|
|
@ -863,7 +885,8 @@ TEST_P(XdsRbacFilterConfigTest, InvalidHeaderMatchers) { |
|
|
|
|
header = policy.add_principals()->mutable_header(); |
|
|
|
|
header->set_name("header_name"); |
|
|
|
|
auto config = GenerateConfig(rbac); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
status.message(), |
|
|
|
@ -891,7 +914,8 @@ TEST_P(XdsRbacFilterConfigTest, InvalidStringMatchers) { |
|
|
|
|
policy.add_permissions()->mutable_url_path()->mutable_path(); |
|
|
|
|
policy.add_principals()->mutable_url_path(); |
|
|
|
|
auto config = GenerateConfig(rbac); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
status.message(), |
|
|
|
@ -915,7 +939,8 @@ TEST_P(XdsRbacFilterConfigTest, InvalidPermissionAndPrincipal) { |
|
|
|
|
policy.add_permissions(); |
|
|
|
|
policy.add_principals(); |
|
|
|
|
auto config = GenerateConfig(rbac); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ(status.message(), |
|
|
|
|
absl::StrCat("errors validating filter config: [" |
|
|
|
@ -984,7 +1009,8 @@ TEST_F(XdsStatefulSessionFilterTest, OverrideConfigDisabled) { |
|
|
|
|
XdsExtension extension = MakeXdsExtension(stateful_session_per_route); |
|
|
|
|
auto config = filter_->GenerateFilterConfigOverride( |
|
|
|
|
decode_context_, std::move(extension), &errors_); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status("unexpected errors"); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status( |
|
|
|
|
absl::StatusCode::kInvalidArgument, "unexpected errors"); |
|
|
|
|
ASSERT_TRUE(config.has_value()); |
|
|
|
|
EXPECT_EQ(config->config_proto_type_name, filter_->OverrideConfigProtoName()); |
|
|
|
|
EXPECT_EQ(config->config, Json(Json::Object{})) << JsonDump(config->config); |
|
|
|
@ -1015,7 +1041,8 @@ TEST_F(XdsStatefulSessionFilterTest, GenerateFilterConfigTypedStruct) { |
|
|
|
|
extension.value = Json(); |
|
|
|
|
auto config = filter_->GenerateFilterConfig(decode_context_, |
|
|
|
|
std::move(extension), &errors_); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
status.message(), |
|
|
|
@ -1032,7 +1059,8 @@ TEST_F(XdsStatefulSessionFilterTest, GenerateFilterConfigUnparseable) { |
|
|
|
|
extension.value = absl::string_view(serialized_resource); |
|
|
|
|
auto config = filter_->GenerateFilterConfig(decode_context_, |
|
|
|
|
std::move(extension), &errors_); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
status.message(), |
|
|
|
@ -1048,7 +1076,8 @@ TEST_F(XdsStatefulSessionFilterTest, GenerateFilterConfigOverrideTypedStruct) { |
|
|
|
|
extension.value = Json(); |
|
|
|
|
auto config = filter_->GenerateFilterConfigOverride( |
|
|
|
|
decode_context_, std::move(extension), &errors_); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ(status.message(), |
|
|
|
|
"errors validating filter config: [" |
|
|
|
@ -1065,7 +1094,8 @@ TEST_F(XdsStatefulSessionFilterTest, GenerateFilterConfigOverrideUnparseable) { |
|
|
|
|
extension.value = absl::string_view(serialized_resource); |
|
|
|
|
auto config = filter_->GenerateFilterConfigOverride( |
|
|
|
|
decode_context_, std::move(extension), &errors_); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ(status.message(), |
|
|
|
|
"errors validating filter config: [" |
|
|
|
@ -1115,7 +1145,8 @@ TEST_P(XdsStatefulSessionFilterConfigTest, MinimalConfig) { |
|
|
|
|
stateful_session.mutable_session_state()->mutable_typed_config()->PackFrom( |
|
|
|
|
cookie_state); |
|
|
|
|
auto config = GenerateConfig(stateful_session); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status("unexpected errors"); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status( |
|
|
|
|
absl::StatusCode::kInvalidArgument, "unexpected errors"); |
|
|
|
|
ASSERT_TRUE(config.has_value()); |
|
|
|
|
EXPECT_EQ(config->config_proto_type_name, |
|
|
|
|
GetParam() ? filter_->OverrideConfigProtoName() |
|
|
|
@ -1134,7 +1165,8 @@ TEST_P(XdsStatefulSessionFilterConfigTest, PathAndTtl) { |
|
|
|
|
stateful_session.mutable_session_state()->mutable_typed_config()->PackFrom( |
|
|
|
|
cookie_state); |
|
|
|
|
auto config = GenerateConfig(stateful_session); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status("unexpected errors"); |
|
|
|
|
ASSERT_TRUE(errors_.ok()) << errors_.status( |
|
|
|
|
absl::StatusCode::kInvalidArgument, "unexpected errors"); |
|
|
|
|
ASSERT_TRUE(config.has_value()); |
|
|
|
|
EXPECT_EQ(config->config_proto_type_name, |
|
|
|
|
GetParam() ? filter_->OverrideConfigProtoName() |
|
|
|
@ -1149,7 +1181,8 @@ TEST_P(XdsStatefulSessionFilterConfigTest, PathAndTtl) { |
|
|
|
|
|
|
|
|
|
TEST_P(XdsStatefulSessionFilterConfigTest, SessionStateUnset) { |
|
|
|
|
auto config = GenerateConfig(StatefulSession()); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
ASSERT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
status.message(), |
|
|
|
@ -1163,7 +1196,8 @@ TEST_P(XdsStatefulSessionFilterConfigTest, CookieNotPresent) { |
|
|
|
|
stateful_session.mutable_session_state()->mutable_typed_config()->PackFrom( |
|
|
|
|
CookieBasedSessionState()); |
|
|
|
|
auto config = GenerateConfig(stateful_session); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
ASSERT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
status.message(), |
|
|
|
@ -1182,7 +1216,8 @@ TEST_P(XdsStatefulSessionFilterConfigTest, CookieNameNotPresent) { |
|
|
|
|
stateful_session.mutable_session_state()->mutable_typed_config()->PackFrom( |
|
|
|
|
cookie_state); |
|
|
|
|
auto config = GenerateConfig(stateful_session); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
ASSERT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
status.message(), |
|
|
|
@ -1203,7 +1238,8 @@ TEST_P(XdsStatefulSessionFilterConfigTest, InvalidTtl) { |
|
|
|
|
stateful_session.mutable_session_state()->mutable_typed_config()->PackFrom( |
|
|
|
|
cookie_state); |
|
|
|
|
auto config = GenerateConfig(stateful_session); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
ASSERT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
status.message(), |
|
|
|
@ -1220,7 +1256,8 @@ TEST_P(XdsStatefulSessionFilterConfigTest, UnknownSessionStateType) { |
|
|
|
|
stateful_session.mutable_session_state()->mutable_typed_config()->PackFrom( |
|
|
|
|
Router()); |
|
|
|
|
auto config = GenerateConfig(stateful_session); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
ASSERT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
status.message(), |
|
|
|
@ -1240,7 +1277,8 @@ TEST_P(XdsStatefulSessionFilterConfigTest, TypedStructSessionState) { |
|
|
|
|
typed_struct.set_type_url(typed_config->type_url()); |
|
|
|
|
typed_config->PackFrom(typed_struct); |
|
|
|
|
auto config = GenerateConfig(stateful_session); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
ASSERT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
status.message(), |
|
|
|
@ -1260,7 +1298,8 @@ TEST_P(XdsStatefulSessionFilterConfigTest, UnparseableSessionState) { |
|
|
|
|
stateful_session.mutable_session_state()->mutable_typed_config()->set_value( |
|
|
|
|
std::string("\0", 1)); |
|
|
|
|
auto config = GenerateConfig(stateful_session); |
|
|
|
|
absl::Status status = errors_.status("errors validating filter config"); |
|
|
|
|
absl::Status status = errors_.status(absl::StatusCode::kInvalidArgument, |
|
|
|
|
"errors validating filter config"); |
|
|
|
|
ASSERT_EQ(status.code(), absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
status.message(), |
|
|
|
|