From eed47664242cacbc91d9abf8094c0adde8ab1658 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Fri, 19 Aug 2022 17:19:46 -0700 Subject: [PATCH] rls_e2e_test: check authority on server side instead of using death test (#30652) --- test/cpp/end2end/rls_end2end_test.cc | 47 +++++----------------------- 1 file changed, 8 insertions(+), 39 deletions(-) diff --git a/test/cpp/end2end/rls_end2end_test.cc b/test/cpp/end2end/rls_end2end_test.cc index 7b0b9118604..a6951fe8e83 100644 --- a/test/cpp/end2end/rls_end2end_test.cc +++ b/test/cpp/end2end/rls_end2end_test.cc @@ -180,23 +180,16 @@ class RlsEnd2endTest : public ::testing::Test { EXPECT_THAT(ctx->client_metadata(), ::testing::Contains( ::testing::Pair(kCallCredsMdKey, kCallCredsMdValue))); + EXPECT_EQ(ctx->ExperimentalGetAuthority(), kServerName); }); rls_server_->Start(); + // Set up client. resolver_response_generator_ = absl::make_unique(); - ResetStub(); - } - - void TearDown() override { - ShutdownBackends(); - rls_server_->Shutdown(); - } - - void ResetStub(const char* expected_authority = kServerName) { ChannelArguments args; args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, resolver_response_generator_->Get()); - args.SetString(GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS, expected_authority); + args.SetString(GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS, kServerName); grpc_channel_credentials* channel_creds = grpc_fake_transport_security_credentials_create(); grpc_call_credentials* call_creds = grpc_md_only_test_credentials_create( @@ -211,6 +204,11 @@ class RlsEnd2endTest : public ::testing::Test { stub_ = grpc::testing::EchoTestService::NewStub(channel_); } + void TearDown() override { + ShutdownBackends(); + rls_server_->Shutdown(); + } + void ShutdownBackends() { for (auto& server : backends_) { server->Shutdown(); @@ -1379,35 +1377,6 @@ TEST_F(RlsEnd2endTest, ConnectivityStateTransientFailure) { channel_->GetState(/*try_to_connect=*/false)); } -TEST_F(RlsEnd2endTest, RlsAuthorityDeathTest) { - GTEST_FLAG_SET(death_test_style, "threadsafe"); - ResetStub("incorrect_authority"); - SetNextResolution( - MakeServiceConfigBuilder() - .AddKeyBuilder(absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\"" - " ]" - " }" - "]", - kServiceValue, kMethodValue, kTestKey)) - .Build()); - // Make sure that we blow up (via abort() from the security connector) when - // the authority for the RLS channel doesn't match expectations. - ASSERT_DEATH_IF_SUPPORTED( - { - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - }, - ""); -} - } // namespace } // namespace testing } // namespace grpc