|
|
|
|
@ -13,7 +13,9 @@
|
|
|
|
|
#include "fne/FNETestHooks.h"
|
|
|
|
|
#include "fne/HostFNE.h"
|
|
|
|
|
#include "common/lookups/AffiliationLookup.h"
|
|
|
|
|
#include "common/lookups/TalkgroupRulesLookup.h"
|
|
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
#include <vector>
|
|
|
|
|
@ -33,27 +35,151 @@ public:
|
|
|
|
|
FNEHarness() :
|
|
|
|
|
configFile("fne-test.yml"),
|
|
|
|
|
host(configFile),
|
|
|
|
|
talkgroups("", 0U, true, false),
|
|
|
|
|
traffic(&host, "127.0.0.1", 62031U, 999999U, "test-password", "test-fne",
|
|
|
|
|
false, false, false, false, true, true, true, true, true,
|
|
|
|
|
0U, false, true, true, 5U, 10U, 2U),
|
|
|
|
|
metadata(&host, &traffic, "127.0.0.1", 62032U, 2U)
|
|
|
|
|
{
|
|
|
|
|
/* stub */
|
|
|
|
|
traffic.setLookups(nullptr, nullptr, &talkgroups, nullptr, nullptr, nullptr);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* @brief Finalizes a instance of the FNEHarness class.
|
|
|
|
|
*/
|
|
|
|
|
~FNEHarness()
|
|
|
|
|
{
|
|
|
|
|
FNETestHooks::clearPeerWriteCapture(traffic);
|
|
|
|
|
FNETestHooks::clearPeers(traffic);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string configFile;
|
|
|
|
|
HostFNE host;
|
|
|
|
|
lookups::TalkgroupRulesLookup talkgroups;
|
|
|
|
|
network::TrafficNetwork traffic;
|
|
|
|
|
network::MetadataNetwork metadata;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TEST_CASE("FNE parrot playback honors affiliated-required talkgroups", "[fne][parrot][affiliations]")
|
|
|
|
|
{
|
|
|
|
|
constexpr uint32_t PARROT_TG = 3100U;
|
|
|
|
|
constexpr uint32_t OTHER_TG = 3200U;
|
|
|
|
|
constexpr uint32_t AFFILIATED_PEER = 1001U;
|
|
|
|
|
constexpr uint32_t UNAFFILIATED_PEER = 1002U;
|
|
|
|
|
constexpr uint32_t OTHER_TG_PEER = 1003U;
|
|
|
|
|
|
|
|
|
|
FNEHarness harness;
|
|
|
|
|
harness.talkgroups.addEntry(PARROT_TG, 0U, true, true);
|
|
|
|
|
|
|
|
|
|
FNETestHooks::addPeer(harness.traffic, AFFILIATED_PEER, network::NET_STAT_RUNNING, true);
|
|
|
|
|
FNETestHooks::addPeer(harness.traffic, UNAFFILIATED_PEER, network::NET_STAT_RUNNING, true);
|
|
|
|
|
FNETestHooks::addPeer(harness.traffic, OTHER_TG_PEER, network::NET_STAT_RUNNING, true);
|
|
|
|
|
FNETestHooks::addGroupAffiliation(harness.traffic, AFFILIATED_PEER, 2001U, PARROT_TG);
|
|
|
|
|
FNETestHooks::addGroupAffiliation(harness.traffic, OTHER_TG_PEER, 2003U, OTHER_TG);
|
|
|
|
|
|
|
|
|
|
const std::vector<FNETestHooks::ParrotProtocol> protocols = {
|
|
|
|
|
FNETestHooks::ParrotProtocol::DMR,
|
|
|
|
|
FNETestHooks::ParrotProtocol::P25,
|
|
|
|
|
FNETestHooks::ParrotProtocol::P25P2,
|
|
|
|
|
FNETestHooks::ParrotProtocol::NXDN,
|
|
|
|
|
FNETestHooks::ParrotProtocol::ANALOG
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for (FNETestHooks::ParrotProtocol protocol : protocols) {
|
|
|
|
|
CAPTURE(static_cast<int>(protocol));
|
|
|
|
|
std::vector<uint32_t> destinations;
|
|
|
|
|
FNETestHooks::capturePeerWrites(harness.traffic, destinations);
|
|
|
|
|
|
|
|
|
|
FNETestHooks::playbackParrotFrame(harness.traffic, protocol,
|
|
|
|
|
UNAFFILIATED_PEER, 2002U, PARROT_TG);
|
|
|
|
|
|
|
|
|
|
REQUIRE(destinations == std::vector<uint32_t>{ AFFILIATED_PEER });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_CASE("FNE parrot playback permits always-send and console peers", "[fne][parrot][routing]")
|
|
|
|
|
{
|
|
|
|
|
constexpr uint32_t PARROT_TG = 3100U;
|
|
|
|
|
constexpr uint32_t ALWAYS_SEND_PEER = 1001U;
|
|
|
|
|
constexpr uint32_t CONSOLE_PEER = 1002U;
|
|
|
|
|
constexpr uint32_t UNAFFILIATED_PEER = 1003U;
|
|
|
|
|
|
|
|
|
|
FNEHarness harness;
|
|
|
|
|
harness.talkgroups.addEntry(PARROT_TG, 0U, true, true);
|
|
|
|
|
lookups::TalkgroupRuleGroupVoice talkgroup = harness.talkgroups.find(PARROT_TG);
|
|
|
|
|
lookups::TalkgroupRuleConfig config = talkgroup.config();
|
|
|
|
|
config.alwaysSend({ ALWAYS_SEND_PEER });
|
|
|
|
|
talkgroup.config(config);
|
|
|
|
|
harness.talkgroups.addEntry(talkgroup);
|
|
|
|
|
|
|
|
|
|
FNETestHooks::addPeer(harness.traffic, ALWAYS_SEND_PEER, network::NET_STAT_RUNNING, true);
|
|
|
|
|
network::FNEPeerConnection& console = FNETestHooks::addPeer(
|
|
|
|
|
harness.traffic, CONSOLE_PEER, network::NET_STAT_RUNNING, true);
|
|
|
|
|
console.peerClass(network::PEER_CONN_CLASS_CONSOLE);
|
|
|
|
|
FNETestHooks::addPeer(harness.traffic, UNAFFILIATED_PEER, network::NET_STAT_RUNNING, true);
|
|
|
|
|
|
|
|
|
|
const std::vector<FNETestHooks::ParrotProtocol> protocols = {
|
|
|
|
|
FNETestHooks::ParrotProtocol::DMR,
|
|
|
|
|
FNETestHooks::ParrotProtocol::P25,
|
|
|
|
|
FNETestHooks::ParrotProtocol::P25P2,
|
|
|
|
|
FNETestHooks::ParrotProtocol::NXDN,
|
|
|
|
|
FNETestHooks::ParrotProtocol::ANALOG
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for (FNETestHooks::ParrotProtocol protocol : protocols) {
|
|
|
|
|
CAPTURE(static_cast<int>(protocol));
|
|
|
|
|
std::vector<uint32_t> destinations;
|
|
|
|
|
FNETestHooks::capturePeerWrites(harness.traffic, destinations);
|
|
|
|
|
|
|
|
|
|
FNETestHooks::playbackParrotFrame(harness.traffic, protocol,
|
|
|
|
|
UNAFFILIATED_PEER, 2003U, PARROT_TG);
|
|
|
|
|
|
|
|
|
|
std::sort(destinations.begin(), destinations.end());
|
|
|
|
|
REQUIRE(destinations == std::vector<uint32_t>{ ALWAYS_SEND_PEER, CONSOLE_PEER });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_CASE("FNE parrot playback blocks excluded peers", "[fne][parrot][routing]")
|
|
|
|
|
{
|
|
|
|
|
constexpr uint32_t PARROT_TG = 3100U;
|
|
|
|
|
constexpr uint32_t PERMITTED_PEER = 1001U;
|
|
|
|
|
constexpr uint32_t EXCLUDED_PEER = 1002U;
|
|
|
|
|
|
|
|
|
|
FNEHarness harness;
|
|
|
|
|
harness.talkgroups.addEntry(PARROT_TG, 0U, true, true);
|
|
|
|
|
lookups::TalkgroupRuleGroupVoice talkgroup = harness.talkgroups.find(PARROT_TG);
|
|
|
|
|
lookups::TalkgroupRuleConfig config = talkgroup.config();
|
|
|
|
|
config.exclusion({ EXCLUDED_PEER });
|
|
|
|
|
config.alwaysSend({ EXCLUDED_PEER });
|
|
|
|
|
talkgroup.config(config);
|
|
|
|
|
harness.talkgroups.addEntry(talkgroup);
|
|
|
|
|
|
|
|
|
|
FNETestHooks::addPeer(harness.traffic, PERMITTED_PEER, network::NET_STAT_RUNNING, true);
|
|
|
|
|
network::FNEPeerConnection& excluded = FNETestHooks::addPeer(
|
|
|
|
|
harness.traffic, EXCLUDED_PEER, network::NET_STAT_RUNNING, true);
|
|
|
|
|
excluded.peerClass(network::PEER_CONN_CLASS_CONSOLE);
|
|
|
|
|
FNETestHooks::addGroupAffiliation(harness.traffic, PERMITTED_PEER, 2001U, PARROT_TG);
|
|
|
|
|
FNETestHooks::addGroupAffiliation(harness.traffic, EXCLUDED_PEER, 2002U, PARROT_TG);
|
|
|
|
|
|
|
|
|
|
const std::vector<FNETestHooks::ParrotProtocol> protocols = {
|
|
|
|
|
FNETestHooks::ParrotProtocol::DMR,
|
|
|
|
|
FNETestHooks::ParrotProtocol::P25,
|
|
|
|
|
FNETestHooks::ParrotProtocol::P25P2,
|
|
|
|
|
FNETestHooks::ParrotProtocol::NXDN,
|
|
|
|
|
FNETestHooks::ParrotProtocol::ANALOG
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for (FNETestHooks::ParrotProtocol protocol : protocols) {
|
|
|
|
|
CAPTURE(static_cast<int>(protocol));
|
|
|
|
|
std::vector<uint32_t> destinations;
|
|
|
|
|
FNETestHooks::capturePeerWrites(harness.traffic, destinations);
|
|
|
|
|
|
|
|
|
|
FNETestHooks::playbackParrotFrame(harness.traffic, protocol,
|
|
|
|
|
PERMITTED_PEER, 2001U, PARROT_TG);
|
|
|
|
|
|
|
|
|
|
REQUIRE(destinations == std::vector<uint32_t>{ PERMITTED_PEER });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_CASE("Affiliation snapshots replace prior state", "[fne][affiliations]")
|
|
|
|
|
{
|
|
|
|
|
lookups::AffiliationLookup affiliations("test-affiliations", nullptr, false);
|
|
|
|
|
|