diff --git a/src/core/lib/security/credentials/composite/composite_credentials.h b/src/core/lib/security/credentials/composite/composite_credentials.h index 625593c5772bd..3e28060fa2534 100644 --- a/src/core/lib/security/credentials/composite/composite_credentials.h +++ b/src/core/lib/security/credentials/composite/composite_credentials.h @@ -55,7 +55,7 @@ class grpc_composite_channel_credentials : public grpc_channel_credentials { grpc_core::RefCountedPtr duplicate_without_call_credentials() override { - return inner_creds_; + return inner_creds_->duplicate_without_call_credentials(); } grpc_core::RefCountedPtr diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc index 22445c318668b..f0c0543275ccd 100644 --- a/test/core/security/credentials_test.cc +++ b/test/core/security/credentials_test.cc @@ -3878,6 +3878,22 @@ TEST(CredentialsTest, TestCompositeChannelCredsCompareSuccess) { grpc_channel_credentials_release(composite_creds_2); } +TEST(CredentialsTest, RecursiveCompositeCredsDuplicateWithoutCallCreds) { + auto* insecure_creds = grpc_insecure_credentials_create(); + auto inner_fake_creds = MakeRefCounted(); + auto outer_fake_creds = MakeRefCounted(); + auto* inner_composite_creds = grpc_composite_channel_credentials_create( + insecure_creds, inner_fake_creds.get(), nullptr); + auto* outer_composite_creds = grpc_composite_channel_credentials_create( + inner_composite_creds, outer_fake_creds.get(), nullptr); + auto duplicate_without_call_creds = + outer_composite_creds->duplicate_without_call_credentials(); + EXPECT_EQ(duplicate_without_call_creds.get(), insecure_creds); + grpc_channel_credentials_release(insecure_creds); + grpc_channel_credentials_release(inner_composite_creds); + grpc_channel_credentials_release(outer_composite_creds); +} + TEST(CredentialsTest, TestCompositeChannelCredsCompareFailureDifferentChannelCreds) { auto* insecure_creds = grpc_insecure_credentials_create();