|
|
@@ -126,31 +126,24 @@ static void wait(notification* n) {
|
|
|
*/
|
|
|
static grpc_byte_buffer* generate_handshaker_response(
|
|
|
alts_handshaker_response_type type) {
|
|
|
- gpr_log(GPR_ERROR, "start of generate handshaker response");
|
|
|
upb::Arena arena;
|
|
|
grpc_gcp_HandshakerResult* result;
|
|
|
grpc_gcp_Identity* peer_identity;
|
|
|
- grpc_gcp_Identity_AttributesEntry* test_peer_attributes_entry;
|
|
|
grpc_gcp_HandshakerResp* resp = grpc_gcp_HandshakerResp_new(arena.ptr());
|
|
|
grpc_gcp_HandshakerStatus* status =
|
|
|
grpc_gcp_HandshakerResp_mutable_status(resp, arena.ptr());
|
|
|
grpc_gcp_HandshakerStatus_set_code(status, 0);
|
|
|
grpc_gcp_Identity* local_identity;
|
|
|
|
|
|
- upb_strview val9;
|
|
|
switch (type) {
|
|
|
case INVALID:
|
|
|
break;
|
|
|
case CLIENT_START:
|
|
|
- gpr_log(GPR_ERROR, "start of generate handshaker response client start");
|
|
|
case SERVER_START:
|
|
|
- gpr_log(GPR_ERROR, "start of generate handshaker response server start");
|
|
|
grpc_gcp_HandshakerResp_set_out_frames(
|
|
|
resp, upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME));
|
|
|
break;
|
|
|
case CLIENT_NEXT:
|
|
|
- // doggo
|
|
|
- gpr_log(GPR_ERROR, "start of generate handshaker response client next");
|
|
|
grpc_gcp_HandshakerResp_set_out_frames(
|
|
|
resp, upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME));
|
|
|
grpc_gcp_HandshakerResp_set_bytes_consumed(
|
|
|
@@ -158,33 +151,14 @@ static grpc_byte_buffer* generate_handshaker_response(
|
|
|
result = grpc_gcp_HandshakerResp_mutable_result(resp, arena.ptr());
|
|
|
peer_identity =
|
|
|
grpc_gcp_HandshakerResult_mutable_peer_identity(result, arena.ptr());
|
|
|
- gpr_log(GPR_ERROR, "Setting Peer Identity in generate handshaker response client next");
|
|
|
-
|
|
|
- // doggo this set of code gets it to not fail once but creates the same error later on
|
|
|
- grpc_gcp_Identity_attributes_set(peer_identity, upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_KEY), upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_VALUE), arena.ptr());
|
|
|
- // test_peer_attributes_entry = grpc_gcp_Identity_add_attributes(peer_identity, arena.ptr());
|
|
|
- // grpc_gcp_Identity_AttributesEntry_set_key(test_peer_attributes_entry, upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_KEY));
|
|
|
- // grpc_gcp_Identity_AttributesEntry_set_value(test_peer_attributes_entry, upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_VALUE));
|
|
|
- gpr_log(GPR_ERROR, "DEFINED PEER ATTRIBUTES ENTRY AND VALUES");
|
|
|
- if ( ! grpc_gcp_Identity_has_attributes(const_cast<grpc_gcp_Identity*>(peer_identity))) {
|
|
|
- gpr_log(GPR_ERROR, "XOXO Failed to DEFINE PEER ATTRIBUTES ENTRY AND VALUES");
|
|
|
- }
|
|
|
-
|
|
|
- val9 = upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_VALUE);
|
|
|
- if (! grpc_gcp_Identity_attributes_get(const_cast<grpc_gcp_Identity*>(peer_identity), upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_KEY), &val9)){
|
|
|
- gpr_log(GPR_ERROR, "XOXOXO Getting is Failing");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ grpc_gcp_Identity_attributes_set(peer_identity, upb_strview_makez(
|
|
|
+ ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_KEY), upb_strview_makez(
|
|
|
+ ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_VALUE), arena.ptr());
|
|
|
grpc_gcp_Identity_set_service_account(
|
|
|
peer_identity,
|
|
|
upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_IDENTITY));
|
|
|
grpc_gcp_HandshakerResult_set_key_data(
|
|
|
result, upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_KEY_DATA));
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
GPR_ASSERT(grpc_gcp_handshaker_resp_set_peer_rpc_versions(
|
|
|
resp, arena.ptr(), ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MAJOR,
|
|
|
ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MINOR,
|
|
|
@@ -202,31 +176,16 @@ static grpc_byte_buffer* generate_handshaker_response(
|
|
|
result, upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_RECORD_PROTOCOL));
|
|
|
grpc_gcp_HandshakerResult_set_max_frame_size(
|
|
|
result, ALTS_TSI_HANDSHAKER_TEST_MAX_FRAME_SIZE);
|
|
|
-
|
|
|
- // upb_strview val = upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_VALUE);
|
|
|
- // gpr_log(GPR_ERROR, "start of generate handshaker response finished setting client info");
|
|
|
- // bool getTest = grpc_gcp_Identity_attributes_get(const_cast<grpc_gcp_Identity*>(peer_identity), upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_KEY), &val);
|
|
|
- // if (! getTest){
|
|
|
- // gpr_log(GPR_ERROR, "XOXOXO Getting is Failing");
|
|
|
- // }
|
|
|
-
|
|
|
break;
|
|
|
case SERVER_NEXT:
|
|
|
- gpr_log(GPR_ERROR, "start of generate handshaker response server next");
|
|
|
grpc_gcp_HandshakerResp_set_bytes_consumed(
|
|
|
resp, strlen(ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME));
|
|
|
result = grpc_gcp_HandshakerResp_mutable_result(resp, arena.ptr());
|
|
|
peer_identity =
|
|
|
grpc_gcp_HandshakerResult_mutable_peer_identity(result, arena.ptr());
|
|
|
-
|
|
|
- // doggo this set of code gets it to not fail once but creates the same error later on
|
|
|
- grpc_gcp_Identity_attributes_set(peer_identity, upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_KEY), upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_VALUE), arena.ptr());
|
|
|
- // test_peer_attributes_entry = grpc_gcp_Identity_add_attributes(peer_identity, arena.ptr());
|
|
|
- // grpc_gcp_Identity_AttributesEntry_set_key(test_peer_attributes_entry, upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_KEY));
|
|
|
- // grpc_gcp_Identity_AttributesEntry_set_value(test_peer_attributes_entry, upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_VALUE));
|
|
|
- // gpr_log(GPR_ERROR, "DEFINED PEER ATTRIBUTES ENTRY AND VALUES");
|
|
|
-
|
|
|
-
|
|
|
+ grpc_gcp_Identity_attributes_set(peer_identity, upb_strview_makez(
|
|
|
+ ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_KEY), upb_strview_makez(
|
|
|
+ ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_VALUE), arena.ptr());
|
|
|
grpc_gcp_Identity_set_service_account(
|
|
|
peer_identity,
|
|
|
upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_IDENTITY));
|
|
|
@@ -329,12 +288,10 @@ static void on_server_start_success_cb(tsi_result status, void* user_data,
|
|
|
signal(&tsi_to_caller_notification);
|
|
|
}
|
|
|
|
|
|
-//doggo
|
|
|
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) {
|
|
|
- gpr_log(GPR_ERROR, "....... TESTING start of on_client_next_success_cb");
|
|
|
GPR_ASSERT(status == TSI_OK);
|
|
|
GPR_ASSERT(user_data == nullptr);
|
|
|
GPR_ASSERT(bytes_to_send_size == strlen(ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME));
|
|
|
@@ -362,7 +319,6 @@ static void on_client_next_success_cb(tsi_result status, void* user_data,
|
|
|
peer.properties[1].value.data,
|
|
|
peer.properties[1].value.length) == 0);
|
|
|
/* Validate alts context. */
|
|
|
- //doggo this is where to add the test
|
|
|
upb::Arena context_arena;
|
|
|
grpc_gcp_AltsContext* ctx = grpc_gcp_AltsContext_parse(
|
|
|
peer.properties[3].value.data, peer.properties[3].value.length,
|
|
|
@@ -381,24 +337,16 @@ static void on_client_next_success_cb(tsi_result status, void* user_data,
|
|
|
peer_account.size) == 0);
|
|
|
GPR_ASSERT(memcmp(ALTS_TSI_HANDSHAKER_TEST_LOCAL_IDENTITY, local_account.data,
|
|
|
local_account.size) == 0);
|
|
|
-
|
|
|
- // // if ( ! grpc_gcp_Identity_has_attributes(const_cast<grpc_gcp_Identity*>(peer_identity))) {
|
|
|
- // // gpr_log(GPR_ERROR, "XOXO Failed to get PEER IDENTITY ATTRIBUTES");
|
|
|
- // // }
|
|
|
- // if ( ! grpc_gcp_AltsContext_has_peer_attributes(const_cast<grpc_gcp_AltsContext*>(ctx))) {
|
|
|
- // gpr_log(GPR_ERROR, "XOXO Failed to get ALTS CONTEXT ATTRIBUTES");
|
|
|
- // }
|
|
|
- // size_t iter;
|
|
|
- // grpc_gcp_AltsContext_PeerAttributesEntry* peer_attributes_entry = grpc_gcp_AltsContext_peer_attributes_nextmutable(ctx, &iter);
|
|
|
- // GPR_ASSERT(peer_attributes_entry != nullptr);
|
|
|
- // while ( peer_attributes_entry != nullptr) {
|
|
|
- // upb_strview key = grpc_gcp_AltsContext_PeerAttributesEntry_key(const_cast<grpc_gcp_AltsContext_PeerAttributesEntry*>(peer_attributes_entry));
|
|
|
- // upb_strview val = grpc_gcp_AltsContext_PeerAttributesEntry_value(const_cast<grpc_gcp_AltsContext_PeerAttributesEntry*>(peer_attributes_entry));
|
|
|
- // GPR_ASSERT(upb_strview_eql(key, upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_KEY)));
|
|
|
- // GPR_ASSERT(upb_strview_eql(val, upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_VALUE)));
|
|
|
- // peer_attributes_entry = grpc_gcp_AltsContext_peer_attributes_nextmutable(ctx, &iter);
|
|
|
- // }
|
|
|
-
|
|
|
+ size_t iter = UPB_MAP_BEGIN;
|
|
|
+ grpc_gcp_AltsContext_PeerAttributesEntry* peer_attributes_entry = grpc_gcp_AltsContext_peer_attributes_nextmutable(ctx, &iter);
|
|
|
+ GPR_ASSERT(peer_attributes_entry != nullptr);
|
|
|
+ while ( peer_attributes_entry != nullptr) {
|
|
|
+ upb_strview key = grpc_gcp_AltsContext_PeerAttributesEntry_key(const_cast<grpc_gcp_AltsContext_PeerAttributesEntry*>(peer_attributes_entry));
|
|
|
+ upb_strview val = grpc_gcp_AltsContext_PeerAttributesEntry_value(const_cast<grpc_gcp_AltsContext_PeerAttributesEntry*>(peer_attributes_entry));
|
|
|
+ GPR_ASSERT(upb_strview_eql(key, upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_KEY)));
|
|
|
+ GPR_ASSERT(upb_strview_eql(val, upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_VALUE)));
|
|
|
+ peer_attributes_entry = grpc_gcp_AltsContext_peer_attributes_nextmutable(ctx, &iter);
|
|
|
+ }
|
|
|
/* Validate security level. */
|
|
|
GPR_ASSERT(memcmp(ALTS_TSI_HANDSHAKER_TEST_SECURITY_LEVEL,
|
|
|
peer.properties[4].value.data,
|
|
|
@@ -422,7 +370,6 @@ static void on_client_next_success_cb(tsi_result status, void* user_data,
|
|
|
signal(&tsi_to_caller_notification);
|
|
|
}
|
|
|
|
|
|
-//doggo need to test here too
|
|
|
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,
|
|
|
@@ -475,16 +422,16 @@ static void on_server_next_success_cb(tsi_result status, void* user_data,
|
|
|
GPR_ASSERT(memcmp(ALTS_TSI_HANDSHAKER_TEST_LOCAL_IDENTITY, local_account.data,
|
|
|
local_account.size) == 0);
|
|
|
|
|
|
- // size_t iter;
|
|
|
- // grpc_gcp_AltsContext_PeerAttributesEntry* peer_attributes_entry = grpc_gcp_AltsContext_peer_attributes_nextmutable(ctx, &iter);
|
|
|
- // while ( peer_attributes_entry != nullptr) {
|
|
|
- // upb_strview key = grpc_gcp_AltsContext_PeerAttributesEntry_key(const_cast<grpc_gcp_AltsContext_PeerAttributesEntry*>(peer_attributes_entry));
|
|
|
- // upb_strview val = grpc_gcp_AltsContext_PeerAttributesEntry_value(const_cast<grpc_gcp_AltsContext_PeerAttributesEntry*>(peer_attributes_entry));
|
|
|
- // GPR_ASSERT(upb_strview_eql(key, upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_KEY)));
|
|
|
- // GPR_ASSERT(upb_strview_eql(val, upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_VALUE)));
|
|
|
- // peer_attributes_entry = grpc_gcp_AltsContext_peer_attributes_nextmutable(ctx, &iter);
|
|
|
- // }
|
|
|
-
|
|
|
+ size_t iter = UPB_MAP_BEGIN;
|
|
|
+ grpc_gcp_AltsContext_PeerAttributesEntry* peer_attributes_entry = grpc_gcp_AltsContext_peer_attributes_nextmutable(ctx, &iter);
|
|
|
+ GPR_ASSERT(peer_attributes_entry != nullptr);
|
|
|
+ while ( peer_attributes_entry != nullptr) {
|
|
|
+ upb_strview key = grpc_gcp_AltsContext_PeerAttributesEntry_key(const_cast<grpc_gcp_AltsContext_PeerAttributesEntry*>(peer_attributes_entry));
|
|
|
+ upb_strview val = grpc_gcp_AltsContext_PeerAttributesEntry_value(const_cast<grpc_gcp_AltsContext_PeerAttributesEntry*>(peer_attributes_entry));
|
|
|
+ GPR_ASSERT(upb_strview_eql(key, upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_KEY)));
|
|
|
+ GPR_ASSERT(upb_strview_eql(val, upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_VALUE)));
|
|
|
+ peer_attributes_entry = grpc_gcp_AltsContext_peer_attributes_nextmutable(ctx, &iter);
|
|
|
+ }
|
|
|
/* Check security level. */
|
|
|
GPR_ASSERT(memcmp(ALTS_TSI_HANDSHAKER_TEST_SECURITY_LEVEL,
|
|
|
peer.properties[4].value.data,
|
|
|
@@ -587,19 +534,15 @@ static alts_handshaker_client_vtable vtable = {mock_client_start,
|
|
|
mock_shutdown, mock_destruct};
|
|
|
|
|
|
static tsi_handshaker* create_test_handshaker(bool is_client) {
|
|
|
- gpr_log(GPR_ERROR, "create test handshaker");
|
|
|
tsi_handshaker* handshaker = nullptr;
|
|
|
grpc_alts_credentials_options* options =
|
|
|
grpc_alts_credentials_client_options_create();
|
|
|
- gpr_log(GPR_ERROR, "create test handhsaker CANNOT FIND: Where is grpc_alts_credentials_client_options_create");
|
|
|
alts_tsi_handshaker_create(options, "target_name",
|
|
|
ALTS_HANDSHAKER_SERVICE_URL_FOR_TESTING, is_client,
|
|
|
nullptr, &handshaker, 0);
|
|
|
alts_tsi_handshaker* alts_handshaker =
|
|
|
reinterpret_cast<alts_tsi_handshaker*>(handshaker);
|
|
|
- gpr_log(GPR_ERROR, "create test handshaker set v table. WHAT IS THIS VTABLE");
|
|
|
alts_tsi_handshaker_set_client_vtable_for_testing(alts_handshaker, &vtable);
|
|
|
- gpr_log(GPR_ERROR, "create tset handshaker destroy handshaker options");
|
|
|
grpc_alts_credentials_options_destroy(options);
|
|
|
return handshaker;
|
|
|
}
|
|
|
@@ -639,28 +582,23 @@ static void check_handshaker_next_success() {
|
|
|
* Create handshakers for which internal mock client is going to do
|
|
|
* correctness check.
|
|
|
*/
|
|
|
- gpr_log(GPR_ERROR, "start of check_handshaker_next_success");
|
|
|
tsi_handshaker* client_handshaker =
|
|
|
create_test_handshaker(true /* is_client */);
|
|
|
tsi_handshaker* server_handshaker =
|
|
|
create_test_handshaker(false /* is_client */);
|
|
|
/* Client start. */
|
|
|
- gpr_log(GPR_ERROR, "check handshaker next success client start");
|
|
|
GPR_ASSERT(tsi_handshaker_next(client_handshaker, nullptr, 0, nullptr,
|
|
|
nullptr, nullptr, on_client_start_success_cb,
|
|
|
nullptr) == TSI_ASYNC);
|
|
|
wait(&tsi_to_caller_notification);
|
|
|
/* Client next. */
|
|
|
- gpr_log(GPR_ERROR, "check handshaker next success client next");
|
|
|
GPR_ASSERT(tsi_handshaker_next(
|
|
|
client_handshaker,
|
|
|
(const unsigned char*)ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES,
|
|
|
strlen(ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES), nullptr, nullptr,
|
|
|
nullptr, on_client_next_success_cb, nullptr) == TSI_ASYNC);
|
|
|
- gpr_log(GPR_ERROR, "check handshaker next success client next pre wait");
|
|
|
wait(&tsi_to_caller_notification);
|
|
|
/* Server start. */
|
|
|
- gpr_log(GPR_ERROR, "check handshaker next success server start");
|
|
|
GPR_ASSERT(tsi_handshaker_next(server_handshaker, nullptr, 0, nullptr,
|
|
|
nullptr, nullptr, on_server_start_success_cb,
|
|
|
nullptr) == TSI_ASYNC);
|
|
|
@@ -944,12 +882,10 @@ static void check_handle_response_invalid_resp() {
|
|
|
}
|
|
|
|
|
|
static void check_handle_response_success(void* /*unused*/) {
|
|
|
- gpr_log(GPR_ERROR, "Start of check handle response success");
|
|
|
/* Client start. */
|
|
|
wait(&caller_to_tsi_notification);
|
|
|
alts_handshaker_client_handle_response(cb_event, true /* is_ok */);
|
|
|
/* Client next. */
|
|
|
- gpr_log(GPR_ERROR, "check handle response success client next");
|
|
|
wait(&caller_to_tsi_notification);
|
|
|
alts_handshaker_client_handle_response(cb_event, true /* is_ok */);
|
|
|
alts_handshaker_client_ref_for_testing(cb_event);
|
|
|
@@ -959,11 +895,9 @@ static void check_handle_response_success(void* /*unused*/) {
|
|
|
cb_event, GRPC_STATUS_OK, GRPC_ERROR_NONE);
|
|
|
}
|
|
|
/* Server start. */
|
|
|
- gpr_log(GPR_ERROR, "check handle response success server start");
|
|
|
wait(&caller_to_tsi_notification);
|
|
|
alts_handshaker_client_handle_response(cb_event, true /* is_ok */);
|
|
|
/* Server next. */
|
|
|
- gpr_log(GPR_ERROR, "check handle response success server next");
|
|
|
wait(&caller_to_tsi_notification);
|
|
|
alts_handshaker_client_handle_response(cb_event, true /* is_ok */);
|
|
|
alts_handshaker_client_ref_for_testing(cb_event);
|
|
|
@@ -1081,13 +1015,11 @@ void check_handshaker_next_fails_after_shutdown() {
|
|
|
|
|
|
void check_handshaker_success() {
|
|
|
/* Initialization. */
|
|
|
- gpr_log(GPR_ERROR, "Start of check handshaker success");
|
|
|
notification_init(&caller_to_tsi_notification);
|
|
|
notification_init(&tsi_to_caller_notification);
|
|
|
/* Tests. */
|
|
|
grpc_core::Thread thd("alts_tsi_handshaker_test",
|
|
|
&check_handle_response_success, nullptr);
|
|
|
- gpr_log(GPR_ERROR, "handshaker success thread");
|
|
|
thd.Start();
|
|
|
check_handshaker_next_success();
|
|
|
thd.Join();
|
|
|
@@ -1103,7 +1035,6 @@ int main(int argc, char** argv) {
|
|
|
grpc_alts_shared_resource_dedicated_init();
|
|
|
/* Tests. */
|
|
|
should_handshaker_client_api_succeed = true;
|
|
|
- gpr_log(GPR_ERROR, "Starting tests from main");
|
|
|
check_handshaker_success();
|
|
|
check_handshaker_next_invalid_input();
|
|
|
check_handshaker_next_fails_after_shutdown();
|