diff options
Diffstat (limited to 'test/cpp/end2end')
-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 | 81 | ||||
-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 |
10 files changed, 36 insertions, 65 deletions
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..6da933302c 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_); @@ -575,6 +575,18 @@ void CancelRpc(ClientContext* context, int delay_us, TestServiceImpl* service) { context->TryCancel(); } +TEST_P(End2endTest, CancelRpcBeforeStart) { + ResetStub(); + EchoRequest request; + EchoResponse response; + ClientContext context; + request.set_message("hello"); + context.TryCancel(); + Status s = stub_->Echo(&context, request, &response); + EXPECT_EQ("", response.message()); + EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code()); +} + // Client cancels request stream after sending two messages TEST_P(End2endTest, ClientCancelsRequestStream) { ResetStub(); @@ -751,7 +763,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 +984,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 +1041,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 +1058,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"); @@ -1217,14 +1188,14 @@ TEST_P(SecureEnd2endTest, ClientAuthContext) { } INSTANTIATE_TEST_CASE_P(End2end, End2endTest, - ::testing::Values(TestScenario(false, true), - TestScenario(false, false))); + ::testing::Values(TestScenario(false, false), + TestScenario(false, true))); INSTANTIATE_TEST_CASE_P(ProxyEnd2end, ProxyEnd2endTest, - ::testing::Values(TestScenario(true, true), - TestScenario(true, false), + ::testing::Values(TestScenario(false, false), TestScenario(false, true), - TestScenario(false, false))); + TestScenario(true, false), + TestScenario(true, true))); INSTANTIATE_TEST_CASE_P(SecureEnd2end, SecureEnd2endTest, ::testing::Values(TestScenario(false, true))); 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 80057d893e..bd34cfba67 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_)); } |