Skip to content

Commit

Permalink
Updating blackbox tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
richiware committed Mar 30, 2017
1 parent d0133e0 commit 9675c75
Show file tree
Hide file tree
Showing 8 changed files with 285 additions and 362 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ endif()
# Testing
###############################################################################
if(EPROSIMA_BUILD_TESTS AND NOT EPROSIMA_INSTALLER AND NOT EPROSIMA_INSTALLER_MINION)
file(TO_CMAKE_PATH "${PROJECT_SOURCE_DIR}/valgrind.supp" MEMORYCHECK_SUPPRESSIONS_FILE)
enable_testing()
include(CTest)
add_subdirectory(test)
Expand Down
26 changes: 22 additions & 4 deletions src/cpp/rtps/security/SecurityManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,9 @@ bool SecurityManager::on_process_handshake(const GUID_t& remote_participant_key,
{
SharedSecretHandle* shared_secret_handle = authentication_plugin_->get_shared_secret(
*remote_participant_info->handshake_handle_, exception);
participant_authorized(remote_participant_info, shared_secret_handle, participant_data);
if(!participant_authorized(remote_participant_info, shared_secret_handle, participant_data))
authentication_plugin_->return_sharedsecret_handle(shared_secret_handle, exception);

}

if(ret == VALIDATION_PENDING_HANDSHAKE_MESSAGE)
Expand Down Expand Up @@ -2381,7 +2383,7 @@ bool SecurityManager::decode_serialized_payload(const SerializedPayload_t& secur
return false;
}

void SecurityManager::participant_authorized(const DiscoveredParticipantInfo::AuthUniquePtr& remote_participant_info,
bool SecurityManager::participant_authorized(const DiscoveredParticipantInfo::AuthUniquePtr& remote_participant_info,
SharedSecretHandle* shared_secret_handle, ParticipantProxyData* participant_data)
{
logInfo(SECURITY, "Authorized participant " << participant_data->m_guid);
Expand All @@ -2395,7 +2397,7 @@ void SecurityManager::participant_authorized(const DiscoveredParticipantInfo::Au
if(shared_secret_handle == nullptr)
{
logError(SECURITY, "Not shared secret for participant " << participant_data->m_guid);
return;
return false;
}

SecurityException exception;
Expand Down Expand Up @@ -2464,13 +2466,27 @@ void SecurityManager::participant_authorized(const DiscoveredParticipantInfo::Au
else
{
crypto_plugin_->cryptokeyfactory()->unregister_participant(participant_crypto_handle, exception);
logError(SECURITY, "Cannot find remote participant " << participant_data->m_guid);
return false;
}
}
else
{
logError(SECURITY, "Cannot register remote participant in crypto plugin ("
<< participant_data->m_guid << ")");
return;
return false;
}
}
else
{
std::unique_lock<std::mutex> lock(mutex_);

// Store shared_secret.
auto dp_it = discovered_participants_.find(participant_data->m_guid);

if(dp_it != discovered_participants_.end())
{
dp_it->second.set_shared_secret(shared_secret_handle);
}
}

Expand All @@ -2496,6 +2512,8 @@ void SecurityManager::participant_authorized(const DiscoveredParticipantInfo::Au
participant_->pdpsimple()->getEDP()->pairingLaterWriterProxy(remote_writer.second, *participant_data,
remote_writer.first);
}

return true;
}

uint32_t SecurityManager::calculate_extra_size_for_rtps_message()
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/rtps/security/SecurityManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ class SecurityManager
const GUID_t& destination_endpoint_key, const GUID_t& source_endpoint_key,
ParticipantCryptoTokenSeq& crypto_tokens);

void participant_authorized(const DiscoveredParticipantInfo::AuthUniquePtr& remote_participant_info,
bool participant_authorized(const DiscoveredParticipantInfo::AuthUniquePtr& remote_participant_info,
SharedSecretHandle* shared_secret_handle, ParticipantProxyData* data);

RTPSParticipantImpl* participant_;
Expand Down
1 change: 0 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.


add_subdirectory(blackbox)
add_subdirectory(communication)
if(NOT ((MSVC OR MSVC_IDE)))
Expand Down
Loading

0 comments on commit 9675c75

Please sign in to comment.