rls_e2e_test: check authority on server side instead of using death test (#30652)

pull/30582/head^2
Mark D. Roth 2 years ago committed by GitHub
parent 9f9d87cfa6
commit eed4766424
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 47
      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<FakeResolverResponseGeneratorWrapper>();
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

Loading…
Cancel
Save