diff --git a/producer/api/cpp/src/request_handler_tcp.cpp b/producer/api/cpp/src/request_handler_tcp.cpp index 157c1212e6b24089d7ed8ace19d7de3f2fc26da5..e6f105d0150499ad74f665b16610710c97153df0 100644 --- a/producer/api/cpp/src/request_handler_tcp.cpp +++ b/producer/api/cpp/src/request_handler_tcp.cpp @@ -13,12 +13,18 @@ RequestHandlerTcp::RequestHandlerTcp(ReceiverDiscoveryService* discovery_service } Error RequestHandlerTcp::Authorize(const std::string& source_credentials) { - GenericRequestHeader header{kOpcodeAuthorize, 0, 0, 0, source_credentials.c_str()}; + GenericRequestHeader header{kOpcodeAuthorize, 0, 0, source_credentials.size(), ""}; Error err; io__->Send(sd_, &header, sizeof(header), &err); if(err) { return err; } + + io__->Send(sd_, (void*) source_credentials.c_str(), (size_t) header.meta_size, &err); + if (err) { + return err; + } + return ReceiveResponse(header, nullptr); } diff --git a/producer/api/cpp/unittests/test_request_handler_tcp.cpp b/producer/api/cpp/unittests/test_request_handler_tcp.cpp index 25a88248bb4b2b3ed107704870670260d9a1699e..536aee478111030daf6181ddf82d475b5b8a877e 100644 --- a/producer/api/cpp/unittests/test_request_handler_tcp.cpp +++ b/producer/api/cpp/unittests/test_request_handler_tcp.cpp @@ -195,7 +195,7 @@ void RequestHandlerTcpTests::ExpectFailAuthorize(bool only_once) { int i = 0; for (auto expected_sd : expected_sds) { EXPECT_CALL(mock_io, - Send_t(expected_sd, M_CheckSendRequest(asapo::kOpcodeAuthorize, 0, 0, expected_beamtime_id, + Send_t(expected_sd, M_CheckSendRequest(asapo::kOpcodeAuthorize, 0, 0, "", ""), sizeof(asapo::GenericRequestHeader), _)) .WillOnce( @@ -203,6 +203,13 @@ void RequestHandlerTcpTests::ExpectFailAuthorize(bool only_once) { testing::SetArgPointee<3>(nullptr), Return(sizeof(asapo::GenericRequestHeader)) )); + EXPECT_CALL(mock_io, + Send_t(expected_sd, _,strlen(expected_beamtime_id), _)) + .WillOnce( + DoAll( + testing::SetArgPointee<3>(nullptr), + Return(strlen(expected_beamtime_id)) + )); EXPECT_CALL(mock_io, Receive_t(expected_sd, _, sizeof(asapo::SendResponse), _)) .InSequence(seq_receive[i]) @@ -236,7 +243,7 @@ void RequestHandlerTcpTests::ExpectOKAuthorize(bool only_once) { int i = 0; for (auto expected_sd : expected_sds) { EXPECT_CALL(mock_io, - Send_t(expected_sd, M_CheckSendRequest(asapo::kOpcodeAuthorize, 0, 0, expected_beamtime_id, + Send_t(expected_sd, M_CheckSendRequest(asapo::kOpcodeAuthorize, 0, 0, "", ""), sizeof(asapo::GenericRequestHeader), _)) .WillOnce( @@ -244,6 +251,13 @@ void RequestHandlerTcpTests::ExpectOKAuthorize(bool only_once) { testing::SetArgPointee<3>(nullptr), Return(sizeof(asapo::GenericRequestHeader)) )); + EXPECT_CALL(mock_io, + Send_t(expected_sd, _,strlen(expected_beamtime_id), _)) + .WillOnce( + DoAll( + testing::SetArgPointee<3>(nullptr), + Return(strlen(expected_beamtime_id)) + )); EXPECT_CALL(mock_io, Receive_t(expected_sd, _, sizeof(asapo::SendResponse), _)) .InSequence(seq_receive[i])