gtestify test/core/handshake (#30207)

* gtestify test/core/security (#30199)

* fix

* gtestify test/core/security

* Fix

* Fix
pull/30243/head
Esun Kim 2 years ago committed by GitHub
parent 694e634a79
commit 7dfd49429f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 220
      CMakeLists.txt
  2. 83
      build_autogenerated.yaml
  3. 3
      test/core/handshake/BUILD
  4. 56
      test/core/handshake/client_ssl.cc
  5. 12
      test/core/handshake/readahead_handshaker_server_ssl.cc
  6. 19
      test/core/handshake/server_ssl.cc
  7. 132
      tools/run_tests/generated/tests.json

220
CMakeLists.txt generated

@ -790,9 +790,6 @@ if(gRPC_BUILD_TESTS)
add_dependencies(buildtests_c buffer_list_test)
add_dependencies(buildtests_c c_slice_buffer_test)
add_dependencies(buildtests_c channel_stack_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_c client_ssl_test)
endif()
add_dependencies(buildtests_c cmdline_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_c combiner_test)
@ -823,9 +820,6 @@ if(gRPC_BUILD_TESTS)
add_dependencies(buildtests_c format_request_test)
add_dependencies(buildtests_c goaway_server_test)
add_dependencies(buildtests_c grpc_ipv6_loopback_available_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_c handshake_server_with_readahead_handshaker_test)
endif()
add_dependencies(buildtests_c histogram_test)
add_dependencies(buildtests_c host_port_test)
add_dependencies(buildtests_c hpack_encoder_test)
@ -850,9 +844,6 @@ if(gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_c resolve_address_using_native_resolver_posix_test)
endif()
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_c server_ssl_test)
endif()
add_dependencies(buildtests_c slice_string_helpers_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_c socket_utils_test)
@ -956,6 +947,9 @@ if(gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx client_lb_end2end_test)
endif()
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx client_ssl_test)
endif()
add_dependencies(buildtests_cxx codegen_test_full)
add_dependencies(buildtests_cxx codegen_test_minimal)
add_dependencies(buildtests_cxx completion_queue_threading_test)
@ -1029,6 +1023,9 @@ if(gRPC_BUILD_TESTS)
add_dependencies(buildtests_cxx grpclb_end2end_test)
endif()
add_dependencies(buildtests_cxx h2_ssl_session_reuse_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx handshake_server_with_readahead_handshaker_test)
endif()
add_dependencies(buildtests_cxx head_of_line_blocking_bad_client_test)
add_dependencies(buildtests_cxx headers_bad_client_test)
add_dependencies(buildtests_cxx health_service_end2end_test)
@ -1138,6 +1135,9 @@ if(gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx server_request_call_test)
endif()
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx server_ssl_test)
endif()
add_dependencies(buildtests_cxx server_test)
add_dependencies(buildtests_cxx service_config_end2end_test)
add_dependencies(buildtests_cxx service_config_test)
@ -4584,35 +4584,6 @@ target_link_libraries(channel_stack_test
)
endif()
if(gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(client_ssl_test
test/core/handshake/client_ssl.cc
)
target_include_directories(client_ssl_test
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
)
target_link_libraries(client_ssl_test
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_test_util
)
endif()
endif()
if(gRPC_BUILD_TESTS)
@ -5076,36 +5047,6 @@ target_link_libraries(grpc_ipv6_loopback_available_test
)
endif()
if(gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(handshake_server_with_readahead_handshaker_test
test/core/handshake/readahead_handshaker_server_ssl.cc
test/core/handshake/server_ssl_common.cc
)
target_include_directories(handshake_server_with_readahead_handshaker_test
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
)
target_link_libraries(handshake_server_with_readahead_handshaker_test
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_test_util
)
endif()
endif()
if(gRPC_BUILD_TESTS)
@ -5606,36 +5547,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
)
endif()
endif()
if(gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(server_ssl_test
test/core/handshake/server_ssl.cc
test/core/handshake/server_ssl_common.cc
)
target_include_directories(server_ssl_test
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
)
target_link_libraries(server_ssl_test
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_test_util
)
endif()
endif()
if(gRPC_BUILD_TESTS)
@ -8731,6 +8642,43 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
)
endif()
endif()
if(gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(client_ssl_test
test/core/handshake/client_ssl.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(client_ssl_test
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(client_ssl_test
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_test_util
)
endif()
endif()
if(gRPC_BUILD_TESTS)
@ -11621,6 +11569,44 @@ target_link_libraries(h2_ssl_session_reuse_test
)
endif()
if(gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(handshake_server_with_readahead_handshaker_test
test/core/handshake/readahead_handshaker_server_ssl.cc
test/core/handshake/server_ssl_common.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(handshake_server_with_readahead_handshaker_test
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(handshake_server_with_readahead_handshaker_test
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_test_util
)
endif()
endif()
if(gRPC_BUILD_TESTS)
@ -15572,6 +15558,44 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
)
endif()
endif()
if(gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(server_ssl_test
test/core/handshake/server_ssl.cc
test/core/handshake/server_ssl_common.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(server_ssl_test
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(server_ssl_test
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_test_util
)
endif()
endif()
if(gRPC_BUILD_TESTS)

@ -3306,18 +3306,6 @@ targets:
deps:
- grpc_test_util
uses_polling: false
- name: client_ssl_test
build: test
language: c
headers: []
src:
- test/core/handshake/client_ssl.cc
deps:
- grpc_test_util
platforms:
- linux
- posix
- mac
- name: cmdline_test
build: test
language: c
@ -3504,20 +3492,6 @@ targets:
- test/core/iomgr/grpc_ipv6_loopback_available_test.cc
deps:
- grpc_test_util
- name: handshake_server_with_readahead_handshaker_test
build: test
language: c
headers:
- test/core/handshake/server_ssl_common.h
src:
- test/core/handshake/readahead_handshaker_server_ssl.cc
- test/core/handshake/server_ssl_common.cc
deps:
- grpc_test_util
platforms:
- linux
- posix
- mac
- name: histogram_test
build: test
language: c
@ -3705,20 +3679,6 @@ targets:
- linux
- posix
- mac
- name: server_ssl_test
build: test
language: c
headers:
- test/core/handshake/server_ssl_common.h
src:
- test/core/handshake/server_ssl.cc
- test/core/handshake/server_ssl_common.cc
deps:
- grpc_test_util
platforms:
- linux
- posix
- mac
- name: slice_string_helpers_test
build: test
language: c
@ -5017,6 +4977,19 @@ targets:
- linux
- posix
- mac
- name: client_ssl_test
gtest: true
build: test
language: c++
headers: []
src:
- test/core/handshake/client_ssl.cc
deps:
- grpc_test_util
platforms:
- linux
- posix
- mac
- name: codegen_test_full
gtest: true
build: test
@ -6189,6 +6162,21 @@ targets:
- test/core/end2end/h2_ssl_session_reuse_test.cc
deps:
- end2end_tests
- name: handshake_server_with_readahead_handshaker_test
gtest: true
build: test
language: c++
headers:
- test/core/handshake/server_ssl_common.h
src:
- test/core/handshake/readahead_handshaker_server_ssl.cc
- test/core/handshake/server_ssl_common.cc
deps:
- grpc_test_util
platforms:
- linux
- posix
- mac
- name: head_of_line_blocking_bad_client_test
gtest: true
build: test
@ -7919,6 +7907,21 @@ targets:
- linux
- posix
- mac
- name: server_ssl_test
gtest: true
build: test
language: c++
headers:
- test/core/handshake/server_ssl_common.h
src:
- test/core/handshake/server_ssl.cc
- test/core/handshake/server_ssl_common.cc
deps:
- grpc_test_util
platforms:
- linux
- posix
- mac
- name: server_test
gtest: true
build: test

@ -26,6 +26,7 @@ grpc_cc_test(
"//src/core/tsi/test_creds:server1.key",
"//src/core/tsi/test_creds:server1.pem",
],
external_deps = ["gtest"],
language = "C++",
tags = ["no_windows"],
deps = [
@ -55,6 +56,7 @@ grpc_cc_test(
"//src/core/tsi/test_creds:server1.key",
"//src/core/tsi/test_creds:server1.pem",
],
external_deps = ["gtest"],
language = "C++",
tags = ["no_windows"],
deps = [
@ -73,6 +75,7 @@ grpc_cc_test(
"//src/core/tsi/test_creds:server1.key",
"//src/core/tsi/test_creds:server1.pem",
],
external_deps = ["gtest"],
language = "C++",
tags = ["no_windows"],
deps = [

@ -16,7 +16,10 @@
*
*/
#include <gtest/gtest.h>
#include "src/core/lib/iomgr/port.h"
#include "test/core/util/test_config.h"
// This test won't work except with posix sockets enabled
#ifdef GRPC_POSIX_SOCKET_TCP
@ -44,7 +47,6 @@
#include "src/core/lib/gprpp/thd.h"
#include "src/core/lib/iomgr/load_file.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
#define SSL_CERT_PATH "src/core/tsi/test_creds/server1.pem"
#define SSL_KEY_PATH "src/core/tsi/test_creds/server1.key"
@ -148,18 +150,18 @@ static int alpn_select_cb(SSL* /*ssl*/, const uint8_t** out, uint8_t* out_len,
const size_t length = static_cast<size_t>(*inp++);
if (length == strlen("grpc-exp") && strncmp(inp, "grpc-exp", length) == 0) {
grpc_exp_seen = true;
GPR_ASSERT(!h2_seen);
EXPECT_FALSE(h2_seen);
}
if (length == strlen("h2") && strncmp(inp, "h2", length) == 0) {
h2_seen = true;
GPR_ASSERT(grpc_exp_seen);
EXPECT_TRUE(grpc_exp_seen);
}
inp += length;
}
GPR_ASSERT(inp == in_end);
GPR_ASSERT(grpc_exp_seen);
GPR_ASSERT(h2_seen);
EXPECT_EQ(inp, in_end);
EXPECT_TRUE(grpc_exp_seen);
EXPECT_TRUE(h2_seen);
return SSL_TLSEXT_ERR_OK;
}
@ -258,7 +260,7 @@ static void server_thread(void* arg) {
// Establish a SSL* and accept at SSL layer.
SSL* ssl = SSL_new(ctx);
SSL_set_info_callback(ssl, ssl_server_info_callback);
GPR_ASSERT(ssl);
ASSERT_TRUE(ssl);
SSL_set_fd(ssl, client);
if (SSL_accept(ssl) <= 0) {
ERR_print_errors_fp(stderr);
@ -302,25 +304,26 @@ static bool client_ssl_test(char* server_alpn_preferred) {
sleep(1);
}
}
GPR_ASSERT(server_socket > 0 && port > 0);
EXPECT_GT(server_socket, 0);
EXPECT_GT(port, 0);
// Launch the TLS server thread.
SslLibraryInfo ssl_library_info;
server_args args = {server_socket, server_alpn_preferred, &ssl_library_info};
bool ok;
grpc_core::Thread thd("grpc_client_ssl_test", server_thread, &args, &ok);
GPR_ASSERT(ok);
EXPECT_TRUE(ok);
thd.Start();
ssl_library_info.Await();
// Load key pair and establish client SSL credentials.
grpc_ssl_pem_key_cert_pair pem_key_cert_pair;
grpc_slice ca_slice, cert_slice, key_slice;
GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
EXPECT_TRUE(GRPC_LOG_IF_ERROR("load_file",
grpc_load_file(SSL_CA_PATH, 1, &ca_slice)));
GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
EXPECT_TRUE(GRPC_LOG_IF_ERROR("load_file",
grpc_load_file(SSL_CERT_PATH, 1, &cert_slice)));
GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
EXPECT_TRUE(GRPC_LOG_IF_ERROR("load_file",
grpc_load_file(SSL_KEY_PATH, 1, &key_slice)));
const char* ca_cert =
reinterpret_cast<const char*> GRPC_SLICE_START_PTR(ca_slice);
@ -343,12 +346,13 @@ static bool client_ssl_test(char* server_alpn_preferred) {
grpc_args.args = &ssl_name_override;
grpc_channel* channel =
grpc_channel_create(target.c_str(), ssl_creds, &grpc_args);
GPR_ASSERT(channel);
EXPECT_TRUE(channel);
// Initially the channel will be idle, the
// grpc_channel_check_connectivity_state triggers an attempt to connect.
GPR_ASSERT(grpc_channel_check_connectivity_state(
channel, 1 /* try_to_connect */) == GRPC_CHANNEL_IDLE);
EXPECT_EQ(
grpc_channel_check_connectivity_state(channel, 1 /* try_to_connect */),
GRPC_CHANNEL_IDLE);
// Wait a bounded number of times for the channel to be ready. When the
// channel is ready, the initial TLS handshake will have successfully
@ -362,7 +366,7 @@ static bool client_ssl_test(char* server_alpn_preferred) {
channel, state, grpc_timeout_seconds_to_deadline(3), cq, nullptr);
gpr_timespec cq_deadline = grpc_timeout_seconds_to_deadline(5);
grpc_event ev = grpc_completion_queue_next(cq, cq_deadline, nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
EXPECT_EQ(ev.type, GRPC_OP_COMPLETE);
state =
grpc_channel_check_connectivity_state(channel, 0 /* try_to_connect */);
}
@ -384,24 +388,24 @@ static bool client_ssl_test(char* server_alpn_preferred) {
return success;
}
int main(int argc, char* argv[]) {
grpc::testing::TestEnvironment env(&argc, argv);
TEST(ClientSslTest, MainTest) {
// Handshake succeeeds when the server has grpc-exp as the ALPN preference.
GPR_ASSERT(client_ssl_test(const_cast<char*>("grpc-exp")));
ASSERT_TRUE(client_ssl_test(const_cast<char*>("grpc-exp")));
// Handshake succeeeds when the server has h2 as the ALPN preference. This
// covers legacy gRPC servers which don't support grpc-exp.
GPR_ASSERT(client_ssl_test(const_cast<char*>("h2")));
ASSERT_TRUE(client_ssl_test(const_cast<char*>("h2")));
// Handshake fails when the server uses a fake protocol as its ALPN
// preference. This validates the client is correctly validating ALPN returns
// and sanity checks the client_ssl_test.
GPR_ASSERT(!client_ssl_test(const_cast<char*>("foo")));
ASSERT_FALSE(client_ssl_test(const_cast<char*>("foo")));
// Clean up the SSL libraries.
EVP_cleanup();
return 0;
}
#else /* GRPC_POSIX_SOCKET_TCP */
int main(int argc, char** argv) { return 1; }
#endif /* GRPC_POSIX_SOCKET_TCP */
int main(int argc, char** argv) {
grpc::testing::TestEnvironment env(&argc, argv);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

@ -21,6 +21,7 @@
#include <sys/socket.h>
#include <unistd.h>
#include <gtest/gtest.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
@ -76,7 +77,7 @@ class ReadAheadHandshakerFactory : public HandshakerFactory {
} // namespace grpc_core
int main(int /*argc*/, char* /*argv*/[]) {
TEST(HandshakeServerWithReadaheadHandshakerTest, MainTest) {
grpc_core::CoreConfiguration::BuildSpecialConfiguration(
[](grpc_core::CoreConfiguration::Builder* builder) {
BuildCoreConfiguration(builder);
@ -87,8 +88,13 @@ int main(int /*argc*/, char* /*argv*/[]) {
grpc_init();
const char* full_alpn_list[] = {"grpc-exp", "h2"};
GPR_ASSERT(server_ssl_test(full_alpn_list, 2, "grpc-exp"));
ASSERT_TRUE(server_ssl_test(full_alpn_list, 2, "grpc-exp"));
CleanupSslLibrary();
grpc_shutdown();
return 0;
}
int main(int argc, char** argv) {
grpc::testing::TestEnvironment env(&argc, argv);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

@ -21,6 +21,7 @@
#include <sys/socket.h>
#include <unistd.h>
#include <gtest/gtest.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
@ -36,24 +37,28 @@
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
int main(int argc, char* argv[]) {
grpc::testing::TestEnvironment env(&argc, argv);
TEST(ServerSslTest, MainTest) {
// Handshake succeeeds when the client supplies the standard ALPN list.
const char* full_alpn_list[] = {"grpc-exp", "h2"};
GPR_ASSERT(server_ssl_test(full_alpn_list, 2, "grpc-exp"));
ASSERT_TRUE(server_ssl_test(full_alpn_list, 2, "grpc-exp"));
// Handshake succeeeds when the client supplies only h2 as the ALPN list. This
// covers legacy gRPC clients which don't support grpc-exp.
const char* h2_only_alpn_list[] = {"h2"};
GPR_ASSERT(server_ssl_test(h2_only_alpn_list, 1, "h2"));
ASSERT_TRUE(server_ssl_test(h2_only_alpn_list, 1, "h2"));
// Handshake succeeds when the client supplies superfluous ALPN entries and
// also when h2 precedes gprc-exp.
const char* extra_alpn_list[] = {"foo", "h2", "bar", "grpc-exp"};
GPR_ASSERT(server_ssl_test(extra_alpn_list, 4, "h2"));
ASSERT_TRUE(server_ssl_test(extra_alpn_list, 4, "h2"));
// Handshake fails when the client uses a fake protocol as its only ALPN
// preference. This validates the server is correctly validating ALPN
// and sanity checks the server_ssl_test.
const char* fake_alpn_list[] = {"foo"};
GPR_ASSERT(!server_ssl_test(fake_alpn_list, 1, "foo"));
ASSERT_FALSE(server_ssl_test(fake_alpn_list, 1, "foo"));
CleanupSslLibrary();
return 0;
}
int main(int argc, char** argv) {
grpc::testing::TestEnvironment env(&argc, argv);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

@ -261,28 +261,6 @@
],
"uses_polling": false
},
{
"args": [],
"benchmark": false,
"ci_platforms": [
"linux",
"mac",
"posix"
],
"cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [],
"flaky": false,
"gtest": false,
"language": "c",
"name": "client_ssl_test",
"platforms": [
"linux",
"mac",
"posix"
],
"uses_polling": true
},
{
"args": [],
"benchmark": false,
@ -653,28 +631,6 @@
],
"uses_polling": true
},
{
"args": [],
"benchmark": false,
"ci_platforms": [
"linux",
"mac",
"posix"
],
"cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [],
"flaky": false,
"gtest": false,
"language": "c",
"name": "handshake_server_with_readahead_handshaker_test",
"platforms": [
"linux",
"mac",
"posix"
],
"uses_polling": true
},
{
"args": [],
"benchmark": false,
@ -1105,28 +1061,6 @@
],
"uses_polling": true
},
{
"args": [],
"benchmark": false,
"ci_platforms": [
"linux",
"mac",
"posix"
],
"cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [],
"flaky": false,
"gtest": false,
"language": "c",
"name": "server_ssl_test",
"platforms": [
"linux",
"mac",
"posix"
],
"uses_polling": true
},
{
"args": [],
"benchmark": false,
@ -2929,6 +2863,28 @@
],
"uses_polling": true
},
{
"args": [],
"benchmark": false,
"ci_platforms": [
"linux",
"mac",
"posix"
],
"cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [],
"flaky": false,
"gtest": true,
"language": "c++",
"name": "client_ssl_test",
"platforms": [
"linux",
"mac",
"posix"
],
"uses_polling": true
},
{
"args": [],
"benchmark": false,
@ -4259,6 +4215,28 @@
],
"uses_polling": true
},
{
"args": [],
"benchmark": false,
"ci_platforms": [
"linux",
"mac",
"posix"
],
"cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [],
"flaky": false,
"gtest": true,
"language": "c++",
"name": "handshake_server_with_readahead_handshaker_test",
"platforms": [
"linux",
"mac",
"posix"
],
"uses_polling": true
},
{
"args": [],
"benchmark": false,
@ -6279,6 +6257,28 @@
],
"uses_polling": true
},
{
"args": [],
"benchmark": false,
"ci_platforms": [
"linux",
"mac",
"posix"
],
"cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [],
"flaky": false,
"gtest": true,
"language": "c++",
"name": "server_ssl_test",
"platforms": [
"linux",
"mac",
"posix"
],
"uses_polling": true
},
{
"args": [],
"benchmark": false,

Loading…
Cancel
Save