diff options
Diffstat (limited to 'test/cpp')
-rw-r--r-- | test/cpp/client/credentials_test.cc | 4 | ||||
-rw-r--r-- | test/cpp/end2end/async_end2end_test.cc | 4 | ||||
-rw-r--r-- | test/cpp/end2end/client_crash_test.cc | 2 | ||||
-rw-r--r-- | test/cpp/end2end/end2end_test.cc | 59 | ||||
-rw-r--r-- | test/cpp/end2end/generic_end2end_test.cc | 2 | ||||
-rw-r--r-- | test/cpp/end2end/mock_test.cc | 2 | ||||
-rw-r--r-- | test/cpp/end2end/server_crash_test_client.cc | 2 | ||||
-rw-r--r-- | test/cpp/end2end/shutdown_test.cc | 2 | ||||
-rw-r--r-- | test/cpp/end2end/streaming_throughput_test.cc | 2 | ||||
-rw-r--r-- | test/cpp/end2end/thread_stress_test.cc | 2 | ||||
-rw-r--r-- | test/cpp/end2end/zookeeper_test.cc | 2 | ||||
-rw-r--r-- | test/cpp/interop/client_helper.cc | 14 | ||||
-rw-r--r-- | test/cpp/interop/interop_client.cc | 2 | ||||
-rw-r--r-- | test/cpp/qps/driver.cc | 6 | ||||
-rw-r--r-- | test/cpp/qps/report.h | 4 | ||||
-rw-r--r-- | test/cpp/util/cli_call_test.cc | 3 | ||||
-rw-r--r-- | test/cpp/util/create_test_channel.cc | 11 | ||||
-rw-r--r-- | test/cpp/util/create_test_channel.h | 2 | ||||
-rw-r--r-- | test/cpp/util/grpc_cli.cc | 4 |
19 files changed, 45 insertions, 84 deletions
diff --git a/test/cpp/client/credentials_test.cc b/test/cpp/client/credentials_test.cc index 743ad065d1..418a54439a 100644 --- a/test/cpp/client/credentials_test.cc +++ b/test/cpp/client/credentials_test.cc @@ -46,8 +46,8 @@ class CredentialsTest : public ::testing::Test { }; TEST_F(CredentialsTest, InvalidGoogleRefreshToken) { - std::shared_ptr<Credentials> bad1 = GoogleRefreshTokenCredentials(""); - EXPECT_EQ(static_cast<Credentials*>(nullptr), bad1.get()); + std::shared_ptr<CallCredentials> bad1 = GoogleRefreshTokenCredentials(""); + EXPECT_EQ(static_cast<CallCredentials*>(nullptr), bad1.get()); } } // namespace testing diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index cfb6c21edc..74290c36d2 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -199,7 +199,7 @@ class AsyncEnd2endTest : public ::testing::TestWithParam<bool> { void ResetStub() { std::shared_ptr<Channel> channel = - CreateChannel(server_address_.str(), InsecureCredentials()); + CreateChannel(server_address_.str(), InsecureChannelCredentials()); stub_ = grpc::cpp::test::util::TestService::NewStub(channel); } @@ -749,7 +749,7 @@ TEST_P(AsyncEnd2endTest, ServerCheckDone) { TEST_P(AsyncEnd2endTest, UnimplementedRpc) { std::shared_ptr<Channel> channel = - CreateChannel(server_address_.str(), InsecureCredentials()); + CreateChannel(server_address_.str(), InsecureChannelCredentials()); std::unique_ptr<grpc::cpp::test::util::UnimplementedService::Stub> stub; stub = grpc::cpp::test::util::UnimplementedService::NewStub(channel); EchoRequest send_request; diff --git a/test/cpp/end2end/client_crash_test.cc b/test/cpp/end2end/client_crash_test.cc index 058e696166..116785bbf2 100644 --- a/test/cpp/end2end/client_crash_test.cc +++ b/test/cpp/end2end/client_crash_test.cc @@ -74,7 +74,7 @@ class CrashTest : public ::testing::Test { })); GPR_ASSERT(server_); return grpc::cpp::test::util::TestService::NewStub( - CreateChannel(addr, InsecureCredentials())); + CreateChannel(addr, InsecureChannelCredentials())); } void KillServer() { server_.reset(); } diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 89a556c587..ef605de8e6 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -146,13 +146,13 @@ class TestAuthMetadataProcessor : public AuthMetadataProcessor { TestAuthMetadataProcessor(bool is_blocking) : is_blocking_(is_blocking) {} - std::shared_ptr<Credentials> GetCompatibleClientCreds() { + std::shared_ptr<CallCredentials> GetCompatibleClientCreds() { return MetadataCredentialsFromPlugin( std::unique_ptr<MetadataCredentialsPlugin>( new TestMetadataCredentialsPlugin(kGoodGuy, is_blocking_, true))); } - std::shared_ptr<Credentials> GetIncompatibleClientCreds() { + std::shared_ptr<CallCredentials> GetIncompatibleClientCreds() { return MetadataCredentialsFromPlugin( std::unique_ptr<MetadataCredentialsPlugin>( new TestMetadataCredentialsPlugin("Mr Hyde", is_blocking_, true))); @@ -407,7 +407,7 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> { } EXPECT_TRUE(is_server_started_); ChannelArguments args; - auto channel_creds = InsecureCredentials(); + auto channel_creds = InsecureChannelCredentials(); if (GetParam().use_tls) { SslCredentialsOptions ssl_opts = {test_root_cert, "", ""}; args.SetSslTargetNameOverride("foo.test.google.fr"); @@ -429,7 +429,7 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> { builder.RegisterService(proxy_service_.get()); proxy_server_ = builder.BuildAndStart(); - channel_ = CreateChannel(proxyaddr.str(), InsecureCredentials()); + channel_ = CreateChannel(proxyaddr.str(), InsecureChannelCredentials()); } stub_ = grpc::cpp::test::util::TestService::NewStub(channel_); @@ -751,7 +751,8 @@ TEST_P(End2endTest, ChannelStateTimeout) { std::ostringstream server_address; server_address << "127.0.0.1:" << port; // Channel to non-existing server - auto channel = CreateChannel(server_address.str(), InsecureCredentials()); + auto channel = + CreateChannel(server_address.str(), InsecureChannelCredentials()); // Start IDLE EXPECT_EQ(GRPC_CHANNEL_IDLE, channel->GetState(true)); @@ -971,33 +972,6 @@ TEST_P(SecureEnd2endTest, SimpleRpcWithHost) { EXPECT_TRUE(s.ok()); } -// rpc and stream should fail on bad credentials. -TEST_P(SecureEnd2endTest, BadCredentials) { - std::shared_ptr<Credentials> bad_creds = GoogleRefreshTokenCredentials(""); - EXPECT_EQ(static_cast<Credentials*>(nullptr), bad_creds.get()); - std::shared_ptr<Channel> channel = - CreateChannel(server_address_.str(), bad_creds); - std::unique_ptr<grpc::cpp::test::util::TestService::Stub> stub( - grpc::cpp::test::util::TestService::NewStub(channel)); - EchoRequest request; - EchoResponse response; - ClientContext context; - request.set_message("Hello"); - - Status s = stub->Echo(&context, request, &response); - EXPECT_EQ("", response.message()); - EXPECT_FALSE(s.ok()); - EXPECT_EQ(StatusCode::INVALID_ARGUMENT, s.error_code()); - EXPECT_EQ("Invalid credentials.", s.error_message()); - - ClientContext context2; - auto stream = stub->BidiStream(&context2); - s = stream->Finish(); - EXPECT_FALSE(s.ok()); - EXPECT_EQ(StatusCode::INVALID_ARGUMENT, s.error_code()); - EXPECT_EQ("Invalid credentials.", s.error_message()); -} - bool MetadataContains( const std::multimap<grpc::string_ref, grpc::string_ref>& metadata, const grpc::string& key, const grpc::string& value) { @@ -1055,7 +1029,7 @@ TEST_P(SecureEnd2endTest, SetPerCallCredentials) { EchoRequest request; EchoResponse response; ClientContext context; - std::shared_ptr<Credentials> creds = + std::shared_ptr<CallCredentials> creds = GoogleIAMCredentials("fake_token", "fake_selector"); context.set_credentials(creds); request.set_message("Hello"); @@ -1072,30 +1046,15 @@ TEST_P(SecureEnd2endTest, SetPerCallCredentials) { "fake_selector")); } -TEST_P(SecureEnd2endTest, InsecurePerCallCredentials) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - std::shared_ptr<Credentials> creds = InsecureCredentials(); - context.set_credentials(creds); - request.set_message("Hello"); - request.mutable_param()->set_echo_metadata(true); - - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(StatusCode::CANCELLED, s.error_code()); - EXPECT_EQ("Failed to set credentials to rpc.", s.error_message()); -} - TEST_P(SecureEnd2endTest, OverridePerCallCredentials) { ResetStub(); EchoRequest request; EchoResponse response; ClientContext context; - std::shared_ptr<Credentials> creds1 = + std::shared_ptr<CallCredentials> creds1 = GoogleIAMCredentials("fake_token1", "fake_selector1"); context.set_credentials(creds1); - std::shared_ptr<Credentials> creds2 = + std::shared_ptr<CallCredentials> creds2 = GoogleIAMCredentials("fake_token2", "fake_selector2"); context.set_credentials(creds2); request.set_message("Hello"); diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc index 6a46916728..082119d6d5 100644 --- a/test/cpp/end2end/generic_end2end_test.cc +++ b/test/cpp/end2end/generic_end2end_test.cc @@ -120,7 +120,7 @@ class GenericEnd2endTest : public ::testing::Test { void ResetStub() { std::shared_ptr<Channel> channel = - CreateChannel(server_address_.str(), InsecureCredentials()); + CreateChannel(server_address_.str(), InsecureChannelCredentials()); generic_stub_.reset(new GenericStub(channel)); } diff --git a/test/cpp/end2end/mock_test.cc b/test/cpp/end2end/mock_test.cc index 9c35fede8f..a2a2f68784 100644 --- a/test/cpp/end2end/mock_test.cc +++ b/test/cpp/end2end/mock_test.cc @@ -244,7 +244,7 @@ class MockTest : public ::testing::Test { void ResetStub() { std::shared_ptr<Channel> channel = - CreateChannel(server_address_.str(), InsecureCredentials()); + CreateChannel(server_address_.str(), InsecureChannelCredentials()); stub_ = grpc::cpp::test::util::TestService::NewStub(channel); } diff --git a/test/cpp/end2end/server_crash_test_client.cc b/test/cpp/end2end/server_crash_test_client.cc index 17869362c2..2baefcbf42 100644 --- a/test/cpp/end2end/server_crash_test_client.cc +++ b/test/cpp/end2end/server_crash_test_client.cc @@ -58,7 +58,7 @@ using namespace gflags; int main(int argc, char** argv) { ParseCommandLineFlags(&argc, &argv, true); auto stub = grpc::cpp::test::util::TestService::NewStub( - grpc::CreateChannel(FLAGS_address, grpc::InsecureCredentials())); + grpc::CreateChannel(FLAGS_address, grpc::InsecureChannelCredentials())); EchoRequest request; EchoResponse response; diff --git a/test/cpp/end2end/shutdown_test.cc b/test/cpp/end2end/shutdown_test.cc index 0549bb8b5f..b1b18b2a7f 100644 --- a/test/cpp/end2end/shutdown_test.cc +++ b/test/cpp/end2end/shutdown_test.cc @@ -93,7 +93,7 @@ class ShutdownTest : public ::testing::Test { void ResetStub() { string target = "dns:localhost:" + to_string(port_); - channel_ = CreateChannel(target, InsecureCredentials()); + channel_ = CreateChannel(target, InsecureChannelCredentials()); stub_ = grpc::cpp::test::util::TestService::NewStub(channel_); } diff --git a/test/cpp/end2end/streaming_throughput_test.cc b/test/cpp/end2end/streaming_throughput_test.cc index d4ab1486cc..b7e103a1ae 100644 --- a/test/cpp/end2end/streaming_throughput_test.cc +++ b/test/cpp/end2end/streaming_throughput_test.cc @@ -160,7 +160,7 @@ class End2endTest : public ::testing::Test { void ResetStub() { std::shared_ptr<Channel> channel = - CreateChannel(server_address_.str(), InsecureCredentials()); + CreateChannel(server_address_.str(), InsecureChannelCredentials()); stub_ = grpc::cpp::test::util::TestService::NewStub(channel); } diff --git a/test/cpp/end2end/thread_stress_test.cc b/test/cpp/end2end/thread_stress_test.cc index 75a07d89c5..fb82b96135 100644 --- a/test/cpp/end2end/thread_stress_test.cc +++ b/test/cpp/end2end/thread_stress_test.cc @@ -190,7 +190,7 @@ class End2endTest : public ::testing::Test { void ResetStub() { std::shared_ptr<Channel> channel = - CreateChannel(server_address_.str(), InsecureCredentials()); + CreateChannel(server_address_.str(), InsecureChannelCredentials()); stub_ = grpc::cpp::test::util::TestService::NewStub(channel); } diff --git a/test/cpp/end2end/zookeeper_test.cc b/test/cpp/end2end/zookeeper_test.cc index d4c7f0489f..e88c0f9c68 100644 --- a/test/cpp/end2end/zookeeper_test.cc +++ b/test/cpp/end2end/zookeeper_test.cc @@ -157,7 +157,7 @@ class ZookeeperTest : public ::testing::Test { void ResetStub() { string target = "zookeeper://" + zookeeper_address_ + "/test"; - channel_ = CreateChannel(target, InsecureCredentials()); + channel_ = CreateChannel(target, InsecureChannelCredentials()); stub_ = std::move(grpc::cpp::test::util::TestService::NewStub(channel_)); } diff --git a/test/cpp/interop/client_helper.cc b/test/cpp/interop/client_helper.cc index 61b46d25aa..5caf0f2d1d 100644 --- a/test/cpp/interop/client_helper.cc +++ b/test/cpp/interop/client_helper.cc @@ -76,11 +76,11 @@ grpc::string GetServiceAccountJsonKey() { } grpc::string GetOauth2AccessToken() { - std::shared_ptr<Credentials> creds = GoogleComputeEngineCredentials(); - SecureCredentials* secure_creds = - dynamic_cast<SecureCredentials*>(creds.get()); + std::shared_ptr<CallCredentials> creds = GoogleComputeEngineCredentials(); + SecureCallCredentials* secure_creds = + dynamic_cast<SecureCallCredentials*>(creds.get()); GPR_ASSERT(secure_creds != nullptr); - grpc_credentials* c_creds = secure_creds->GetRawCreds(); + grpc_call_credentials* c_creds = secure_creds->GetRawCreds(); char* token = grpc_test_fetch_oauth2_token_with_credentials(c_creds); GPR_ASSERT(token != nullptr); gpr_log(GPR_INFO, "Get raw oauth2 access token: %s", token); @@ -98,13 +98,13 @@ std::shared_ptr<Channel> CreateChannelForTestCase( FLAGS_server_port); if (test_case == "compute_engine_creds") { - std::shared_ptr<Credentials> creds; + std::shared_ptr<CallCredentials> creds; GPR_ASSERT(FLAGS_use_tls); creds = GoogleComputeEngineCredentials(); return CreateTestChannel(host_port, FLAGS_server_host_override, FLAGS_use_tls, !FLAGS_use_test_ca, creds); } else if (test_case == "jwt_token_creds") { - std::shared_ptr<Credentials> creds; + std::shared_ptr<CallCredentials> creds; GPR_ASSERT(FLAGS_use_tls); grpc::string json_key = GetServiceAccountJsonKey(); std::chrono::seconds token_lifetime = std::chrono::hours(1); @@ -114,7 +114,7 @@ std::shared_ptr<Channel> CreateChannelForTestCase( FLAGS_use_tls, !FLAGS_use_test_ca, creds); } else if (test_case == "oauth2_auth_token") { grpc::string raw_token = GetOauth2AccessToken(); - std::shared_ptr<Credentials> creds = AccessTokenCredentials(raw_token); + std::shared_ptr<CallCredentials> creds = AccessTokenCredentials(raw_token); return CreateTestChannel(host_port, FLAGS_server_host_override, FLAGS_use_tls, !FLAGS_use_test_ca, creds); } else { diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index 5169945762..9ffaeb19aa 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -211,7 +211,7 @@ void InteropClient::DoPerRpcCreds(const grpc::string& json_key) { ClientContext context; std::chrono::seconds token_lifetime = std::chrono::hours(1); - std::shared_ptr<Credentials> creds = + std::shared_ptr<CallCredentials> creds = ServiceAccountJWTAccessCredentials(json_key, token_lifetime.count()); context.set_credentials(creds); diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index dd5c4f4f73..3d27ea8213 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -161,8 +161,8 @@ std::unique_ptr<ScenarioResult> RunScenario( // where class contained in std::vector must have a copy constructor auto* servers = new ServerData[num_servers]; for (size_t i = 0; i < num_servers; i++) { - servers[i].stub = - Worker::NewStub(CreateChannel(workers[i], InsecureCredentials())); + servers[i].stub = Worker::NewStub( + CreateChannel(workers[i], InsecureChannelCredentials())); ServerArgs args; result_server_config = server_config; result_server_config.set_host(workers[i]); @@ -190,7 +190,7 @@ std::unique_ptr<ScenarioResult> RunScenario( auto* clients = new ClientData[num_clients]; for (size_t i = 0; i < num_clients; i++) { clients[i].stub = Worker::NewStub( - CreateChannel(workers[i + num_servers], InsecureCredentials())); + CreateChannel(workers[i + num_servers], InsecureChannelCredentials())); ClientArgs args; result_client_config = client_config; result_client_config.set_host(workers[i + num_servers]); diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h index 5914fc4e30..339280e2f0 100644 --- a/test/cpp/qps/report.h +++ b/test/cpp/qps/report.h @@ -116,8 +116,8 @@ class PerfDbReporter : public Reporter { test_name_(test_name), sys_info_(sys_info), tag_(tag) { - perf_db_client_.init( - grpc::CreateChannel(server_address, grpc::InsecureCredentials())); + perf_db_client_.init(grpc::CreateChannel( + server_address, grpc::InsecureChannelCredentials())); } ~PerfDbReporter() GRPC_OVERRIDE { SendData(); }; diff --git a/test/cpp/util/cli_call_test.cc b/test/cpp/util/cli_call_test.cc index 9c8d59987e..32cd8e4103 100644 --- a/test/cpp/util/cli_call_test.cc +++ b/test/cpp/util/cli_call_test.cc @@ -89,7 +89,8 @@ class CliCallTest : public ::testing::Test { void TearDown() GRPC_OVERRIDE { server_->Shutdown(); } void ResetStub() { - channel_ = CreateChannel(server_address_.str(), InsecureCredentials()); + channel_ = + CreateChannel(server_address_.str(), InsecureChannelCredentials()); stub_ = grpc::cpp::test::util::TestService::NewStub(channel_); } diff --git a/test/cpp/util/create_test_channel.cc b/test/cpp/util/create_test_channel.cc index f0d5bfc7eb..0cd9f9e767 100644 --- a/test/cpp/util/create_test_channel.cc +++ b/test/cpp/util/create_test_channel.cc @@ -58,13 +58,14 @@ namespace grpc { std::shared_ptr<Channel> CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, bool enable_ssl, bool use_prod_roots, - const std::shared_ptr<Credentials>& creds) { + const std::shared_ptr<CallCredentials>& creds) { ChannelArguments channel_args; if (enable_ssl) { const char* roots_certs = use_prod_roots ? "" : test_root_cert; SslCredentialsOptions ssl_opts = {roots_certs, "", ""}; - std::shared_ptr<Credentials> channel_creds = SslCredentials(ssl_opts); + std::shared_ptr<ChannelCredentials> channel_creds = + SslCredentials(ssl_opts); if (!server.empty() && !override_hostname.empty()) { channel_args.SetSslTargetNameOverride(override_hostname); @@ -72,11 +73,11 @@ std::shared_ptr<Channel> CreateTestChannel( const grpc::string& connect_to = server.empty() ? override_hostname : server; if (creds.get()) { - channel_creds = CompositeCredentials(creds, channel_creds); + channel_creds = CompositeChannelCredentials(channel_creds, creds); } return CreateCustomChannel(connect_to, channel_creds, channel_args); } else { - return CreateChannel(server, InsecureCredentials()); + return CreateChannel(server, InsecureChannelCredentials()); } } @@ -84,7 +85,7 @@ std::shared_ptr<Channel> CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, bool enable_ssl, bool use_prod_roots) { return CreateTestChannel(server, override_hostname, enable_ssl, - use_prod_roots, std::shared_ptr<Credentials>()); + use_prod_roots, std::shared_ptr<CallCredentials>()); } // Shortcut for end2end and interop tests. diff --git a/test/cpp/util/create_test_channel.h b/test/cpp/util/create_test_channel.h index a4750689a0..b50d653de3 100644 --- a/test/cpp/util/create_test_channel.h +++ b/test/cpp/util/create_test_channel.h @@ -51,7 +51,7 @@ std::shared_ptr<Channel> CreateTestChannel( std::shared_ptr<Channel> CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, bool enable_ssl, bool use_prod_roots, - const std::shared_ptr<Credentials>& creds); + const std::shared_ptr<CallCredentials>& creds); } // namespace grpc diff --git a/test/cpp/util/grpc_cli.cc b/test/cpp/util/grpc_cli.cc index 334b6efb6a..3f40b242fc 100644 --- a/test/cpp/util/grpc_cli.cc +++ b/test/cpp/util/grpc_cli.cc @@ -148,9 +148,9 @@ int main(int argc, char** argv) { std::stringstream input_stream; input_stream << input_file.rdbuf(); - std::shared_ptr<grpc::Credentials> creds; + std::shared_ptr<grpc::ChannelCredentials> creds; if (!FLAGS_enable_ssl) { - creds = grpc::InsecureCredentials(); + creds = grpc::InsecureChannelCredentials(); } else { if (FLAGS_use_auth) { creds = grpc::GoogleDefaultCredentials(); |