aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc')
-rw-r--r--test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc305
1 files changed, 151 insertions, 154 deletions
diff --git a/test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc b/test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc
index 85a58114ba..316ff13816 100644
--- a/test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc
+++ b/test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc
@@ -24,7 +24,7 @@
#include "src/core/lib/gprpp/thd.h"
#include "src/core/tsi/alts/handshaker/alts_handshaker_client.h"
-#include "src/core/tsi/alts/handshaker/alts_tsi_event.h"
+#include "src/core/tsi/alts/handshaker/alts_shared_resource.h"
#include "src/core/tsi/alts/handshaker/alts_tsi_handshaker.h"
#include "src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h"
#include "test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.h"
@@ -43,12 +43,18 @@
#define ALTS_TSI_HANDSHAKER_TEST_MIN_RPC_VERSION_MAJOR 2
#define ALTS_TSI_HANDSHAKER_TEST_MIN_RPC_VERSION_MINOR 1
+using grpc_core::internal::alts_handshaker_client_check_fields_for_testing;
+using grpc_core::internal::alts_handshaker_client_get_handshaker_for_testing;
using grpc_core::internal::
- alts_tsi_handshaker_get_has_sent_start_message_for_testing;
+ alts_handshaker_client_get_recv_buffer_addr_for_testing;
+using grpc_core::internal::alts_handshaker_client_set_cb_for_testing;
+using grpc_core::internal::alts_handshaker_client_set_fields_for_testing;
+using grpc_core::internal::alts_handshaker_client_set_recv_bytes_for_testing;
+using grpc_core::internal::alts_handshaker_client_set_vtable_for_testing;
+using grpc_core::internal::alts_tsi_handshaker_get_client_for_testing;
using grpc_core::internal::alts_tsi_handshaker_get_is_client_for_testing;
-using grpc_core::internal::alts_tsi_handshaker_get_recv_bytes_for_testing;
-using grpc_core::internal::alts_tsi_handshaker_set_client_for_testing;
-using grpc_core::internal::alts_tsi_handshaker_set_recv_bytes_for_testing;
+using grpc_core::internal::alts_tsi_handshaker_set_client_vtable_for_testing;
+static bool should_handshaker_client_api_succeed = true;
/* ALTS mock notification. */
typedef struct notification {
@@ -57,12 +63,6 @@ typedef struct notification {
bool notified;
} notification;
-/* ALTS mock handshaker client. */
-typedef struct alts_mock_handshaker_client {
- alts_handshaker_client base;
- bool used_for_success_test;
-} alts_mock_handshaker_client;
-
/* Type of ALTS handshaker response. */
typedef enum {
INVALID,
@@ -73,10 +73,7 @@ typedef enum {
SERVER_NEXT,
} alts_handshaker_response_type;
-static alts_tsi_event* client_start_event;
-static alts_tsi_event* client_next_event;
-static alts_tsi_event* server_start_event;
-static alts_tsi_event* server_next_event;
+static alts_handshaker_client* cb_event = nullptr;
static notification caller_to_tsi_notification;
static notification tsi_to_caller_notification;
@@ -311,89 +308,69 @@ static void on_server_next_success_cb(tsi_result status, void* user_data,
signal(&tsi_to_caller_notification);
}
-static tsi_result mock_client_start(alts_handshaker_client* self,
- alts_tsi_event* event) {
- alts_mock_handshaker_client* client =
- reinterpret_cast<alts_mock_handshaker_client*>(self);
- if (!client->used_for_success_test) {
- alts_tsi_event_destroy(event);
+static tsi_result mock_client_start(alts_handshaker_client* client) {
+ if (!should_handshaker_client_api_succeed) {
return TSI_INTERNAL_ERROR;
}
- GPR_ASSERT(event->cb == on_client_start_success_cb);
- GPR_ASSERT(event->user_data == nullptr);
- GPR_ASSERT(!alts_tsi_handshaker_get_has_sent_start_message_for_testing(
- event->handshaker));
+ alts_handshaker_client_check_fields_for_testing(
+ client, on_client_start_success_cb, nullptr, false, nullptr);
/* Populate handshaker response for client_start request. */
- event->recv_buffer = generate_handshaker_response(CLIENT_START);
- client_start_event = event;
+ grpc_byte_buffer** recv_buffer_ptr =
+ alts_handshaker_client_get_recv_buffer_addr_for_testing(client);
+ *recv_buffer_ptr = generate_handshaker_response(CLIENT_START);
+ cb_event = client;
signal(&caller_to_tsi_notification);
return TSI_OK;
}
static void mock_shutdown(alts_handshaker_client* self) {}
-static tsi_result mock_server_start(alts_handshaker_client* self,
- alts_tsi_event* event,
+static tsi_result mock_server_start(alts_handshaker_client* client,
grpc_slice* bytes_received) {
- alts_mock_handshaker_client* client =
- reinterpret_cast<alts_mock_handshaker_client*>(self);
- if (!client->used_for_success_test) {
- alts_tsi_event_destroy(event);
+ if (!should_handshaker_client_api_succeed) {
return TSI_INTERNAL_ERROR;
}
- GPR_ASSERT(event->cb == on_server_start_success_cb);
- GPR_ASSERT(event->user_data == nullptr);
+ alts_handshaker_client_check_fields_for_testing(
+ client, on_server_start_success_cb, nullptr, false, nullptr);
grpc_slice slice = grpc_empty_slice();
GPR_ASSERT(grpc_slice_cmp(*bytes_received, slice) == 0);
- GPR_ASSERT(!alts_tsi_handshaker_get_has_sent_start_message_for_testing(
- event->handshaker));
/* Populate handshaker response for server_start request. */
- event->recv_buffer = generate_handshaker_response(SERVER_START);
- server_start_event = event;
+ grpc_byte_buffer** recv_buffer_ptr =
+ alts_handshaker_client_get_recv_buffer_addr_for_testing(client);
+ *recv_buffer_ptr = generate_handshaker_response(SERVER_START);
+ cb_event = client;
grpc_slice_unref(slice);
signal(&caller_to_tsi_notification);
return TSI_OK;
}
-static tsi_result mock_next(alts_handshaker_client* self, alts_tsi_event* event,
+static tsi_result mock_next(alts_handshaker_client* client,
grpc_slice* bytes_received) {
- alts_mock_handshaker_client* client =
- reinterpret_cast<alts_mock_handshaker_client*>(self);
- if (!client->used_for_success_test) {
- alts_tsi_event_destroy(event);
+ if (!should_handshaker_client_api_succeed) {
return TSI_INTERNAL_ERROR;
}
- bool is_client =
- alts_tsi_handshaker_get_is_client_for_testing(event->handshaker);
- if (is_client) {
- GPR_ASSERT(event->cb == on_client_next_success_cb);
- } else {
- GPR_ASSERT(event->cb == on_server_next_success_cb);
- }
- GPR_ASSERT(event->user_data == nullptr);
+ alts_tsi_handshaker* handshaker =
+ alts_handshaker_client_get_handshaker_for_testing(client);
+ bool is_client = alts_tsi_handshaker_get_is_client_for_testing(handshaker);
+ tsi_handshaker_on_next_done_cb cb =
+ is_client ? on_client_next_success_cb : on_server_next_success_cb;
+ alts_handshaker_client_set_cb_for_testing(client, cb);
+ alts_handshaker_client_set_recv_bytes_for_testing(client, bytes_received);
+ alts_handshaker_client_check_fields_for_testing(client, cb, nullptr, true,
+ bytes_received);
GPR_ASSERT(bytes_received != nullptr);
GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR(*bytes_received),
ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES,
GRPC_SLICE_LENGTH(*bytes_received)) == 0);
- GPR_ASSERT(grpc_slice_cmp(alts_tsi_handshaker_get_recv_bytes_for_testing(
- event->handshaker),
- *bytes_received) == 0);
- GPR_ASSERT(alts_tsi_handshaker_get_has_sent_start_message_for_testing(
- event->handshaker));
/* Populate handshaker response for next request. */
grpc_slice out_frame =
grpc_slice_from_static_string(ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME);
- if (is_client) {
- event->recv_buffer = generate_handshaker_response(CLIENT_NEXT);
- } else {
- event->recv_buffer = generate_handshaker_response(SERVER_NEXT);
- }
- alts_tsi_handshaker_set_recv_bytes_for_testing(event->handshaker, &out_frame);
- if (is_client) {
- client_next_event = event;
- } else {
- server_next_event = event;
- }
+ grpc_byte_buffer** recv_buffer_ptr =
+ alts_handshaker_client_get_recv_buffer_addr_for_testing(client);
+ *recv_buffer_ptr = is_client ? generate_handshaker_response(CLIENT_NEXT)
+ : generate_handshaker_response(SERVER_NEXT);
+ alts_handshaker_client_set_recv_bytes_for_testing(client, &out_frame);
+ cb_event = client;
signal(&caller_to_tsi_notification);
grpc_slice_unref(out_frame);
return TSI_OK;
@@ -401,38 +378,27 @@ static tsi_result mock_next(alts_handshaker_client* self, alts_tsi_event* event,
static void mock_destruct(alts_handshaker_client* client) {}
-static const alts_handshaker_client_vtable vtable = {
- mock_client_start, mock_server_start, mock_next, mock_shutdown,
- mock_destruct};
-
-static alts_handshaker_client* alts_mock_handshaker_client_create(
- bool used_for_success_test) {
- alts_mock_handshaker_client* client =
- static_cast<alts_mock_handshaker_client*>(gpr_zalloc(sizeof(*client)));
- client->base.vtable = &vtable;
- client->used_for_success_test = used_for_success_test;
- return &client->base;
-}
+static alts_handshaker_client_vtable vtable = {mock_client_start,
+ mock_server_start, mock_next,
+ mock_shutdown, mock_destruct};
-static tsi_handshaker* create_test_handshaker(bool used_for_success_test,
- bool is_client) {
+static tsi_handshaker* create_test_handshaker(bool is_client) {
tsi_handshaker* handshaker = nullptr;
- alts_handshaker_client* client =
- alts_mock_handshaker_client_create(used_for_success_test);
grpc_alts_credentials_options* options =
grpc_alts_credentials_client_options_create();
- alts_tsi_handshaker_create(options, "target_name", "lame", is_client,
- &handshaker);
+ alts_tsi_handshaker_create(options, "target_name",
+ ALTS_HANDSHAKER_SERVICE_URL_FOR_TESTING, is_client,
+ nullptr, &handshaker);
alts_tsi_handshaker* alts_handshaker =
reinterpret_cast<alts_tsi_handshaker*>(handshaker);
- alts_tsi_handshaker_set_client_for_testing(alts_handshaker, client);
+ alts_tsi_handshaker_set_client_vtable_for_testing(alts_handshaker, &vtable);
grpc_alts_credentials_options_destroy(options);
return handshaker;
}
static void check_handshaker_next_invalid_input() {
/* Initialization. */
- tsi_handshaker* handshaker = create_test_handshaker(true, true);
+ tsi_handshaker* handshaker = create_test_handshaker(true);
/* Check nullptr handshaker. */
GPR_ASSERT(tsi_handshaker_next(nullptr, nullptr, 0, nullptr, nullptr, nullptr,
check_must_not_be_called,
@@ -447,8 +413,7 @@ static void check_handshaker_next_invalid_input() {
static void check_handshaker_shutdown_invalid_input() {
/* Initialization. */
- tsi_handshaker* handshaker = create_test_handshaker(
- false /* used_for_success_test */, true /* is_client */);
+ tsi_handshaker* handshaker = create_test_handshaker(true /* is_client */);
/* Check nullptr handshaker. */
tsi_handshaker_shutdown(nullptr);
/* Cleanup. */
@@ -460,10 +425,10 @@ static void check_handshaker_next_success() {
* Create handshakers for which internal mock client is going to do
* correctness check.
*/
- tsi_handshaker* client_handshaker = create_test_handshaker(
- true /* used_for_success_test */, true /* is_client */);
- tsi_handshaker* server_handshaker = create_test_handshaker(
- true /* used_for_success_test */, false /* is_client */);
+ tsi_handshaker* client_handshaker =
+ create_test_handshaker(true /* is_client */);
+ tsi_handshaker* server_handshaker =
+ create_test_handshaker(false /* is_client */);
/* Client start. */
GPR_ASSERT(tsi_handshaker_next(client_handshaker, nullptr, 0, nullptr,
nullptr, nullptr, on_client_start_success_cb,
@@ -494,9 +459,7 @@ static void check_handshaker_next_success() {
}
static void check_handshaker_next_with_shutdown() {
- /* Initialization. */
- tsi_handshaker* handshaker = create_test_handshaker(
- true /* used_for_success_test */, true /* is_client*/);
+ tsi_handshaker* handshaker = create_test_handshaker(true /* is_client*/);
/* next(success) -- shutdown(success) -- next (fail) */
GPR_ASSERT(tsi_handshaker_next(handshaker, nullptr, 0, nullptr, nullptr,
nullptr, on_client_start_success_cb,
@@ -514,20 +477,18 @@ static void check_handshaker_next_with_shutdown() {
}
static void check_handle_response_with_shutdown(void* unused) {
- /* Client start. */
wait(&caller_to_tsi_notification);
- alts_tsi_event_dispatch_to_handshaker(client_start_event, true /* is_ok */);
- alts_tsi_event_destroy(client_start_event);
+ alts_handshaker_client_handle_response(cb_event, true /* is_ok */);
}
static void check_handshaker_next_failure() {
/**
* Create handshakers for which internal mock client is always going to fail.
*/
- tsi_handshaker* client_handshaker = create_test_handshaker(
- false /* used_for_success_test */, true /* is_client */);
- tsi_handshaker* server_handshaker = create_test_handshaker(
- false /* used_for_success_test */, false /* is_client */);
+ tsi_handshaker* client_handshaker =
+ create_test_handshaker(true /* is_client */);
+ tsi_handshaker* server_handshaker =
+ create_test_handshaker(false /* is_client */);
/* Client start. */
GPR_ASSERT(tsi_handshaker_next(client_handshaker, nullptr, 0, nullptr,
nullptr, nullptr, check_must_not_be_called,
@@ -578,34 +539,46 @@ static void on_failed_grpc_call_cb(tsi_result status, void* user_data,
}
static void check_handle_response_invalid_input() {
+ /* Initialization. */
+ notification_init(&caller_to_tsi_notification);
+ notification_init(&tsi_to_caller_notification);
/**
* Create a handshaker at the client side, for which internal mock client is
* always going to fail.
*/
- tsi_handshaker* handshaker = create_test_handshaker(
- false /* used_for_success_test */, true /* is_client */);
+ tsi_handshaker* handshaker = create_test_handshaker(true /* is_client */);
+ tsi_handshaker_next(handshaker, nullptr, 0, nullptr, nullptr, nullptr,
+ on_client_start_success_cb, nullptr);
alts_tsi_handshaker* alts_handshaker =
reinterpret_cast<alts_tsi_handshaker*>(handshaker);
- grpc_byte_buffer recv_buffer;
+ grpc_slice slice = grpc_empty_slice();
+ grpc_byte_buffer* recv_buffer = grpc_raw_byte_buffer_create(&slice, 1);
+ alts_handshaker_client* client =
+ alts_tsi_handshaker_get_client_for_testing(alts_handshaker);
/* Check nullptr handshaker. */
- alts_tsi_handshaker_handle_response(nullptr, &recv_buffer, GRPC_STATUS_OK,
- nullptr, on_invalid_input_cb, nullptr,
- true);
+ alts_handshaker_client_set_fields_for_testing(client, nullptr,
+ on_invalid_input_cb, nullptr,
+ recv_buffer, GRPC_STATUS_OK);
+ alts_handshaker_client_handle_response(client, true);
/* Check nullptr recv_bytes. */
- alts_tsi_handshaker_handle_response(alts_handshaker, nullptr, GRPC_STATUS_OK,
- nullptr, on_invalid_input_cb, nullptr,
- true);
+ alts_handshaker_client_set_fields_for_testing(client, alts_handshaker,
+ on_invalid_input_cb, nullptr,
+ nullptr, GRPC_STATUS_OK);
+ alts_handshaker_client_handle_response(client, true);
/* Check failed grpc call made to handshaker service. */
- alts_tsi_handshaker_handle_response(alts_handshaker, &recv_buffer,
- GRPC_STATUS_UNKNOWN, nullptr,
- on_failed_grpc_call_cb, nullptr, true);
-
- alts_tsi_handshaker_handle_response(alts_handshaker, &recv_buffer,
- GRPC_STATUS_OK, nullptr,
- on_failed_grpc_call_cb, nullptr, false);
-
+ alts_handshaker_client_set_fields_for_testing(
+ client, alts_handshaker, on_failed_grpc_call_cb, nullptr, recv_buffer,
+ GRPC_STATUS_UNKNOWN);
+ alts_handshaker_client_handle_response(client, true);
+ alts_handshaker_client_set_fields_for_testing(client, alts_handshaker,
+ on_failed_grpc_call_cb, nullptr,
+ recv_buffer, GRPC_STATUS_OK);
+ alts_handshaker_client_handle_response(client, false);
/* Cleanup. */
+ grpc_slice_unref(slice);
tsi_handshaker_destroy(handshaker);
+ notification_destroy(&caller_to_tsi_notification);
+ notification_destroy(&tsi_to_caller_notification);
}
static void on_invalid_resp_cb(tsi_result status, void* user_data,
@@ -620,41 +593,45 @@ static void on_invalid_resp_cb(tsi_result status, void* user_data,
}
static void check_handle_response_invalid_resp() {
+ /* Initialization. */
+ notification_init(&caller_to_tsi_notification);
+ notification_init(&tsi_to_caller_notification);
/**
* Create a handshaker at the client side, for which internal mock client is
* always going to fail.
*/
- tsi_handshaker* handshaker = create_test_handshaker(
- false /* used_for_success_test */, true /* is_client */);
+ tsi_handshaker* handshaker = create_test_handshaker(true /* is_client */);
+ tsi_handshaker_next(handshaker, nullptr, 0, nullptr, nullptr, nullptr,
+ on_client_start_success_cb, nullptr);
alts_tsi_handshaker* alts_handshaker =
reinterpret_cast<alts_tsi_handshaker*>(handshaker);
+ alts_handshaker_client* client =
+ alts_tsi_handshaker_get_client_for_testing(alts_handshaker);
/* Tests. */
grpc_byte_buffer* recv_buffer = generate_handshaker_response(INVALID);
- alts_tsi_handshaker_handle_response(alts_handshaker, recv_buffer,
- GRPC_STATUS_OK, nullptr,
- on_invalid_resp_cb, nullptr, true);
+ alts_handshaker_client_set_fields_for_testing(client, alts_handshaker,
+ on_invalid_resp_cb, nullptr,
+ recv_buffer, GRPC_STATUS_OK);
+ alts_handshaker_client_handle_response(client, true);
/* Cleanup. */
- grpc_byte_buffer_destroy(recv_buffer);
tsi_handshaker_destroy(handshaker);
+ notification_destroy(&caller_to_tsi_notification);
+ notification_destroy(&tsi_to_caller_notification);
}
static void check_handle_response_success(void* unused) {
/* Client start. */
wait(&caller_to_tsi_notification);
- alts_tsi_event_dispatch_to_handshaker(client_start_event, true /* is_ok */);
- alts_tsi_event_destroy(client_start_event);
+ alts_handshaker_client_handle_response(cb_event, true /* is_ok */);
/* Client next. */
wait(&caller_to_tsi_notification);
- alts_tsi_event_dispatch_to_handshaker(client_next_event, true /* is_ok */);
- alts_tsi_event_destroy(client_next_event);
+ alts_handshaker_client_handle_response(cb_event, true /* is_ok */);
/* Server start. */
wait(&caller_to_tsi_notification);
- alts_tsi_event_dispatch_to_handshaker(server_start_event, true /* is_ok */);
- alts_tsi_event_destroy(server_start_event);
+ alts_handshaker_client_handle_response(cb_event, true /* is_ok */);
/* Server next. */
wait(&caller_to_tsi_notification);
- alts_tsi_event_dispatch_to_handshaker(server_next_event, true /* is_ok */);
- alts_tsi_event_destroy(server_next_event);
+ alts_handshaker_client_handle_response(cb_event, true /* is_ok */);
}
static void on_failed_resp_cb(tsi_result status, void* user_data,
@@ -669,22 +646,30 @@ static void on_failed_resp_cb(tsi_result status, void* user_data,
}
static void check_handle_response_failure() {
+ /* Initialization. */
+ notification_init(&caller_to_tsi_notification);
+ notification_init(&tsi_to_caller_notification);
/**
* Create a handshaker at the client side, for which internal mock client is
* always going to fail.
*/
- tsi_handshaker* handshaker = create_test_handshaker(
- false /* used_for_success_test */, true /* is_client */);
+ tsi_handshaker* handshaker = create_test_handshaker(true /* is_client */);
+ tsi_handshaker_next(handshaker, nullptr, 0, nullptr, nullptr, nullptr,
+ on_client_start_success_cb, nullptr);
alts_tsi_handshaker* alts_handshaker =
reinterpret_cast<alts_tsi_handshaker*>(handshaker);
+ alts_handshaker_client* client =
+ alts_tsi_handshaker_get_client_for_testing(alts_handshaker);
/* Tests. */
grpc_byte_buffer* recv_buffer = generate_handshaker_response(FAILED);
- alts_tsi_handshaker_handle_response(alts_handshaker, recv_buffer,
- GRPC_STATUS_OK, nullptr,
- on_failed_resp_cb, nullptr, true);
- grpc_byte_buffer_destroy(recv_buffer);
+ alts_handshaker_client_set_fields_for_testing(client, alts_handshaker,
+ on_failed_resp_cb, nullptr,
+ recv_buffer, GRPC_STATUS_OK);
+ alts_handshaker_client_handle_response(client, true /* is_ok*/);
/* Cleanup. */
tsi_handshaker_destroy(handshaker);
+ notification_destroy(&caller_to_tsi_notification);
+ notification_destroy(&tsi_to_caller_notification);
}
static void on_shutdown_resp_cb(tsi_result status, void* user_data,
@@ -699,26 +684,38 @@ static void on_shutdown_resp_cb(tsi_result status, void* user_data,
}
static void check_handle_response_after_shutdown() {
- tsi_handshaker* handshaker = create_test_handshaker(
- true /* used_for_success_test */, true /* is_client */);
+ /* Initialization. */
+ notification_init(&caller_to_tsi_notification);
+ notification_init(&tsi_to_caller_notification);
+ tsi_handshaker* handshaker = create_test_handshaker(true /* is_client */);
+ tsi_handshaker_next(handshaker, nullptr, 0, nullptr, nullptr, nullptr,
+ on_client_start_success_cb, nullptr);
alts_tsi_handshaker* alts_handshaker =
reinterpret_cast<alts_tsi_handshaker*>(handshaker);
+ alts_handshaker_client* client =
+ alts_tsi_handshaker_get_client_for_testing(alts_handshaker);
+ grpc_byte_buffer** recv_buffer_ptr =
+ alts_handshaker_client_get_recv_buffer_addr_for_testing(client);
+ grpc_byte_buffer_destroy(*recv_buffer_ptr);
+
/* Tests. */
tsi_handshaker_shutdown(handshaker);
grpc_byte_buffer* recv_buffer = generate_handshaker_response(CLIENT_START);
- alts_tsi_handshaker_handle_response(alts_handshaker, recv_buffer,
- GRPC_STATUS_OK, nullptr,
- on_shutdown_resp_cb, nullptr, true);
- grpc_byte_buffer_destroy(recv_buffer);
+ alts_handshaker_client_set_fields_for_testing(client, alts_handshaker,
+ on_shutdown_resp_cb, nullptr,
+ recv_buffer, GRPC_STATUS_OK);
+ alts_handshaker_client_handle_response(client, true);
/* Cleanup. */
tsi_handshaker_destroy(handshaker);
+ notification_destroy(&caller_to_tsi_notification);
+ notification_destroy(&tsi_to_caller_notification);
}
void check_handshaker_next_fails_after_shutdown() {
/* Initialization. */
notification_init(&caller_to_tsi_notification);
notification_init(&tsi_to_caller_notification);
- client_start_event = nullptr;
+ cb_event = nullptr;
/* Tests. */
grpc_core::Thread thd("alts_tsi_handshaker_test",
&check_handle_response_with_shutdown, nullptr);
@@ -734,10 +731,6 @@ void check_handshaker_success() {
/* Initialization. */
notification_init(&caller_to_tsi_notification);
notification_init(&tsi_to_caller_notification);
- client_start_event = nullptr;
- client_next_event = nullptr;
- server_start_event = nullptr;
- server_next_event = nullptr;
/* Tests. */
grpc_core::Thread thd("alts_tsi_handshaker_test",
&check_handle_response_success, nullptr);
@@ -752,17 +745,21 @@ void check_handshaker_success() {
int main(int argc, char** argv) {
/* Initialization. */
grpc_init();
+ grpc_alts_shared_resource_dedicated_init();
/* Tests. */
+ should_handshaker_client_api_succeed = true;
check_handshaker_success();
check_handshaker_next_invalid_input();
- check_handshaker_shutdown_invalid_input();
check_handshaker_next_fails_after_shutdown();
+ check_handle_response_after_shutdown();
+ should_handshaker_client_api_succeed = false;
+ check_handshaker_shutdown_invalid_input();
check_handshaker_next_failure();
check_handle_response_invalid_input();
check_handle_response_invalid_resp();
check_handle_response_failure();
- check_handle_response_after_shutdown();
/* Cleanup. */
+ grpc_alts_shared_resource_dedicated_shutdown();
grpc_shutdown();
return 0;
}