From 4ad3823b1520390beb0b5d9f24a3a08302b72428 Mon Sep 17 00:00:00 2001 From: heck Date: Sun, 11 Jul 2021 01:42:43 +0200 Subject: [PATCH] Test: PityTest - PityNode add class TestIdent --- test/pitytest11/src/PityNode.cc | 33 ++++++++++++++++++++++++++++++--- test/pitytest11/src/PityNode.hh | 19 +++++++++++++++++++ 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/test/pitytest11/src/PityNode.cc b/test/pitytest11/src/PityNode.cc index 62dfb2b..3fa8ee1 100644 --- a/test/pitytest11/src/PityNode.cc +++ b/test/pitytest11/src/PityNode.cc @@ -4,14 +4,41 @@ namespace pEp { namespace PityTest11 { + TestIdent::TestIdent(const std::string& addr) : + addr{ addr }, did_rx_encrypted{ false }, did_tx_encrypted{ false } + { + ident = Test::Utils::createCptIdent(addr); + } + + TestIdent::TestIdent(const TestIdent& rhs) + { + did_rx_encrypted = rhs.did_rx_encrypted; + did_tx_encrypted = rhs.did_tx_encrypted; + addr = rhs.addr; + ident = Test::Utils::dup(rhs.ident.get()); + } + + bool TestIdent::tofu_done() const + { + return did_tx_encrypted && did_rx_encrypted; + } + + + // --------------------------------------------------------------------------------- + bool PityNode::debug_log_enabled = false; PityNode::PityNode(int nodeNr) : _node_nr{ nodeNr } { logger_debug.set_instancename(getName()); - std::stringstream ss{}; + std::stringstream ss; ss << this; pEpLogClass(std::string("called with: " + std::to_string(_node_nr) + "AT: " + ss.str())); + ident = std::make_shared(TestIdent(getName())); + } + + TestIdent& PityNode::getIdent() { + return *ident.get(); } int PityNode::getNr() const @@ -21,14 +48,14 @@ namespace pEp { std::string PityNode::getName() const { - std::string ret{}; + std::string ret; ret += "node_" + std::to_string(_node_nr) + "@peptest.org"; return ret; } std::string PityNode::to_string() const { - std::string ret{}; + std::string ret; ret += "name: " + getName(); return ret; } diff --git a/test/pitytest11/src/PityNode.hh b/test/pitytest11/src/PityNode.hh index 1d099fb..a4a71ea 100644 --- a/test/pitytest11/src/PityNode.hh +++ b/test/pitytest11/src/PityNode.hh @@ -5,9 +5,26 @@ #define PITYTEST_PITYNODE_HH #include "../../../src/pEpLog.hh" +#include "../../framework/utils.hh" namespace pEp { namespace PityTest11 { + class TestIdent { + public: + TestIdent() = delete; + explicit TestIdent(const std::string& addr); + TestIdent(const TestIdent& rhs); + bool tofu_done() const; + + std::string addr; + pEp::Test::Utils::pEpIdent ident{}; + + // state + bool did_tx_encrypted; + bool did_rx_encrypted; + }; + + class PityNode { public: // Constructors @@ -15,6 +32,7 @@ namespace pEp { explicit PityNode(int nodeNr); // Getters + TestIdent& getIdent(); int getNr() const; std::string getName() const; std::string to_string() const; @@ -26,6 +44,7 @@ namespace pEp { private: //fields const int _node_nr; + std::shared_ptr ident; //internal logging Adapter::pEpLog::pEpLogger& m4gic_logger_n4me = logger_debug;