Classes | Macros | Typedefs | Enumerations | Functions | Variables
alts_tsi_handshaker_test.cc File Reference
#include "src/core/tsi/alts/handshaker/alts_tsi_handshaker.h"
#include <stdio.h>
#include <stdlib.h>
#include "upb/upb.hpp"
#include <grpc/grpc.h>
#include <grpc/support/sync.h>
#include "src/core/lib/gprpp/thd.h"
#include "src/core/tsi/alts/handshaker/alts_handshaker_client.h"
#include "src/core/tsi/alts/handshaker/alts_shared_resource.h"
#include "src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h"
#include "src/core/tsi/transport_security_grpc.h"
#include "src/proto/grpc/gcp/altscontext.upb.h"
#include "test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.h"
#include "test/core/util/test_config.h"
Include dependency graph for alts_tsi_handshaker_test.cc:

Go to the source code of this file.

Classes

struct  notification
 

Macros

#define ALTS_TSI_HANDSHAKER_TEST_APPLICATION_PROTOCOL   "test application protocol"
 
#define ALTS_TSI_HANDSHAKER_TEST_BUFFER_SIZE   100
 
#define ALTS_TSI_HANDSHAKER_TEST_CONSUMED_BYTES   "Hello "
 
#define ALTS_TSI_HANDSHAKER_TEST_KEY_DATA   "ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKL"
 
#define ALTS_TSI_HANDSHAKER_TEST_LOCAL_IDENTITY   "chapilocal@service.google.com"
 
#define ALTS_TSI_HANDSHAKER_TEST_MAX_FRAME_SIZE   (2 * 1024 * 1024)
 
#define ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MAJOR   3
 
#define ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MINOR   2
 
#define ALTS_TSI_HANDSHAKER_TEST_MIN_RPC_VERSION_MAJOR   2
 
#define ALTS_TSI_HANDSHAKER_TEST_MIN_RPC_VERSION_MINOR   1
 
#define ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME   "Hello Google"
 
#define ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_KEY   "peer"
 
#define ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_VALUE   "attributes"
 
#define ALTS_TSI_HANDSHAKER_TEST_PEER_IDENTITY   "chapi@service.google.com"
 
#define ALTS_TSI_HANDSHAKER_TEST_RECORD_PROTOCOL   "test record protocol"
 
#define ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES   "Hello World"
 
#define ALTS_TSI_HANDSHAKER_TEST_REMAIN_BYTES   "Google"
 
#define ALTS_TSI_HANDSHAKER_TEST_SECURITY_LEVEL   "TSI_PRIVACY_AND_INTEGRITY"
 
#define ALTS_TSI_HANDSHAKER_TEST_SLEEP_TIME_IN_SECONDS   2
 

Typedefs

typedef struct notification notification
 

Enumerations

enum  alts_handshaker_response_type {
  INVALID, FAILED, CLIENT_START, SERVER_START,
  CLIENT_NEXT, SERVER_NEXT
}
 

Functions

static void check_handle_response_after_shutdown ()
 
static void check_handle_response_failed_grpc_call_to_handshaker_service ()
 
static void check_handle_response_failed_recv_message_from_handshaker_service ()
 
static void check_handle_response_failure ()
 
static void check_handle_response_invalid_resp ()
 
static void check_handle_response_nullptr_handshaker ()
 
static void check_handle_response_nullptr_recv_bytes ()
 
static void check_handle_response_success (void *)
 
static void check_handle_response_with_shutdown (void *)
 
void check_handshaker_next_fails_after_shutdown ()
 
static void check_handshaker_next_failure ()
 
static void check_handshaker_next_invalid_input ()
 
static void check_handshaker_next_success ()
 
static void check_handshaker_next_with_shutdown ()
 
static void check_handshaker_shutdown_invalid_input ()
 
void check_handshaker_success ()
 
static void check_must_not_be_called (tsi_result, void *, const unsigned char *, size_t, tsi_handshaker_result *)
 
static tsi_handshakercreate_test_handshaker (bool is_client)
 
static grpc_byte_buffergenerate_handshaker_response (alts_handshaker_response_type type)
 
int main (int argc, char **argv)
 
static tsi_result mock_client_start (alts_handshaker_client *client)
 
static void mock_destruct (alts_handshaker_client *)
 
static tsi_result mock_next (alts_handshaker_client *client, grpc_slice *bytes_received)
 
static tsi_result mock_server_start (alts_handshaker_client *client, grpc_slice *bytes_received)
 
static void mock_shutdown (alts_handshaker_client *)
 
static void notification_destroy (notification *n)
 
static void notification_init (notification *n)
 
static void on_client_next_success_cb (tsi_result status, void *user_data, const unsigned char *bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result *result)
 
static void on_client_start_success_cb (tsi_result status, void *user_data, const unsigned char *bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result *result)
 
static void on_failed_grpc_call_cb (tsi_result status, void *user_data, const unsigned char *bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result *result)
 
static void on_failed_resp_cb (tsi_result status, void *user_data, const unsigned char *bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result *result)
 
static void on_invalid_input_cb (tsi_result status, void *user_data, const unsigned char *bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result *result)
 
static void on_invalid_resp_cb (tsi_result status, void *user_data, const unsigned char *bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result *result)
 
static void on_server_next_success_cb (tsi_result status, void *user_data, const unsigned char *bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result *result)
 
static void on_server_start_success_cb (tsi_result status, void *user_data, const unsigned char *bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result *result)
 
static void on_shutdown_resp_cb (tsi_result status, void *user_data, const unsigned char *bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result *result)
 
static void run_tsi_handshaker_destroy_with_exec_ctx (tsi_handshaker *handshaker)
 
static void signal (notification *n)
 
static void wait (notification *n)
 

Variables

static notification caller_to_tsi_notification
 
static alts_handshaker_clientcb_event = nullptr
 
static bool should_handshaker_client_api_succeed = true
 
static notification tsi_to_caller_notification
 
static alts_handshaker_client_vtable vtable
 

Macro Definition Documentation

◆ ALTS_TSI_HANDSHAKER_TEST_APPLICATION_PROTOCOL

#define ALTS_TSI_HANDSHAKER_TEST_APPLICATION_PROTOCOL   "test application protocol"

Definition at line 53 of file alts_tsi_handshaker_test.cc.

◆ ALTS_TSI_HANDSHAKER_TEST_BUFFER_SIZE

#define ALTS_TSI_HANDSHAKER_TEST_BUFFER_SIZE   100

Definition at line 46 of file alts_tsi_handshaker_test.cc.

◆ ALTS_TSI_HANDSHAKER_TEST_CONSUMED_BYTES

#define ALTS_TSI_HANDSHAKER_TEST_CONSUMED_BYTES   "Hello "

Definition at line 40 of file alts_tsi_handshaker_test.cc.

◆ ALTS_TSI_HANDSHAKER_TEST_KEY_DATA

#define ALTS_TSI_HANDSHAKER_TEST_KEY_DATA   "ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKL"

Definition at line 44 of file alts_tsi_handshaker_test.cc.

◆ ALTS_TSI_HANDSHAKER_TEST_LOCAL_IDENTITY

#define ALTS_TSI_HANDSHAKER_TEST_LOCAL_IDENTITY   "chapilocal@service.google.com"

Definition at line 52 of file alts_tsi_handshaker_test.cc.

◆ ALTS_TSI_HANDSHAKER_TEST_MAX_FRAME_SIZE

#define ALTS_TSI_HANDSHAKER_TEST_MAX_FRAME_SIZE   (2 * 1024 * 1024)

Definition at line 56 of file alts_tsi_handshaker_test.cc.

◆ ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MAJOR

#define ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MAJOR   3

Definition at line 48 of file alts_tsi_handshaker_test.cc.

◆ ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MINOR

#define ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MINOR   2

Definition at line 49 of file alts_tsi_handshaker_test.cc.

◆ ALTS_TSI_HANDSHAKER_TEST_MIN_RPC_VERSION_MAJOR

#define ALTS_TSI_HANDSHAKER_TEST_MIN_RPC_VERSION_MAJOR   2

Definition at line 50 of file alts_tsi_handshaker_test.cc.

◆ ALTS_TSI_HANDSHAKER_TEST_MIN_RPC_VERSION_MINOR

#define ALTS_TSI_HANDSHAKER_TEST_MIN_RPC_VERSION_MINOR   1

Definition at line 51 of file alts_tsi_handshaker_test.cc.

◆ ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME

#define ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME   "Hello Google"

Definition at line 39 of file alts_tsi_handshaker_test.cc.

◆ ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_KEY

#define ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_KEY   "peer"

Definition at line 57 of file alts_tsi_handshaker_test.cc.

◆ ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_VALUE

#define ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_VALUE   "attributes"

Definition at line 58 of file alts_tsi_handshaker_test.cc.

◆ ALTS_TSI_HANDSHAKER_TEST_PEER_IDENTITY

#define ALTS_TSI_HANDSHAKER_TEST_PEER_IDENTITY   "chapi@service.google.com"

Definition at line 42 of file alts_tsi_handshaker_test.cc.

◆ ALTS_TSI_HANDSHAKER_TEST_RECORD_PROTOCOL

#define ALTS_TSI_HANDSHAKER_TEST_RECORD_PROTOCOL   "test record protocol"

Definition at line 55 of file alts_tsi_handshaker_test.cc.

◆ ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES

#define ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES   "Hello World"

Definition at line 38 of file alts_tsi_handshaker_test.cc.

◆ ALTS_TSI_HANDSHAKER_TEST_REMAIN_BYTES

#define ALTS_TSI_HANDSHAKER_TEST_REMAIN_BYTES   "Google"

Definition at line 41 of file alts_tsi_handshaker_test.cc.

◆ ALTS_TSI_HANDSHAKER_TEST_SECURITY_LEVEL

#define ALTS_TSI_HANDSHAKER_TEST_SECURITY_LEVEL   "TSI_PRIVACY_AND_INTEGRITY"

Definition at line 43 of file alts_tsi_handshaker_test.cc.

◆ ALTS_TSI_HANDSHAKER_TEST_SLEEP_TIME_IN_SECONDS

#define ALTS_TSI_HANDSHAKER_TEST_SLEEP_TIME_IN_SECONDS   2

Definition at line 47 of file alts_tsi_handshaker_test.cc.

Typedef Documentation

◆ notification

typedef struct notification notification

Enumeration Type Documentation

◆ alts_handshaker_response_type

Enumerator
INVALID 
FAILED 
CLIENT_START 
SERVER_START 
CLIENT_NEXT 
SERVER_NEXT 

Definition at line 83 of file alts_tsi_handshaker_test.cc.

Function Documentation

◆ check_handle_response_after_shutdown()

static void check_handle_response_after_shutdown ( )
static

Definition at line 996 of file alts_tsi_handshaker_test.cc.

◆ check_handle_response_failed_grpc_call_to_handshaker_service()

static void check_handle_response_failed_grpc_call_to_handshaker_service ( )
static

Create a handshaker at the client side, for which internal mock client is always going to fail.

Definition at line 799 of file alts_tsi_handshaker_test.cc.

◆ check_handle_response_failed_recv_message_from_handshaker_service()

static void check_handle_response_failed_recv_message_from_handshaker_service ( )
static

Create a handshaker at the client side, for which internal mock client is always going to fail.

Definition at line 835 of file alts_tsi_handshaker_test.cc.

◆ check_handle_response_failure()

static void check_handle_response_failure ( )
static

Create a handshaker at the client side, for which internal mock client is always going to fail.

Definition at line 952 of file alts_tsi_handshaker_test.cc.

◆ check_handle_response_invalid_resp()

static void check_handle_response_invalid_resp ( )
static

Create a handshaker at the client side, for which internal mock client is always going to fail.

Definition at line 881 of file alts_tsi_handshaker_test.cc.

◆ check_handle_response_nullptr_handshaker()

static void check_handle_response_nullptr_handshaker ( )
static

Create a handshaker at the client side, for which internal mock client is always going to fail.

Definition at line 728 of file alts_tsi_handshaker_test.cc.

◆ check_handle_response_nullptr_recv_bytes()

static void check_handle_response_nullptr_recv_bytes ( )
static

Create a handshaker at the client side, for which internal mock client is always going to fail.

Definition at line 767 of file alts_tsi_handshaker_test.cc.

◆ check_handle_response_success()

static void check_handle_response_success ( void *  )
static

Definition at line 914 of file alts_tsi_handshaker_test.cc.

◆ check_handle_response_with_shutdown()

static void check_handle_response_with_shutdown ( void *  )
static

Definition at line 666 of file alts_tsi_handshaker_test.cc.

◆ check_handshaker_next_fails_after_shutdown()

void check_handshaker_next_fails_after_shutdown ( )

Definition at line 1030 of file alts_tsi_handshaker_test.cc.

◆ check_handshaker_next_failure()

static void check_handshaker_next_failure ( )
static

Create handshakers for which internal mock client is always going to fail.

Definition at line 671 of file alts_tsi_handshaker_test.cc.

◆ check_handshaker_next_invalid_input()

static void check_handshaker_next_invalid_input ( )
static

Definition at line 586 of file alts_tsi_handshaker_test.cc.

◆ check_handshaker_next_success()

static void check_handshaker_next_success ( )
static

Create handshakers for which internal mock client is going to do correctness check.

Definition at line 610 of file alts_tsi_handshaker_test.cc.

◆ check_handshaker_next_with_shutdown()

static void check_handshaker_next_with_shutdown ( )
static

Definition at line 648 of file alts_tsi_handshaker_test.cc.

◆ check_handshaker_shutdown_invalid_input()

static void check_handshaker_shutdown_invalid_input ( )
static

Definition at line 601 of file alts_tsi_handshaker_test.cc.

◆ check_handshaker_success()

void check_handshaker_success ( )

Definition at line 1046 of file alts_tsi_handshaker_test.cc.

◆ check_must_not_be_called()

static void check_must_not_be_called ( tsi_result  ,
void *  ,
const unsigned char *  ,
size_t  ,
tsi_handshaker_result  
)
static

Definition at line 239 of file alts_tsi_handshaker_test.cc.

◆ create_test_handshaker()

static tsi_handshaker* create_test_handshaker ( bool  is_client)
static

Definition at line 566 of file alts_tsi_handshaker_test.cc.

◆ generate_handshaker_response()

static grpc_byte_buffer* generate_handshaker_response ( alts_handshaker_response_type  type)
static

This method mocks ALTS handshaker service to generate handshaker response for a specific request.

Definition at line 127 of file alts_tsi_handshaker_test.cc.

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 1061 of file alts_tsi_handshaker_test.cc.

◆ mock_client_start()

static tsi_result mock_client_start ( alts_handshaker_client client)
static

Definition at line 488 of file alts_tsi_handshaker_test.cc.

◆ mock_destruct()

static void mock_destruct ( alts_handshaker_client )
static

Definition at line 560 of file alts_tsi_handshaker_test.cc.

◆ mock_next()

static tsi_result mock_next ( alts_handshaker_client client,
grpc_slice bytes_received 
)
static

Definition at line 528 of file alts_tsi_handshaker_test.cc.

◆ mock_server_start()

static tsi_result mock_server_start ( alts_handshaker_client client,
grpc_slice bytes_received 
)
static

Definition at line 509 of file alts_tsi_handshaker_test.cc.

◆ mock_shutdown()

static void mock_shutdown ( alts_handshaker_client )
static

Definition at line 507 of file alts_tsi_handshaker_test.cc.

◆ notification_destroy()

static void notification_destroy ( notification n)
static

Definition at line 102 of file alts_tsi_handshaker_test.cc.

◆ notification_init()

static void notification_init ( notification n)
static

Definition at line 96 of file alts_tsi_handshaker_test.cc.

◆ on_client_next_success_cb()

static void on_client_next_success_cb ( tsi_result  status,
void *  user_data,
const unsigned char *  bytes_to_send,
size_t  bytes_to_send_size,
tsi_handshaker_result result 
)
static

Definition at line 300 of file alts_tsi_handshaker_test.cc.

◆ on_client_start_success_cb()

static void on_client_start_success_cb ( tsi_result  status,
void *  user_data,
const unsigned char *  bytes_to_send,
size_t  bytes_to_send_size,
tsi_handshaker_result result 
)
static

Definition at line 246 of file alts_tsi_handshaker_test.cc.

◆ on_failed_grpc_call_cb()

static void on_failed_grpc_call_cb ( tsi_result  status,
void *  user_data,
const unsigned char *  bytes_to_send,
size_t  bytes_to_send_size,
tsi_handshaker_result result 
)
static

Definition at line 717 of file alts_tsi_handshaker_test.cc.

◆ on_failed_resp_cb()

static void on_failed_resp_cb ( tsi_result  status,
void *  user_data,
const unsigned char *  bytes_to_send,
size_t  bytes_to_send_size,
tsi_handshaker_result result 
)
static

Definition at line 941 of file alts_tsi_handshaker_test.cc.

◆ on_invalid_input_cb()

static void on_invalid_input_cb ( tsi_result  status,
void *  user_data,
const unsigned char *  bytes_to_send,
size_t  bytes_to_send_size,
tsi_handshaker_result result 
)
static

Definition at line 706 of file alts_tsi_handshaker_test.cc.

◆ on_invalid_resp_cb()

static void on_invalid_resp_cb ( tsi_result  status,
void *  user_data,
const unsigned char *  bytes_to_send,
size_t  bytes_to_send_size,
tsi_handshaker_result result 
)
static

Definition at line 870 of file alts_tsi_handshaker_test.cc.

◆ on_server_next_success_cb()

static void on_server_next_success_cb ( tsi_result  status,
void *  user_data,
const unsigned char *  bytes_to_send,
size_t  bytes_to_send_size,
tsi_handshaker_result result 
)
static

Definition at line 393 of file alts_tsi_handshaker_test.cc.

◆ on_server_start_success_cb()

static void on_server_start_success_cb ( tsi_result  status,
void *  user_data,
const unsigned char *  bytes_to_send,
size_t  bytes_to_send_size,
tsi_handshaker_result result 
)
static

Definition at line 273 of file alts_tsi_handshaker_test.cc.

◆ on_shutdown_resp_cb()

static void on_shutdown_resp_cb ( tsi_result  status,
void *  user_data,
const unsigned char *  bytes_to_send,
size_t  bytes_to_send_size,
tsi_handshaker_result result 
)
static

Definition at line 985 of file alts_tsi_handshaker_test.cc.

◆ run_tsi_handshaker_destroy_with_exec_ctx()

static void run_tsi_handshaker_destroy_with_exec_ctx ( tsi_handshaker handshaker)
static

Definition at line 580 of file alts_tsi_handshaker_test.cc.

◆ signal()

static void signal ( notification n)
static

Definition at line 107 of file alts_tsi_handshaker_test.cc.

◆ wait()

static void wait ( notification n)
static

Definition at line 114 of file alts_tsi_handshaker_test.cc.

Variable Documentation

◆ caller_to_tsi_notification

notification caller_to_tsi_notification
static

Definition at line 93 of file alts_tsi_handshaker_test.cc.

◆ cb_event

alts_handshaker_client* cb_event = nullptr
static

Definition at line 92 of file alts_tsi_handshaker_test.cc.

◆ should_handshaker_client_api_succeed

bool should_handshaker_client_api_succeed = true
static

Definition at line 73 of file alts_tsi_handshaker_test.cc.

◆ tsi_to_caller_notification

notification tsi_to_caller_notification
static

Definition at line 94 of file alts_tsi_handshaker_test.cc.

◆ vtable

mock_client_start
static tsi_result mock_client_start(alts_handshaker_client *client)
Definition: alts_tsi_handshaker_test.cc:488
mock_destruct
static void mock_destruct(alts_handshaker_client *)
Definition: alts_tsi_handshaker_test.cc:560
mock_shutdown
static void mock_shutdown(alts_handshaker_client *)
Definition: alts_tsi_handshaker_test.cc:507
mock_next
static tsi_result mock_next(alts_handshaker_client *client, grpc_slice *bytes_received)
Definition: alts_tsi_handshaker_test.cc:528
mock_server_start
static tsi_result mock_server_start(alts_handshaker_client *client, grpc_slice *bytes_received)
Definition: alts_tsi_handshaker_test.cc:509


grpc
Author(s):
autogenerated on Fri May 16 2025 03:01:02