Ver código fonte

starting to update upb map integration

Danny Reidenbach 5 anos atrás
pai
commit
54b1333ab8

+ 25 - 21
src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc

@@ -309,14 +309,6 @@ tsi_result alts_tsi_handshaker_result_create(grpc_gcp_HandshakerResp* resp,
   }
   }
 
 
 
 
-  const grpc_gcp_Identity* cpeer_identity =
-      grpc_gcp_HandshakerResult_peer_identity(hresult);
-  if (cpeer_identity == nullptr) {
-    gpr_log(GPR_ERROR, "Invalid peer identity");
-    return TSI_FAILED_PRECONDITION;
-  }
-  // client next side add teh map key value
-  // let ashitha know what the issue was
 
 
 
 
 
 
@@ -356,25 +348,37 @@ tsi_result alts_tsi_handshaker_result_create(grpc_gcp_HandshakerResp* resp,
       context, const_cast<grpc_gcp_RpcProtocolVersions*>(peer_rpc_version));
       context, const_cast<grpc_gcp_RpcProtocolVersions*>(peer_rpc_version));
 
 
 
 
-  grpc_gcp_HandshakerResult* ncresult = grpc_gcp_HandshakerResp_mutable_result(resp, context_arena.ptr());
-  grpc_gcp_Identity* peer_identity = grpc_gcp_HandshakerResult_mutable_peer_identity(ncresult, context_arena.ptr());
+  grpc_gcp_HandshakerResult* ncresult = const_cast<grpc_gcp_HandshakerResult*>(hresult);
+  grpc_gcp_Identity* peer_identity = const_cast<grpc_gcp_Identity*>(identity);
   if(peer_identity == nullptr ) { //|| *peer_attributes_counter == nullptr) {
   if(peer_identity == nullptr ) { //|| *peer_attributes_counter == nullptr) {
     gpr_log(GPR_ERROR, "Null Peer Identity.");
     gpr_log(GPR_ERROR, "Null Peer Identity.");
     return TSI_FAILED_PRECONDITION;
     return TSI_FAILED_PRECONDITION;
   }
   }
+  
+  size_t iter;
+  grpc_gcp_Identity_AttributesEntry* peer_attributes_entry = grpc_gcp_Identity_attributes_nextmutable(peer_identity, &iter);
+
+   while ( peer_attributes_entry != nullptr) {
+    upb_strview key = grpc_gcp_Identity_AttributesEntry_key(const_cast<grpc_gcp_AltsContext_PeerAttributesEntry*>(peer_attributes_entry));
+    upb_strview val = grpc_gcp_Identity_AttributesEntry_value(const_cast<grpc_gcp_AltsContext_PeerAttributesEntry*>(peer_attributes_entry));
+    grpc_gcp_AltsContext_peer_attributes_set(context, key, val, context_arena.ptr());
+    peer_attributes_entry = grpc_gcp_Identity_attributes_nextmutable(peer_identity, &iter);
+  }
+ 
+
+
   // need to searilze before storing
   // need to searilze before storing
 
 
-  size_t sample = 2048; // removing this line removes errors messages e0612
-  size_t* lenz = &sample;
-  grpc_gcp_Identity_AttributesEntry** peer_attributes = grpc_gcp_Identity_mutable_attributes(peer_identity, lenz); // need size_t *len)
-  // where do these labeled functions come from --> upb genreated files
-  // grpc_gcp_Identity_AttributesEntry** peer_attributes_counter = peer_attributes;
-  if(peer_attributes == nullptr ) { //|| *peer_attributes_counter == nullptr) {
-    gpr_log(GPR_ERROR, "Null PEER ATTRIBUTES.");
-    // GPR_ASSERT(0);
-    return TSI_FAILED_PRECONDITION; //This is triggering
-  }
-  gpr_log(GPR_ERROR, "NON NULL PEER ATTRIBUTES");
+
+  // grpc_gcp_Identity_AttributesEntry** peer_attributes = grpc_gcp_Identity_mutable_attributes(peer_identity, lenz); // need size_t *len)
+  // // where do these labeled functions come from --> upb genreated files
+  // // grpc_gcp_Identity_AttributesEntry** peer_attributes_counter = peer_attributes;
+  // if(peer_attributes == nullptr ) { //|| *peer_attributes_counter == nullptr) {
+  //   gpr_log(GPR_ERROR, "Null PEER ATTRIBUTES.");
+  //   // GPR_ASSERT(0);
+  //   return TSI_FAILED_PRECONDITION; //This is triggering
+  // }
+  // gpr_log(GPR_ERROR, "NON NULL PEER ATTRIBUTES");
   // // while(*peer_attributes_counter != nullptr) {//map<string, string>::iterator it = peer_attributes.begin(); it != peer_attributes.end(); it++ ) {
   // // while(*peer_attributes_counter != nullptr) {//map<string, string>::iterator it = peer_attributes.begin(); it != peer_attributes.end(); it++ ) {
   // //   grpc_gcp_AltsContext_PeerAttributesEntry* peer_entry = grpc_gcp_AltsContext_add_peer_attributes(context, context_arena.ptr());
   // //   grpc_gcp_AltsContext_PeerAttributesEntry* peer_entry = grpc_gcp_AltsContext_add_peer_attributes(context, context_arena.ptr());
   // //   upb_strview key = grpc_gcp_Identity_AttributesEntry_key(*peer_attributes_counter); USE CONST_CAST
   // //   upb_strview key = grpc_gcp_Identity_AttributesEntry_key(*peer_attributes_counter); USE CONST_CAST

+ 8 - 7
test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc

@@ -159,9 +159,10 @@ static grpc_byte_buffer* generate_handshaker_response(
       gpr_log(GPR_ERROR, "Setting Peer Identity in generate handshaker response client next");
       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
        // doggo this set of code gets it to not fail once but creates the same error later on
-      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));
+      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");
       gpr_log(GPR_ERROR, "DEFINED PEER ATTRIBUTES ENTRY AND VALUES");
 
 
 
 
@@ -202,10 +203,10 @@ static grpc_byte_buffer* generate_handshaker_response(
           grpc_gcp_HandshakerResult_mutable_peer_identity(result, arena.ptr());
           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
         // doggo this set of code gets it to not fail once but creates the same error later on
-      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");
+      // 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_set_service_account(
       grpc_gcp_Identity_set_service_account(