Experimental method to get a debugging only view into credentials

pull/20246/head
Yash Tibrewal 5 years ago
parent a358d48f12
commit a4cf948b2f
  1. 7
      include/grpcpp/impl/codegen/client_context_impl.h
  2. 3
      test/cpp/end2end/end2end_test.cc

@ -316,6 +316,13 @@ class ClientContext {
void set_credentials(
const std::shared_ptr<grpc_impl::CallCredentials>& creds);
/// EXPERIMENTAL debugging API
///
/// Returns the credentials for the client call. This should be used only in
/// tests and for diagnostic purposes, and should not be used by application
/// logic.
std::shared_ptr<grpc_impl::CallCredentials> credentials() { return creds_; }
/// Return the compression algorithm the client call will request be used.
/// Note that the gRPC runtime may decide to ignore this request, for example,
/// due to resource constraints.

@ -1884,6 +1884,7 @@ TEST_P(SecureEnd2endTest, CallCredentialsInterceptionWithSetCredentials) {
std::shared_ptr<CallCredentials> creds1 =
GoogleIAMCredentials("wrong_token", "wrong_selector");
context.set_credentials(creds1);
EXPECT_EQ(context.credentials(), creds1);
request.set_message("Hello");
request.mutable_param()->set_echo_metadata(true);
@ -1907,9 +1908,11 @@ TEST_P(SecureEnd2endTest, OverridePerCallCredentials) {
std::shared_ptr<CallCredentials> creds1 =
GoogleIAMCredentials("fake_token1", "fake_selector1");
context.set_credentials(creds1);
EXPECT_EQ(context.credentials(), creds1);
std::shared_ptr<CallCredentials> creds2 =
GoogleIAMCredentials("fake_token2", "fake_selector2");
context.set_credentials(creds2);
EXPECT_EQ(context.credentials(), creds2);
request.set_message("Hello");
request.mutable_param()->set_echo_metadata(true);

Loading…
Cancel
Save