Skip to content

Commit

Permalink
Add a simple test
Browse files Browse the repository at this point in the history
  • Loading branch information
yang-g committed Sep 29, 2017
1 parent cfd20c4 commit 3c00328
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/cpp/end2end/end2end_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,34 @@ TEST_P(SecureEnd2endTest, BlockingAuthMetadataPluginFailure) {
kTestCredsPluginErrorMsg);
}

TEST_P(SecureEnd2endTest, CompositeCallCreds) {
ResetStub();
EchoRequest request;
EchoResponse response;
ClientContext context;
const char kMetadataKey1[] = "call-creds-key1";
const char kMetadataKey2[] = "call-creds-key2";
const char kMetadataVal1[] = "call-creds-val1";
const char kMetadataVal2[] = "call-creds-val2";

context.set_credentials(CompositeCallCredentials(
MetadataCredentialsFromPlugin(std::unique_ptr<MetadataCredentialsPlugin>(
new TestMetadataCredentialsPlugin(kMetadataKey1, kMetadataVal1, true,
true))),
MetadataCredentialsFromPlugin(std::unique_ptr<MetadataCredentialsPlugin>(
new TestMetadataCredentialsPlugin(kMetadataKey2, kMetadataVal2, true,
true)))));
request.set_message("Hello");
request.mutable_param()->set_echo_metadata(true);

Status s = stub_->Echo(&context, request, &response);
EXPECT_TRUE(s.ok());
EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(),
kMetadataKey1, kMetadataVal1));
EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(),
kMetadataKey2, kMetadataVal2));
}

TEST_P(SecureEnd2endTest, ClientAuthContext) {
ResetStub();
EchoRequest request;
Expand Down

0 comments on commit 3c00328

Please sign in to comment.