alts_tsi_handshaker_test.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2018 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
20 
21 #include <stdio.h>
22 #include <stdlib.h>
23 
24 #include "upb/upb.hpp"
25 
26 #include <grpc/grpc.h>
27 #include <grpc/support/sync.h>
28 
29 #include "src/core/lib/gprpp/thd.h"
37 
38 #define ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES "Hello World"
39 #define ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME "Hello Google"
40 #define ALTS_TSI_HANDSHAKER_TEST_CONSUMED_BYTES "Hello "
41 #define ALTS_TSI_HANDSHAKER_TEST_REMAIN_BYTES "Google"
42 #define ALTS_TSI_HANDSHAKER_TEST_PEER_IDENTITY "chapi@service.google.com"
43 #define ALTS_TSI_HANDSHAKER_TEST_SECURITY_LEVEL "TSI_PRIVACY_AND_INTEGRITY"
44 #define ALTS_TSI_HANDSHAKER_TEST_KEY_DATA \
45  "ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKL"
46 #define ALTS_TSI_HANDSHAKER_TEST_BUFFER_SIZE 100
47 #define ALTS_TSI_HANDSHAKER_TEST_SLEEP_TIME_IN_SECONDS 2
48 #define ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MAJOR 3
49 #define ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MINOR 2
50 #define ALTS_TSI_HANDSHAKER_TEST_MIN_RPC_VERSION_MAJOR 2
51 #define ALTS_TSI_HANDSHAKER_TEST_MIN_RPC_VERSION_MINOR 1
52 #define ALTS_TSI_HANDSHAKER_TEST_LOCAL_IDENTITY "chapilocal@service.google.com"
53 #define ALTS_TSI_HANDSHAKER_TEST_APPLICATION_PROTOCOL \
54  "test application protocol"
55 #define ALTS_TSI_HANDSHAKER_TEST_RECORD_PROTOCOL "test record protocol"
56 #define ALTS_TSI_HANDSHAKER_TEST_MAX_FRAME_SIZE (2 * 1024 * 1024)
57 #define ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_KEY "peer"
58 #define ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_VALUE "attributes"
59 
74 
75 /* ALTS mock notification. */
76 typedef struct notification {
79  bool notified;
80 } notification;
81 
82 /* Type of ALTS handshaker response. */
83 typedef enum {
91 
92 static alts_handshaker_client* cb_event = nullptr;
95 
97  gpr_mu_init(&n->mu);
98  gpr_cv_init(&n->cv);
99  n->notified = false;
100 }
101 
103  gpr_mu_destroy(&n->mu);
104  gpr_cv_destroy(&n->cv);
105 }
106 
107 static void signal(notification* n) {
108  gpr_mu_lock(&n->mu);
109  n->notified = true;
110  gpr_cv_signal(&n->cv);
111  gpr_mu_unlock(&n->mu);
112 }
113 
114 static void wait(notification* n) {
115  gpr_mu_lock(&n->mu);
116  while (!n->notified) {
118  }
119  n->notified = false;
120  gpr_mu_unlock(&n->mu);
121 }
122 
131  grpc_gcp_Identity* peer_identity;
136  grpc_gcp_Identity* local_identity;
137  switch (type) {
138  case INVALID:
139  break;
140  case CLIENT_START:
141  case SERVER_START:
144  break;
145  case CLIENT_NEXT:
151  peer_identity =
154  peer_identity,
159  arena.ptr());
161  peer_identity,
170  local_identity =
173  local_identity,
179  result,
183  break;
184  case SERVER_NEXT:
188  peer_identity =
191  peer_identity,
196  arena.ptr());
198  peer_identity,
207  local_identity =
210  local_identity,
216  result,
218  break;
219  case FAILED:
220  grpc_gcp_HandshakerStatus_set_code(status, 3 /* INVALID ARGUMENT */);
221  break;
222  }
223  size_t buf_len;
224  char* buf = grpc_gcp_HandshakerResp_serialize(resp, arena.ptr(), &buf_len);
226  if (type == INVALID) {
227  grpc_slice bad_slice =
230  slice = grpc_slice_ref(bad_slice);
231  grpc_slice_unref(bad_slice);
232  }
234  grpc_raw_byte_buffer_create(&slice, 1 /* number of slices */);
236  return buffer;
237 }
238 
239 static void check_must_not_be_called(tsi_result /*status*/, void* /*user_data*/,
240  const unsigned char* /*bytes_to_send*/,
241  size_t /*bytes_to_send_size*/,
242  tsi_handshaker_result* /*result*/) {
243  GPR_ASSERT(0);
244 }
245 
246 static void on_client_start_success_cb(tsi_result status, void* user_data,
247  const unsigned char* bytes_to_send,
248  size_t bytes_to_send_size,
251  GPR_ASSERT(user_data == nullptr);
252  GPR_ASSERT(bytes_to_send_size == strlen(ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME));
253  GPR_ASSERT(memcmp(bytes_to_send, ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME,
254  bytes_to_send_size) == 0);
255  GPR_ASSERT(result == nullptr);
256  /* Validate peer identity. */
257  tsi_peer peer;
260  /* Validate frame protector. */
261  tsi_frame_protector* protector = nullptr;
263  result, nullptr, &protector) == TSI_INVALID_ARGUMENT);
264  /* Validate unused bytes. */
265  const unsigned char* unused_bytes = nullptr;
266  size_t unused_bytes_size = 0;
268  &unused_bytes_size) ==
271 }
272 
273 static void on_server_start_success_cb(tsi_result status, void* user_data,
274  const unsigned char* bytes_to_send,
275  size_t bytes_to_send_size,
278  GPR_ASSERT(user_data == nullptr);
279  GPR_ASSERT(bytes_to_send_size == strlen(ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME));
280  GPR_ASSERT(memcmp(bytes_to_send, ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME,
281  bytes_to_send_size) == 0);
282  GPR_ASSERT(result == nullptr);
283  /* Validate peer identity. */
284  tsi_peer peer;
287  /* Validate frame protector. */
288  tsi_frame_protector* protector = nullptr;
290  result, nullptr, &protector) == TSI_INVALID_ARGUMENT);
291  /* Validate unused bytes. */
292  const unsigned char* unused_bytes = nullptr;
293  size_t unused_bytes_size = 0;
295  &unused_bytes_size) ==
298 }
299 
300 static void on_client_next_success_cb(tsi_result status, void* user_data,
301  const unsigned char* bytes_to_send,
302  size_t bytes_to_send_size,
305  GPR_ASSERT(user_data == nullptr);
306  GPR_ASSERT(bytes_to_send_size == strlen(ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME));
307  GPR_ASSERT(memcmp(bytes_to_send, ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME,
308  bytes_to_send_size) == 0);
309  GPR_ASSERT(result != nullptr);
310  // Validate max frame size value after Frame Size Negotiation. Here peer max
311  // frame size is greater than default value, and user specified max frame size
312  // is absent.
313  tsi_zero_copy_grpc_protector* zero_copy_protector = nullptr;
315  result, nullptr, &zero_copy_protector) == TSI_OK);
316  size_t actual_max_frame_size;
318  &actual_max_frame_size);
319  GPR_ASSERT(actual_max_frame_size == kTsiAltsMaxFrameSize);
320  tsi_zero_copy_grpc_protector_destroy(zero_copy_protector);
321  /* Validate peer identity. */
322  tsi_peer peer;
326  peer.properties[0].value.length) == 0);
328  peer.properties[1].value.data,
329  peer.properties[1].value.length) == 0);
330  /* Validate alts context. */
331  upb::Arena context_arena;
333  peer.properties[3].value.data, peer.properties[3].value.length,
334  context_arena.ptr());
335  GPR_ASSERT(ctx != nullptr);
336  upb_StringView application_protocol =
340  upb_StringView local_account =
343  application_protocol.data, application_protocol.size) == 0);
345  record_protocol.data, record_protocol.size) == 0);
347  peer_account.size) == 0);
349  local_account.size) == 0);
350  size_t iter = kUpb_Map_Begin;
351  grpc_gcp_AltsContext_PeerAttributesEntry* peer_attributes_entry =
353  GPR_ASSERT(peer_attributes_entry != nullptr);
354  while (peer_attributes_entry != nullptr) {
357  peer_attributes_entry));
360  peer_attributes_entry));
367  peer_attributes_entry =
369  }
370  /* Validate security level. */
372  peer.properties[4].value.data,
373  peer.properties[4].value.length) == 0);
374  tsi_peer_destruct(&peer);
375  /* Validate unused bytes. */
376  const unsigned char* bytes = nullptr;
377  size_t bytes_size = 0;
379  &bytes_size) == TSI_OK);
380  GPR_ASSERT(bytes_size == strlen(ALTS_TSI_HANDSHAKER_TEST_REMAIN_BYTES));
382  0);
383  /* Validate frame protector. */
384  tsi_frame_protector* protector = nullptr;
386  result, nullptr, &protector) == TSI_OK);
387  GPR_ASSERT(protector != nullptr);
388  tsi_frame_protector_destroy(protector);
391 }
392 
393 static void on_server_next_success_cb(tsi_result status, void* user_data,
394  const unsigned char* bytes_to_send,
395  size_t bytes_to_send_size,
398  GPR_ASSERT(user_data == nullptr);
399  GPR_ASSERT(bytes_to_send_size == 0);
400  GPR_ASSERT(bytes_to_send == nullptr);
401  GPR_ASSERT(result != nullptr);
402  // Validate max frame size value after Frame Size Negotiation. The negotiated
403  // frame size value equals minimum send frame size, due to the absence of peer
404  // max frame size.
405  tsi_zero_copy_grpc_protector* zero_copy_protector = nullptr;
406  size_t user_specified_max_frame_size =
409  result, &user_specified_max_frame_size,
410  &zero_copy_protector) == TSI_OK);
411  size_t actual_max_frame_size;
413  &actual_max_frame_size);
414  GPR_ASSERT(actual_max_frame_size == kTsiAltsMinFrameSize);
415  tsi_zero_copy_grpc_protector_destroy(zero_copy_protector);
416  /* Validate peer identity. */
417  tsi_peer peer;
421  peer.properties[0].value.length) == 0);
423  peer.properties[1].value.data,
424  peer.properties[1].value.length) == 0);
425  /* Validate alts context. */
426  upb::Arena context_arena;
428  peer.properties[3].value.data, peer.properties[3].value.length,
429  context_arena.ptr());
430  GPR_ASSERT(ctx != nullptr);
431  upb_StringView application_protocol =
435  upb_StringView local_account =
438  application_protocol.data, application_protocol.size) == 0);
440  record_protocol.data, record_protocol.size) == 0);
442  peer_account.size) == 0);
444  local_account.size) == 0);
445  size_t iter = kUpb_Map_Begin;
446  grpc_gcp_AltsContext_PeerAttributesEntry* peer_attributes_entry =
448  GPR_ASSERT(peer_attributes_entry != nullptr);
449  while (peer_attributes_entry != nullptr) {
452  peer_attributes_entry));
455  peer_attributes_entry));
462  peer_attributes_entry =
464  }
465  /* Check security level. */
467  peer.properties[4].value.data,
468  peer.properties[4].value.length) == 0);
469 
470  tsi_peer_destruct(&peer);
471  /* Validate unused bytes. */
472  const unsigned char* bytes = nullptr;
473  size_t bytes_size = 0;
475  &bytes_size) == TSI_OK);
476  GPR_ASSERT(bytes_size == 0);
477  GPR_ASSERT(bytes == nullptr);
478  /* Validate frame protector. */
479  tsi_frame_protector* protector = nullptr;
481  result, nullptr, &protector) == TSI_OK);
482  GPR_ASSERT(protector != nullptr);
483  tsi_frame_protector_destroy(protector);
486 }
487 
490  return TSI_INTERNAL_ERROR;
491  }
492  /* Note that the alts_tsi_handshaker needs to set its
493  * has_sent_start_message field field to true
494  * before the call to alts_handshaker_client_start is made because
495  * because it's unsafe to access it afterwards. */
497  client, on_client_start_success_cb, nullptr, true, nullptr);
498  /* Populate handshaker response for client_start request. */
499  grpc_byte_buffer** recv_buffer_ptr =
501  *recv_buffer_ptr = generate_handshaker_response(CLIENT_START);
502  cb_event = client;
504  return TSI_OK;
505 }
506 
507 static void mock_shutdown(alts_handshaker_client* /*self*/) {}
508 
512  return TSI_INTERNAL_ERROR;
513  }
515  client, on_server_start_success_cb, nullptr, true, nullptr);
518  /* Populate handshaker response for server_start request. */
519  grpc_byte_buffer** recv_buffer_ptr =
521  *recv_buffer_ptr = generate_handshaker_response(SERVER_START);
522  cb_event = client;
525  return TSI_OK;
526 }
527 
531  return TSI_INTERNAL_ERROR;
532  }
533  alts_tsi_handshaker* handshaker =
535  bool is_client = alts_tsi_handshaker_get_is_client_for_testing(handshaker);
542  GPR_ASSERT(bytes_received != nullptr);
546  /* Populate handshaker response for next request. */
547  grpc_slice out_frame =
549  grpc_byte_buffer** recv_buffer_ptr =
551  *recv_buffer_ptr = is_client ? generate_handshaker_response(CLIENT_NEXT)
554  cb_event = client;
556  grpc_slice_unref(out_frame);
557  return TSI_OK;
558 }
559 
560 static void mock_destruct(alts_handshaker_client* /*client*/) {}
561 
565 
566 static tsi_handshaker* create_test_handshaker(bool is_client) {
567  tsi_handshaker* handshaker = nullptr;
570  alts_tsi_handshaker_create(options, "target_name",
572  nullptr, &handshaker, 0);
573  alts_tsi_handshaker* alts_handshaker =
574  reinterpret_cast<alts_tsi_handshaker*>(handshaker);
577  return handshaker;
578 }
579 
581  tsi_handshaker* handshaker) {
583  tsi_handshaker_destroy(handshaker);
584 }
585 
587  /* Initialization. */
588  tsi_handshaker* handshaker = create_test_handshaker(true);
589  /* Check nullptr handshaker. */
590  GPR_ASSERT(tsi_handshaker_next(nullptr, nullptr, 0, nullptr, nullptr, nullptr,
592  nullptr) == TSI_INVALID_ARGUMENT);
593  /* Check nullptr callback. */
594  GPR_ASSERT(tsi_handshaker_next(handshaker, nullptr, 0, nullptr, nullptr,
595  nullptr, nullptr,
596  nullptr) == TSI_INVALID_ARGUMENT);
597  /* Cleanup. */
599 }
600 
602  /* Initialization. */
603  tsi_handshaker* handshaker = create_test_handshaker(true /* is_client */);
604  /* Check nullptr handshaker. */
605  tsi_handshaker_shutdown(nullptr);
606  /* Cleanup. */
608 }
609 
615  tsi_handshaker* client_handshaker =
616  create_test_handshaker(true /* is_client */);
617  tsi_handshaker* server_handshaker =
618  create_test_handshaker(false /* is_client */);
619  /* Client start. */
620  GPR_ASSERT(tsi_handshaker_next(client_handshaker, nullptr, 0, nullptr,
621  nullptr, nullptr, on_client_start_success_cb,
622  nullptr) == TSI_ASYNC);
624  /* Client next. */
626  client_handshaker,
627  (const unsigned char*)ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES,
628  strlen(ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES), nullptr, nullptr,
629  nullptr, on_client_next_success_cb, nullptr) == TSI_ASYNC);
631  /* Server start. */
632  GPR_ASSERT(tsi_handshaker_next(server_handshaker, nullptr, 0, nullptr,
633  nullptr, nullptr, on_server_start_success_cb,
634  nullptr) == TSI_ASYNC);
636  /* Server next. */
638  server_handshaker,
639  (const unsigned char*)ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES,
640  strlen(ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES), nullptr, nullptr,
641  nullptr, on_server_next_success_cb, nullptr) == TSI_ASYNC);
643  /* Cleanup. */
644  run_tsi_handshaker_destroy_with_exec_ctx(server_handshaker);
645  run_tsi_handshaker_destroy_with_exec_ctx(client_handshaker);
646 }
647 
649  tsi_handshaker* handshaker = create_test_handshaker(true /* is_client*/);
650  /* next(success) -- shutdown(success) -- next (fail) */
651  GPR_ASSERT(tsi_handshaker_next(handshaker, nullptr, 0, nullptr, nullptr,
653  nullptr) == TSI_ASYNC);
655  tsi_handshaker_shutdown(handshaker);
657  handshaker,
658  (const unsigned char*)ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES,
659  strlen(ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES), nullptr, nullptr,
660  nullptr, on_client_next_success_cb,
661  nullptr) == TSI_HANDSHAKE_SHUTDOWN);
662  /* Cleanup. */
664 }
665 
666 static void check_handle_response_with_shutdown(void* /*unused*/) {
669 }
670 
675  tsi_handshaker* client_handshaker =
676  create_test_handshaker(true /* is_client */);
677  tsi_handshaker* server_handshaker =
678  create_test_handshaker(false /* is_client */);
679  /* Client start. */
680  GPR_ASSERT(tsi_handshaker_next(client_handshaker, nullptr, 0, nullptr,
681  nullptr, nullptr, check_must_not_be_called,
682  nullptr) == TSI_INTERNAL_ERROR);
683  /* Server start. */
684  GPR_ASSERT(tsi_handshaker_next(server_handshaker, nullptr, 0, nullptr,
685  nullptr, nullptr, check_must_not_be_called,
686  nullptr) == TSI_INTERNAL_ERROR);
687  /* Server next. */
689  server_handshaker,
690  (const unsigned char*)ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES,
691  strlen(ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES), nullptr, nullptr,
692  nullptr, check_must_not_be_called,
693  nullptr) == TSI_INTERNAL_ERROR);
694  /* Client next. */
696  client_handshaker,
697  (const unsigned char*)ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES,
698  strlen(ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES), nullptr, nullptr,
699  nullptr, check_must_not_be_called,
700  nullptr) == TSI_INTERNAL_ERROR);
701  /* Cleanup. */
702  run_tsi_handshaker_destroy_with_exec_ctx(server_handshaker);
703  run_tsi_handshaker_destroy_with_exec_ctx(client_handshaker);
704 }
705 
706 static void on_invalid_input_cb(tsi_result status, void* user_data,
707  const unsigned char* bytes_to_send,
708  size_t bytes_to_send_size,
711  GPR_ASSERT(user_data == nullptr);
712  GPR_ASSERT(bytes_to_send == nullptr);
713  GPR_ASSERT(bytes_to_send_size == 0);
714  GPR_ASSERT(result == nullptr);
715 }
716 
717 static void on_failed_grpc_call_cb(tsi_result status, void* user_data,
718  const unsigned char* bytes_to_send,
719  size_t bytes_to_send_size,
722  GPR_ASSERT(user_data == nullptr);
723  GPR_ASSERT(bytes_to_send == nullptr);
724  GPR_ASSERT(bytes_to_send_size == 0);
725  GPR_ASSERT(result == nullptr);
726 }
727 
729  /* Initialization. */
736  tsi_handshaker* handshaker = create_test_handshaker(true /* is_client */);
737  tsi_handshaker_next(handshaker, nullptr, 0, nullptr, nullptr, nullptr,
738  on_client_start_success_cb, nullptr);
739  alts_tsi_handshaker* alts_handshaker =
740  reinterpret_cast<alts_tsi_handshaker*>(handshaker);
745  /* Check nullptr handshaker. */
747  on_invalid_input_cb, nullptr,
748  recv_buffer, GRPC_STATUS_OK);
750  /* Note: here and elsewhere in this test, we first ref the handshaker in order
751  * to match the unref that on_status_received will do. This necessary
752  * because this test mocks out the grpc call in such a way that the code
753  * path that would usually take this ref is skipped. */
755  {
759  }
760  /* Cleanup. */
765 }
766 
768  /* Initialization. */
775  tsi_handshaker* handshaker = create_test_handshaker(true /* is_client */);
776  tsi_handshaker_next(handshaker, nullptr, 0, nullptr, nullptr, nullptr,
777  on_client_start_success_cb, nullptr);
778  alts_tsi_handshaker* alts_handshaker =
779  reinterpret_cast<alts_tsi_handshaker*>(handshaker);
782  /* Check nullptr recv_bytes. */
784  on_invalid_input_cb, nullptr,
785  nullptr, GRPC_STATUS_OK);
788  {
792  }
793  /* Cleanup. */
797 }
798 
800  /* Initialization. */
807  tsi_handshaker* handshaker = create_test_handshaker(true /* is_client */);
808  tsi_handshaker_next(handshaker, nullptr, 0, nullptr, nullptr, nullptr,
809  on_client_start_success_cb, nullptr);
810  alts_tsi_handshaker* alts_handshaker =
811  reinterpret_cast<alts_tsi_handshaker*>(handshaker);
816  /* Check failed grpc call made to handshaker service. */
818  client, alts_handshaker, on_failed_grpc_call_cb, nullptr, recv_buffer,
822  {
826  }
827  /* Cleanup. */
832 }
833 
834 static void
836  /* Initialization. */
843  tsi_handshaker* handshaker = create_test_handshaker(true /* is_client */);
844  tsi_handshaker_next(handshaker, nullptr, 0, nullptr, nullptr, nullptr,
845  on_client_start_success_cb, nullptr);
846  alts_tsi_handshaker* alts_handshaker =
847  reinterpret_cast<alts_tsi_handshaker*>(handshaker);
852  /* Check failed recv message op from handshaker service. */
854  on_failed_grpc_call_cb, nullptr,
855  recv_buffer, GRPC_STATUS_OK);
858  {
862  }
863  /* Cleanup. */
868 }
869 
870 static void on_invalid_resp_cb(tsi_result status, void* user_data,
871  const unsigned char* bytes_to_send,
872  size_t bytes_to_send_size,
875  GPR_ASSERT(user_data == nullptr);
876  GPR_ASSERT(bytes_to_send == nullptr);
877  GPR_ASSERT(bytes_to_send_size == 0);
878  GPR_ASSERT(result == nullptr);
879 }
880 
882  /* Initialization. */
889  tsi_handshaker* handshaker = create_test_handshaker(true /* is_client */);
890  tsi_handshaker_next(handshaker, nullptr, 0, nullptr, nullptr, nullptr,
891  on_client_start_success_cb, nullptr);
892  alts_tsi_handshaker* alts_handshaker =
893  reinterpret_cast<alts_tsi_handshaker*>(handshaker);
896  /* Tests. */
899  on_invalid_resp_cb, nullptr,
900  recv_buffer, GRPC_STATUS_OK);
903  {
907  }
908  /* Cleanup. */
912 }
913 
914 static void check_handle_response_success(void* /*unused*/) {
915  /* Client start. */
918  /* Client next. */
922  {
926  }
927  /* Server start. */
930  /* Server next. */
934  {
938  }
939 }
940 
941 static void on_failed_resp_cb(tsi_result status, void* user_data,
942  const unsigned char* bytes_to_send,
943  size_t bytes_to_send_size,
946  GPR_ASSERT(user_data == nullptr);
947  GPR_ASSERT(bytes_to_send == nullptr);
948  GPR_ASSERT(bytes_to_send_size == 0);
949  GPR_ASSERT(result == nullptr);
950 }
951 
953  /* Initialization. */
960  tsi_handshaker* handshaker = create_test_handshaker(true /* is_client */);
961  tsi_handshaker_next(handshaker, nullptr, 0, nullptr, nullptr, nullptr,
962  on_client_start_success_cb, nullptr);
963  alts_tsi_handshaker* alts_handshaker =
964  reinterpret_cast<alts_tsi_handshaker*>(handshaker);
967  /* Tests. */
970  on_failed_resp_cb, nullptr,
971  recv_buffer, GRPC_STATUS_OK);
974  {
978  }
979  /* Cleanup. */
983 }
984 
985 static void on_shutdown_resp_cb(tsi_result status, void* user_data,
986  const unsigned char* bytes_to_send,
987  size_t bytes_to_send_size,
990  GPR_ASSERT(user_data == nullptr);
991  GPR_ASSERT(bytes_to_send == nullptr);
992  GPR_ASSERT(bytes_to_send_size == 0);
993  GPR_ASSERT(result == nullptr);
994 }
995 
997  /* Initialization. */
1000  tsi_handshaker* handshaker = create_test_handshaker(true /* is_client */);
1001  tsi_handshaker_next(handshaker, nullptr, 0, nullptr, nullptr, nullptr,
1002  on_client_start_success_cb, nullptr);
1003  alts_tsi_handshaker* alts_handshaker =
1004  reinterpret_cast<alts_tsi_handshaker*>(handshaker);
1007  grpc_byte_buffer** recv_buffer_ptr =
1009  grpc_byte_buffer_destroy(*recv_buffer_ptr);
1010 
1011  /* Tests. */
1012  tsi_handshaker_shutdown(handshaker);
1015  on_shutdown_resp_cb, nullptr,
1016  recv_buffer, GRPC_STATUS_OK);
1019  {
1023  }
1024  /* Cleanup. */
1028 }
1029 
1031  /* Initialization. */
1034  cb_event = nullptr;
1035  /* Tests. */
1036  grpc_core::Thread thd("alts_tsi_handshaker_test",
1038  thd.Start();
1040  thd.Join();
1041  /* Cleanup. */
1044 }
1045 
1047  /* Initialization. */
1050  /* Tests. */
1051  grpc_core::Thread thd("alts_tsi_handshaker_test",
1052  &check_handle_response_success, nullptr);
1053  thd.Start();
1055  thd.Join();
1056  /* Cleanup. */
1059 }
1060 
1061 int main(int argc, char** argv) {
1062  grpc::testing::TestEnvironment env(&argc, argv);
1063  /* Initialization. */
1064  grpc_init();
1066  /* Tests. */
1081  /* Cleanup. */
1083  grpc_shutdown();
1084  return 0;
1085 }
altscontext.upb.h
ALTS_TSI_HANDSHAKER_TEST_MIN_RPC_VERSION_MINOR
#define ALTS_TSI_HANDSHAKER_TEST_MIN_RPC_VERSION_MINOR
Definition: alts_tsi_handshaker_test.cc:51
gpr_cv_signal
GPRAPI void gpr_cv_signal(gpr_cv *cv)
SERVER_START
@ SERVER_START
Definition: alts_tsi_handshaker_test.cc:87
grpc_slice_unref
GPRAPI void grpc_slice_unref(grpc_slice s)
Definition: slice_api.cc:32
ALTS_TSI_HANDSHAKER_TEST_RECORD_PROTOCOL
#define ALTS_TSI_HANDSHAKER_TEST_RECORD_PROTOCOL
Definition: alts_tsi_handshaker_test.cc:55
grpc_alts_credentials_options_destroy
GRPCAPI void grpc_alts_credentials_options_destroy(grpc_alts_credentials_options *options)
Definition: grpc_alts_credentials_options.cc:38
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
check_handle_response_nullptr_handshaker
static void check_handle_response_nullptr_handshaker()
Definition: alts_tsi_handshaker_test.cc:728
grpc_core::internal::alts_handshaker_client_set_cb_for_testing
void alts_handshaker_client_set_cb_for_testing(alts_handshaker_client *c, tsi_handshaker_on_next_done_cb cb)
Definition: alts_handshaker_client.cc:822
grpc_gcp_HandshakerStatus
struct grpc_gcp_HandshakerStatus grpc_gcp_HandshakerStatus
Definition: handshaker.upb.h:45
gpr_mu_unlock
GPRAPI void gpr_mu_unlock(gpr_mu *mu)
notification_destroy
static void notification_destroy(notification *n)
Definition: alts_tsi_handshaker_test.cc:102
GRPC_ERROR_NONE
#define GRPC_ERROR_NONE
Definition: error.h:234
grpc_core::internal::alts_handshaker_client_ref_for_testing
void alts_handshaker_client_ref_for_testing(alts_handshaker_client *c)
Definition: alts_handshaker_client.cc:838
tsi_peer::properties
tsi_peer_property * properties
Definition: transport_security_interface.h:239
grpc_gcp_HandshakerResp_set_bytes_consumed
UPB_INLINE void grpc_gcp_HandshakerResp_set_bytes_consumed(grpc_gcp_HandshakerResp *msg, uint32_t value)
Definition: handshaker.upb.h:1095
tsi_peer_property::value
struct tsi_peer_property::@48 value
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)
Definition: alts_tsi_handshaker_test.cc:393
grpc_raw_byte_buffer_create
GRPCAPI grpc_byte_buffer * grpc_raw_byte_buffer_create(grpc_slice *slices, size_t nslices)
Definition: byte_buffer.cc:34
ctx
Definition: benchmark-async.c:30
alts_tsi_handshaker_private.h
generate.env
env
Definition: generate.py:37
check_handshaker_success
void check_handshaker_success()
Definition: alts_tsi_handshaker_test.cc:1046
kUpb_Map_Begin
#define kUpb_Map_Begin
Definition: upb/upb/upb.h:329
check_handle_response_success
static void check_handle_response_success(void *)
Definition: alts_tsi_handshaker_test.cc:914
tsi_zero_copy_grpc_protector_destroy
void tsi_zero_copy_grpc_protector_destroy(tsi_zero_copy_grpc_protector *self)
Definition: transport_security_grpc.cc:64
alts_tsi_handshaker
Definition: alts_tsi_handshaker.cc:49
tsi_handshaker
Definition: transport_security.h:84
ALTS_TSI_HANDSHAKER_TEST_KEY_DATA
#define ALTS_TSI_HANDSHAKER_TEST_KEY_DATA
Definition: alts_tsi_handshaker_test.cc:44
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)
Definition: alts_tsi_handshaker_test.cc:300
grpc_gcp_HandshakerResult_set_max_frame_size
UPB_INLINE void grpc_gcp_HandshakerResult_set_max_frame_size(grpc_gcp_HandshakerResult *msg, uint32_t value)
Definition: handshaker.upb.h:975
grpc_gcp_HandshakerResult_mutable_peer_identity
UPB_INLINE struct grpc_gcp_Identity * grpc_gcp_HandshakerResult_mutable_peer_identity(grpc_gcp_HandshakerResult *msg, upb_Arena *arena)
Definition: handshaker.upb.h:937
ALTS_TSI_HANDSHAKER_TEST_PEER_IDENTITY
#define ALTS_TSI_HANDSHAKER_TEST_PEER_IDENTITY
Definition: alts_tsi_handshaker_test.cc:42
tsi_handshaker_destroy
void tsi_handshaker_destroy(tsi_handshaker *self)
Definition: transport_security.cc:237
TSI_INTERNAL_ERROR
@ TSI_INTERNAL_ERROR
Definition: transport_security_interface.h:39
grpc_core::internal::alts_handshaker_client_get_recv_buffer_addr_for_testing
grpc_byte_buffer ** alts_handshaker_client_get_recv_buffer_addr_for_testing(alts_handshaker_client *c)
Definition: alts_handshaker_client.cc:752
upb_StringView::data
const char * data
Definition: upb/upb/upb.h:73
client
Definition: examples/python/async_streaming/client.py:1
alts_tsi_handshaker.h
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)
Definition: alts_tsi_handshaker_test.cc:706
caller_to_tsi_notification
static notification caller_to_tsi_notification
Definition: alts_tsi_handshaker_test.cc:93
tsi_handshaker_result_get_unused_bytes
tsi_result tsi_handshaker_result_get_unused_bytes(const tsi_handshaker_result *self, const unsigned char **bytes, size_t *bytes_size)
Definition: transport_security.cc:277
gpr_cv
pthread_cond_t gpr_cv
Definition: impl/codegen/sync_posix.h:48
tsi_peer_property::length
size_t length
Definition: transport_security_interface.h:234
options
double_dict options[]
Definition: capstone_test.c:55
mock_client_start
static tsi_result mock_client_start(alts_handshaker_client *client)
Definition: alts_tsi_handshaker_test.cc:488
grpc_gcp_AltsContext_local_service_account
UPB_INLINE upb_StringView grpc_gcp_AltsContext_local_service_account(const grpc_gcp_AltsContext *msg)
Definition: altscontext.upb.h:92
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
grpc_alts_shared_resource_dedicated_init
void grpc_alts_shared_resource_dedicated_init()
Definition: alts_shared_resource.cc:50
grpc_slice_cmp
GPRAPI int grpc_slice_cmp(grpc_slice a, grpc_slice b)
Definition: slice/slice.cc:419
ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MINOR
#define ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MINOR
Definition: alts_tsi_handshaker_test.cc:49
mock_destruct
static void mock_destruct(alts_handshaker_client *)
Definition: alts_tsi_handshaker_test.cc:560
bytes_received
static int bytes_received
Definition: test-callback-stack.c:44
alts_handshaker_client_vtable
Definition: alts_handshaker_client.h:54
ALTS_TSI_HANDSHAKER_TEST_MAX_FRAME_SIZE
#define ALTS_TSI_HANDSHAKER_TEST_MAX_FRAME_SIZE
Definition: alts_tsi_handshaker_test.cc:56
grpc_gcp_HandshakerResp_new
UPB_INLINE grpc_gcp_HandshakerResp * grpc_gcp_HandshakerResp_new(upb_Arena *arena)
Definition: handshaker.upb.h:1032
CLIENT_NEXT
@ CLIENT_NEXT
Definition: alts_tsi_handshaker_test.cc:88
grpc_gcp_AltsContext_PeerAttributesEntry_key
UPB_INLINE upb_StringView grpc_gcp_AltsContext_PeerAttributesEntry_key(const grpc_gcp_AltsContext_PeerAttributesEntry *msg)
Definition: altscontext.upb.h:161
kTsiAltsNumOfPeerProperties
const size_t kTsiAltsNumOfPeerProperties
Definition: alts_tsi_handshaker.h:39
status
absl::Status status
Definition: rls.cc:251
ALTS_TSI_HANDSHAKER_TEST_REMAIN_BYTES
#define ALTS_TSI_HANDSHAKER_TEST_REMAIN_BYTES
Definition: alts_tsi_handshaker_test.cc:41
gpr_inf_future
GPRAPI gpr_timespec gpr_inf_future(gpr_clock_type type)
Definition: src/core/lib/gpr/time.cc:55
ALTS_TSI_HANDSHAKER_TEST_CONSUMED_BYTES
#define ALTS_TSI_HANDSHAKER_TEST_CONSUMED_BYTES
Definition: alts_tsi_handshaker_test.cc:40
FAILED
@ FAILED
Definition: alts_tsi_handshaker_test.cc:85
grpc_alts_shared_resource_dedicated_shutdown
void grpc_alts_shared_resource_dedicated_shutdown()
Definition: alts_shared_resource.cc:80
check_handshaker_next_success
static void check_handshaker_next_success()
Definition: alts_tsi_handshaker_test.cc:610
TSI_HANDSHAKE_SHUTDOWN
@ TSI_HANDSHAKE_SHUTDOWN
Definition: transport_security_interface.h:46
main
int main(int argc, char **argv)
Definition: alts_tsi_handshaker_test.cc:1061
mock_shutdown
static void mock_shutdown(alts_handshaker_client *)
Definition: alts_tsi_handshaker_test.cc:507
ALTS_TSI_HANDSHAKER_TEST_APPLICATION_PROTOCOL
#define ALTS_TSI_HANDSHAKER_TEST_APPLICATION_PROTOCOL
Definition: alts_tsi_handshaker_test.cc:53
alts_handshaker_client_handle_response
void alts_handshaker_client_handle_response(alts_handshaker_client *c, bool is_ok)
Definition: alts_handshaker_client.cc:190
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
mock_next
static tsi_result mock_next(alts_handshaker_client *client, grpc_slice *bytes_received)
Definition: alts_tsi_handshaker_test.cc:528
ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_VALUE
#define ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_VALUE
Definition: alts_tsi_handshaker_test.cc:58
client
static uv_tcp_t client
Definition: test-callback-stack.c:33
tsi_to_caller_notification
static notification tsi_to_caller_notification
Definition: alts_tsi_handshaker_test.cc:94
ALTS_HANDSHAKER_SERVICE_URL_FOR_TESTING
#define ALTS_HANDSHAKER_SERVICE_URL_FOR_TESTING
Definition: alts_handshaker_client.h:36
grpc_gcp_Identity_set_service_account
UPB_INLINE void grpc_gcp_Identity_set_service_account(grpc_gcp_Identity *msg, upb_StringView value)
Definition: handshaker.upb.h:209
gpr_mu_destroy
GPRAPI void gpr_mu_destroy(gpr_mu *mu)
TSI_OK
@ TSI_OK
Definition: transport_security_interface.h:32
grpc_gcp_HandshakerStatus_set_code
UPB_INLINE void grpc_gcp_HandshakerStatus_set_code(grpc_gcp_HandshakerStatus *msg, uint32_t value)
Definition: handshaker.upb.h:1023
grpc_gcp_Identity_attributes_set
UPB_INLINE bool grpc_gcp_Identity_attributes_set(grpc_gcp_Identity *msg, upb_StringView key, upb_StringView val, upb_Arena *a)
Definition: handshaker.upb.h:216
grpc_gcp_HandshakerResult_set_application_protocol
UPB_INLINE void grpc_gcp_HandshakerResult_set_application_protocol(grpc_gcp_HandshakerResult *msg, upb_StringView value)
Definition: handshaker.upb.h:924
alts_handshaker_client.h
grpc_gcp_AltsContext_PeerAttributesEntry_value
UPB_INLINE upb_StringView grpc_gcp_AltsContext_PeerAttributesEntry_value(const grpc_gcp_AltsContext_PeerAttributesEntry *msg)
Definition: altscontext.upb.h:166
grpc_alts_credentials_client_options_create
GRPCAPI grpc_alts_credentials_options * grpc_alts_credentials_client_options_create(void)
Definition: grpc_alts_credentials_client_options.cc:73
GRPC_STATUS_OK
@ GRPC_STATUS_OK
Definition: include/grpc/impl/codegen/status.h:30
grpc_gcp_HandshakerResp_mutable_status
UPB_INLINE struct grpc_gcp_HandshakerStatus * grpc_gcp_HandshakerResp_mutable_status(grpc_gcp_HandshakerResp *msg, upb_Arena *arena)
Definition: handshaker.upb.h:1115
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
grpc_gcp_HandshakerResp
struct grpc_gcp_HandshakerResp grpc_gcp_HandshakerResp
Definition: handshaker.upb.h:46
ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_KEY
#define ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_KEY
Definition: alts_tsi_handshaker_test.cc:57
mock_server_start
static tsi_result mock_server_start(alts_handshaker_client *client, grpc_slice *bytes_received)
Definition: alts_tsi_handshaker_test.cc:509
gpr_cv_destroy
GPRAPI void gpr_cv_destroy(gpr_cv *cv)
signal
static void signal(notification *n)
Definition: alts_tsi_handshaker_test.cc:107
upb_StringView::size
size_t size
Definition: upb/upb/upb.h:74
grpc_core::internal::alts_handshaker_client_check_fields_for_testing
void alts_handshaker_client_check_fields_for_testing(alts_handshaker_client *c, tsi_handshaker_on_next_done_cb cb, void *user_data, bool has_sent_start_message, grpc_slice *recv_bytes)
Definition: alts_handshaker_client.cc:790
ALTS_TSI_HANDSHAKER_TEST_LOCAL_IDENTITY
#define ALTS_TSI_HANDSHAKER_TEST_LOCAL_IDENTITY
Definition: alts_tsi_handshaker_test.cc:52
ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME
#define ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME
Definition: alts_tsi_handshaker_test.cc:39
slice
grpc_slice slice
Definition: src/core/lib/surface/server.cc:467
gpr_mu_init
GPRAPI void gpr_mu_init(gpr_mu *mu)
http2_server_health_check.resp
resp
Definition: http2_server_health_check.py:31
grpc_gcp_handshaker_resp_set_peer_rpc_versions
bool grpc_gcp_handshaker_resp_set_peer_rpc_versions(grpc_gcp_HandshakerResp *resp, upb_Arena *arena, uint32_t max_major, uint32_t max_minor, uint32_t min_major, uint32_t min_minor)
Definition: alts_handshaker_service_api_test_lib.cc:21
create_test_handshaker
static tsi_handshaker * create_test_handshaker(bool is_client)
Definition: alts_tsi_handshaker_test.cc:566
should_handshaker_client_api_succeed
static bool should_handshaker_client_api_succeed
Definition: alts_tsi_handshaker_test.cc:73
CLIENT_START
@ CLIENT_START
Definition: alts_tsi_handshaker_test.cc:86
check_handshaker_next_with_shutdown
static void check_handshaker_next_with_shutdown()
Definition: alts_tsi_handshaker_test.cc:648
grpc.h
grpc_byte_buffer
Definition: grpc_types.h:43
tsi_handshaker_on_next_done_cb
void(* tsi_handshaker_on_next_done_cb)(tsi_result status, void *user_data, const unsigned char *bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result *handshaker_result)
Definition: transport_security_interface.h:462
tsi_handshaker_result_create_zero_copy_grpc_protector
tsi_result tsi_handshaker_result_create_zero_copy_grpc_protector(const tsi_handshaker_result *self, size_t *max_output_protected_frame_size, tsi_zero_copy_grpc_protector **protector)
Definition: transport_security_grpc.cc:24
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)
Definition: alts_tsi_handshaker_test.cc:273
tsi_result
tsi_result
Definition: transport_security_interface.h:31
GRPC_SLICE_START_PTR
#define GRPC_SLICE_START_PTR(slice)
Definition: include/grpc/impl/codegen/slice.h:101
check_handshaker_shutdown_invalid_input
static void check_handshaker_shutdown_invalid_input()
Definition: alts_tsi_handshaker_test.cc:601
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)
Definition: alts_tsi_handshaker_test.cc:870
ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MAJOR
#define ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MAJOR
Definition: alts_tsi_handshaker_test.cc:48
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)
Definition: alts_tsi_handshaker_test.cc:985
gpr_cv_wait
GPRAPI int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline)
grpc_slice_from_static_string
GPRAPI grpc_slice grpc_slice_from_static_string(const char *source)
Definition: slice/slice.cc:89
grpc_gcp_AltsContext
struct grpc_gcp_AltsContext grpc_gcp_AltsContext
Definition: altscontext.upb.h:25
grpc_empty_slice
GPRAPI grpc_slice grpc_empty_slice(void)
Definition: slice/slice.cc:42
grpc_gcp_AltsContext_peer_service_account
UPB_INLINE upb_StringView grpc_gcp_AltsContext_peer_service_account(const grpc_gcp_AltsContext *msg)
Definition: altscontext.upb.h:86
grpc_slice
Definition: include/grpc/impl/codegen/slice.h:65
grpc_core::internal::alts_tsi_handshaker_get_is_client_for_testing
bool alts_tsi_handshaker_get_is_client_for_testing(alts_tsi_handshaker *handshaker)
Definition: alts_tsi_handshaker.cc:701
gpr_mu_lock
GPRAPI void gpr_mu_lock(gpr_mu *mu)
ALTS_TSI_HANDSHAKER_TEST_MIN_RPC_VERSION_MAJOR
#define ALTS_TSI_HANDSHAKER_TEST_MIN_RPC_VERSION_MAJOR
Definition: alts_tsi_handshaker_test.cc:50
alts_handshaker_client
Definition: alts_handshaker_client.cc:43
tsi_peer_property::data
char * data
Definition: transport_security_interface.h:233
alts_shared_resource.h
grpc_core::internal::alts_handshaker_client_get_handshaker_for_testing
alts_tsi_handshaker * alts_handshaker_client_get_handshaker_for_testing(alts_handshaker_client *c)
Definition: alts_handshaker_client.cc:814
check_handle_response_after_shutdown
static void check_handle_response_after_shutdown()
Definition: alts_tsi_handshaker_test.cc:996
buffer
char buffer[1024]
Definition: libuv/docs/code/idle-compute/main.c:8
check_handshaker_next_failure
static void check_handshaker_next_failure()
Definition: alts_tsi_handshaker_test.cc:671
notification::notified
bool notified
Definition: alts_tsi_handshaker_test.cc:79
upb_StringView_IsEqual
UPB_INLINE bool upb_StringView_IsEqual(upb_StringView a, upb_StringView b)
Definition: upb/upb/upb.h:89
TSI_ALTS_CERTIFICATE_TYPE
#define TSI_ALTS_CERTIFICATE_TYPE
Definition: alts_tsi_handshaker.h:35
grpc_core::ExecCtx
Definition: exec_ctx.h:97
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)
Definition: alts_tsi_handshaker_test.cc:717
n
int n
Definition: abseil-cpp/absl/container/btree_test.cc:1080
alts_tsi_handshaker_create
tsi_result alts_tsi_handshaker_create(const grpc_alts_credentials_options *options, const char *target_name, const char *handshaker_service_url, bool is_client, grpc_pollset_set *interested_parties, tsi_handshaker **self, size_t user_specified_max_frame_size)
Definition: alts_tsi_handshaker.cc:639
tsi_handshaker_result_extract_peer
tsi_result tsi_handshaker_result_extract_peer(const tsi_handshaker_result *self, tsi_peer *peer)
Definition: transport_security.cc:244
vtable
static alts_handshaker_client_vtable vtable
Definition: alts_tsi_handshaker_test.cc:562
check_must_not_be_called
static void check_must_not_be_called(tsi_result, void *, const unsigned char *, size_t, tsi_handshaker_result *)
Definition: alts_tsi_handshaker_test.cc:239
grpc_gcp_HandshakerResp_serialize
UPB_INLINE char * grpc_gcp_HandshakerResp_serialize(const grpc_gcp_HandshakerResp *msg, upb_Arena *arena, size_t *len)
Definition: handshaker.upb.h:1054
INVALID
@ INVALID
Definition: alts_tsi_handshaker_test.cc:84
GRPC_SLICE_LENGTH
#define GRPC_SLICE_LENGTH(slice)
Definition: include/grpc/impl/codegen/slice.h:104
tsi_handshaker_shutdown
void tsi_handshaker_shutdown(tsi_handshaker *self)
Definition: transport_security.cc:229
grpc_gcp_HandshakerResult_set_record_protocol
UPB_INLINE void grpc_gcp_HandshakerResult_set_record_protocol(grpc_gcp_HandshakerResult *msg, upb_StringView value)
Definition: handshaker.upb.h:927
test_config.h
grpc_gcp_AltsContext_peer_attributes_nextmutable
UPB_INLINE grpc_gcp_AltsContext_PeerAttributesEntry * grpc_gcp_AltsContext_peer_attributes_nextmutable(grpc_gcp_AltsContext *msg, size_t *iter)
Definition: altscontext.upb.h:155
kTsiAltsMinFrameSize
const size_t kTsiAltsMinFrameSize
Definition: alts_tsi_handshaker.h:43
tsi_handshaker_next
tsi_result tsi_handshaker_next(tsi_handshaker *self, const unsigned char *received_bytes, size_t received_bytes_size, const unsigned char **bytes_to_send, size_t *bytes_to_send_size, tsi_handshaker_result **handshaker_result, tsi_handshaker_on_next_done_cb cb, void *user_data)
Definition: transport_security.cc:215
upb::Arena::ptr
upb_Arena * ptr()
Definition: upb.hpp:76
TSI_DATA_CORRUPTED
@ TSI_DATA_CORRUPTED
Definition: transport_security_interface.h:40
tsi_peer
Definition: transport_security_interface.h:238
grpc_alts_credentials_options
Definition: grpc_alts_credentials_options.h:35
grpc_gcp_HandshakerResult_mutable_local_identity
UPB_INLINE struct grpc_gcp_Identity * grpc_gcp_HandshakerResult_mutable_local_identity(grpc_gcp_HandshakerResult *msg, upb_Arena *arena)
Definition: handshaker.upb.h:950
grpc_core::internal::alts_handshaker_client_set_recv_bytes_for_testing
void alts_handshaker_client_set_recv_bytes_for_testing(alts_handshaker_client *c, grpc_slice *recv_bytes)
Definition: alts_handshaker_client.cc:768
upb::Arena
Definition: upb.hpp:68
generate_handshaker_response
static grpc_byte_buffer * generate_handshaker_response(alts_handshaker_response_type type)
Definition: alts_tsi_handshaker_test.cc:127
grpc_gcp_Identity
struct grpc_gcp_Identity grpc_gcp_Identity
Definition: handshaker.upb.h:36
tsi_handshaker_result_destroy
void tsi_handshaker_result_destroy(tsi_handshaker_result *self)
Definition: transport_security.cc:288
grpc_gcp_AltsContext_record_protocol
UPB_INLINE upb_StringView grpc_gcp_AltsContext_record_protocol(const grpc_gcp_AltsContext *msg)
Definition: altscontext.upb.h:74
key
const char * key
Definition: hpack_parser_table.cc:164
upb_StringView
Definition: upb/upb/upb.h:72
bytes
uint8 bytes[10]
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream_unittest.cc:153
kTsiAltsMaxFrameSize
const size_t kTsiAltsMaxFrameSize
Definition: alts_tsi_handshaker.h:44
gpr_mu
pthread_mutex_t gpr_mu
Definition: impl/codegen/sync_posix.h:47
gpr_slice_from_copied_buffer
#define gpr_slice_from_copied_buffer
Definition: gpr_slice.h:45
notification
Definition: alts_tsi_handshaker_test.cc:76
upb.hpp
TSI_ASYNC
@ TSI_ASYNC
Definition: transport_security_interface.h:45
notification
struct notification notification
exec_ctx
grpc_core::ExecCtx exec_ctx
Definition: end2end_binder_transport_test.cc:75
ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES
#define ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES
Definition: alts_tsi_handshaker_test.cc:38
check_handle_response_failed_recv_message_from_handshaker_service
static void check_handle_response_failed_recv_message_from_handshaker_service()
Definition: alts_tsi_handshaker_test.cc:835
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)
Definition: alts_tsi_handshaker_test.cc:246
grpc_gcp_AltsContext_application_protocol
UPB_INLINE upb_StringView grpc_gcp_AltsContext_application_protocol(const grpc_gcp_AltsContext *msg)
Definition: altscontext.upb.h:68
grpc::testing::TestEnvironment
Definition: test/core/util/test_config.h:54
grpc_gcp_HandshakerResult
struct grpc_gcp_HandshakerResult grpc_gcp_HandshakerResult
Definition: handshaker.upb.h:44
thd.h
grpc_gcp_AltsContext_PeerAttributesEntry
struct grpc_gcp_AltsContext_PeerAttributesEntry grpc_gcp_AltsContext_PeerAttributesEntry
Definition: altscontext.upb.h:26
grpc_gcp_AltsContext_parse
UPB_INLINE grpc_gcp_AltsContext * grpc_gcp_AltsContext_parse(const char *buf, size_t size, upb_Arena *arena)
Definition: altscontext.upb.h:39
grpc_byte_buffer_destroy
GRPCAPI void grpc_byte_buffer_destroy(grpc_byte_buffer *bb)
Definition: byte_buffer.cc:81
check_handshaker_next_invalid_input
static void check_handshaker_next_invalid_input()
Definition: alts_tsi_handshaker_test.cc:586
TSI_INVALID_ARGUMENT
@ TSI_INVALID_ARGUMENT
Definition: transport_security_interface.h:34
grpc_core::internal::alts_handshaker_client_set_fields_for_testing
void alts_handshaker_client_set_fields_for_testing(alts_handshaker_client *c, alts_tsi_handshaker *handshaker, tsi_handshaker_on_next_done_cb cb, void *user_data, grpc_byte_buffer *recv_buffer, grpc_status_code status)
Definition: alts_handshaker_client.cc:776
run_tsi_handshaker_destroy_with_exec_ctx
static void run_tsi_handshaker_destroy_with_exec_ctx(tsi_handshaker *handshaker)
Definition: alts_tsi_handshaker_test.cc:580
wait
static void wait(notification *n)
Definition: alts_tsi_handshaker_test.cc:114
grpc_core::Thread
Definition: thd.h:43
grpc_slice_split_head
GPRAPI grpc_slice grpc_slice_split_head(grpc_slice *s, size_t split)
Definition: slice/slice.cc:347
notification::cv
gpr_cv cv
Definition: alts_tsi_handshaker_test.cc:77
check_handshaker_next_fails_after_shutdown
void check_handshaker_next_fails_after_shutdown()
Definition: alts_tsi_handshaker_test.cc:1030
upb_StringView_FromString
UPB_INLINE upb_StringView upb_StringView_FromString(const char *data)
Definition: upb/upb/upb.h:85
tsi_handshaker_result_create_frame_protector
tsi_result tsi_handshaker_result_create_frame_protector(const tsi_handshaker_result *self, size_t *max_output_protected_frame_size, tsi_frame_protector **protector)
Definition: transport_security.cc:266
cb_event
static alts_handshaker_client * cb_event
Definition: alts_tsi_handshaker_test.cc:92
tsi_handshaker_result
Definition: transport_security.h:121
check_handle_response_with_shutdown
static void check_handle_response_with_shutdown(void *)
Definition: alts_tsi_handshaker_test.cc:666
grpc_core::internal::alts_tsi_handshaker_set_client_vtable_for_testing
void alts_tsi_handshaker_set_client_vtable_for_testing(alts_tsi_handshaker *handshaker, alts_handshaker_client_vtable *vtable)
Definition: alts_tsi_handshaker.cc:695
notification::mu
gpr_mu mu
Definition: alts_tsi_handshaker_test.cc:78
check_handle_response_invalid_resp
static void check_handle_response_invalid_resp()
Definition: alts_tsi_handshaker_test.cc:881
tsi_zero_copy_grpc_protector_max_frame_size
tsi_result tsi_zero_copy_grpc_protector_max_frame_size(tsi_zero_copy_grpc_protector *self, size_t *max_frame_size)
Definition: transport_security_grpc.cc:69
grpc_core::internal::alts_handshaker_client_on_status_received_for_testing
void alts_handshaker_client_on_status_received_for_testing(alts_handshaker_client *c, grpc_status_code status, grpc_error_handle error)
Definition: alts_handshaker_client.cc:844
alts_handshaker_service_api_test_lib.h
iter
Definition: test_winkernel.cpp:47
grpc_gcp_HandshakerResult_set_key_data
UPB_INLINE void grpc_gcp_HandshakerResult_set_key_data(grpc_gcp_HandshakerResult *msg, upb_StringView value)
Definition: handshaker.upb.h:930
check_handle_response_failed_grpc_call_to_handshaker_service
static void check_handle_response_failed_grpc_call_to_handshaker_service()
Definition: alts_tsi_handshaker_test.cc:799
check_handle_response_failure
static void check_handle_response_failure()
Definition: alts_tsi_handshaker_test.cc:952
tsi_frame_protector
Definition: transport_security.h:51
tsi_frame_protector_destroy
void tsi_frame_protector_destroy(tsi_frame_protector *self)
Definition: transport_security.cc:135
profile_analyzer.thd
thd
Definition: profile_analyzer.py:168
alts_handshaker_response_type
alts_handshaker_response_type
Definition: alts_tsi_handshaker_test.cc:83
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
grpc_core::internal::alts_tsi_handshaker_get_client_for_testing
alts_handshaker_client * alts_tsi_handshaker_get_client_for_testing(alts_tsi_handshaker *handshaker)
Definition: alts_tsi_handshaker.cc:707
tsi_zero_copy_grpc_protector
Definition: transport_security_grpc.h:79
grpc_gcp_HandshakerResp_mutable_result
UPB_INLINE struct grpc_gcp_HandshakerResult * grpc_gcp_HandshakerResp_mutable_result(grpc_gcp_HandshakerResp *msg, upb_Arena *arena)
Definition: handshaker.upb.h:1102
grpc_init
GRPCAPI void grpc_init(void)
Definition: init.cc:146
grpc_gcp_HandshakerResp_set_out_frames
UPB_INLINE void grpc_gcp_HandshakerResp_set_out_frames(grpc_gcp_HandshakerResp *msg, upb_StringView value)
Definition: handshaker.upb.h:1092
check_handle_response_nullptr_recv_bytes
static void check_handle_response_nullptr_recv_bytes()
Definition: alts_tsi_handshaker_test.cc:767
notification_init
static void notification_init(notification *n)
Definition: alts_tsi_handshaker_test.cc:96
GPR_CLOCK_REALTIME
@ GPR_CLOCK_REALTIME
Definition: gpr_types.h:39
sync.h
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)
Definition: alts_tsi_handshaker_test.cc:941
tsi_peer_destruct
void tsi_peer_destruct(tsi_peer *self)
Definition: transport_security.cc:320
grpc_shutdown
GRPCAPI void grpc_shutdown(void)
Definition: init.cc:209
cb
OPENSSL_EXPORT pem_password_cb * cb
Definition: pem.h:351
GRPC_STATUS_UNKNOWN
@ GRPC_STATUS_UNKNOWN
Definition: include/grpc/impl/codegen/status.h:40
gpr_cv_init
GPRAPI void gpr_cv_init(gpr_cv *cv)
tsi_peer::property_count
size_t property_count
Definition: transport_security_interface.h:240
SERVER_NEXT
@ SERVER_NEXT
Definition: alts_tsi_handshaker_test.cc:89
ALTS_TSI_HANDSHAKER_TEST_SECURITY_LEVEL
#define ALTS_TSI_HANDSHAKER_TEST_SECURITY_LEVEL
Definition: alts_tsi_handshaker_test.cc:43
transport_security_grpc.h
grpc_slice_ref
GPRAPI grpc_slice grpc_slice_ref(grpc_slice s)
Definition: slice_api.cc:27


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:41