moved authgpg fake module to tests folder

fixed ficachetest and fimontest 

makefile update for serialiser for previous revision


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4321 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2011-06-22 21:44:40 +00:00
parent f3fbac7d77
commit f12d2c46bc
10 changed files with 117 additions and 57 deletions

View File

@ -40,13 +40,15 @@ void cleanupZombies(int numkill); // function to cleanup zombies under OSX.
//#define GPG_DEBUG 1
static AuthGPGimpl *instance_gpg = NULL;
static AuthGPG *instance_gpg = NULL;
void AuthGPGInit()
{
instance_gpg = new AuthGPGimpl();
}
void AuthGPGExit()
{
if (instance_gpg) {

View File

@ -139,7 +139,7 @@ typedef std::map<std::string, gpgcert> certmap;
extern void AuthGPGInit();
extern void AuthGPGExit();
class AuthGPG
class AuthGPG : public RsThread
{
public:
@ -259,7 +259,7 @@ virtual bool addService(AuthGPGService *service) = 0;
/* The real implementation! */
class AuthGPGimpl : public AuthGPG, public p3Config, public RsThread
class AuthGPGimpl : public AuthGPG, public p3Config
{
public:

View File

@ -8,10 +8,10 @@ DHT_TOP_DIR = ../../../../libbitdht/src
include $(RS_TOP_DIR)/tests/scripts/config.mk
###############################################################
TESTOBJ = fitest2.o fisavetest.o searchtest.o
TESTOBJ = fitest2.o fisavetest.o searchtest.o #ficachetest.o
#ficachetest.o
TESTS = fitest2 fisavetest searchtest
TESTS = fitest2 fisavetest searchtest #ficachetest
#ficachetest
ifeq ($(OS),Linux)

View File

@ -23,6 +23,7 @@
#include "dbase/cachestrapper.h"
#include "dbase/cachetest.h"
#include "pqi/p3connmgr.h"
#include <iostream>
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
@ -52,9 +53,9 @@ int main(int argc, char **argv)
RsPeerId pid2("0x0102");
RsPeerId pid3("0x0103");
p3ConnectMgr *connMgr1 = NULL;
p3ConnectMgr *connMgr2 = NULL;
p3ConnectMgr *connMgr3 = NULL;
p3ConnectMgr *connMgr1 = new p3ConnectMgr();
p3ConnectMgr *connMgr2 = connMgr1;
p3ConnectMgr *connMgr3 = connMgr1;
CacheStrapper sc1(connMgr1);
CacheStrapper sc2(connMgr2);
@ -72,15 +73,15 @@ int main(int argc, char **argv)
std::string nulldir = "";
CacheSource *csrc1 = new CacheTestSource(&sc1, nulldir);
CacheStore *cstore1 = new CacheTestStore(&ctt1, nulldir);
CacheStore *cstore1 = new CacheTestStore(&ctt1, &sc1, nulldir);
CacheId cid1(TESTID, 0);
CacheSource *csrc2 = new CacheTestSource(&sc2, nulldir);
CacheStore *cstore2 = new CacheTestStore(&ctt2, nulldir);
CacheStore *cstore2 = new CacheTestStore(&ctt2, &sc2, nulldir);
CacheId cid2(TESTID, 0);
CacheSource *csrc3 = new CacheTestSource(&sc3, nulldir);
CacheStore *cstore3 = new CacheTestStore(&ctt3, nulldir);
CacheStore *cstore3 = new CacheTestStore(&ctt3, &sc3, nulldir);
CacheId cid3(TESTID, 0);
CachePair cp1(csrc1, cstore1, cid1);
@ -183,7 +184,7 @@ void handleQuery(CacheStrapper *csp, RsPeerId pid,
std::cerr << "Cache Query from: " << pid << std::endl;
csp -> sendCacheQuery(ids, time(NULL));
//csp -> sendCacheQuery(ids, time(NULL));
for(pit = ids.begin(); pit != ids.end(); pit++)
{
std::cerr << "Cache Query for: " << (*pit) << std::endl;

View File

@ -21,6 +21,9 @@
*
*/
#include "pqi/p3connmgr.h"
#include "retroshare/rsiface.h"
#include "dbase/cachestrapper.h"
#include "dbase/findex.h"
#include "dbase/fimonitor.h"
@ -34,7 +37,12 @@ void usage(char *name)
}
/*!
* What is tested:
* 1.
* 2.
* 3.
*/
int main(int argc, char **argv)
{
/* handle commandline arguments */
@ -73,12 +81,13 @@ int main(int argc, char **argv)
usage(argv[0]);
}
sleep(1);
//p3ConnectMgr connMgr;
NotifyBase nb;
CacheStrapper* cs = NULL;
FileIndexMonitor mon(NULL,NULL, "", "OWN ID");
FileIndexMonitor mon(cs, &nb, "", "OWN ID", std::string("."));
/* setup monitor */
mon.setPeriod(period);
mon.setSharedDirectories(rootdirs);
/* simulate running the thread */

View File

@ -17,7 +17,7 @@ static int test_fill(ftFileCreator *creator);
int main()
{
/* use ftcreator to create a file on tmp drive */
ftFileCreator fcreator("/tmp/rs-ftfc-test.dta",100000,"hash");
ftFileCreator fcreator("/tmp/rs-ftfc-test.dta",100000,"hash", false);
test_timeout(&fcreator);
test_fill(&fcreator);
@ -32,7 +32,7 @@ int test_timeout(ftFileCreator *creator)
{
uint32_t chunk = 1000;
uint64_t offset = 0;
int max_timeout = 30;
int max_timeout = 5;
int max_offset = chunk * max_timeout;
int i;
std::cerr << "60 second test of chunk queue.";
@ -48,7 +48,7 @@ int test_timeout(ftFileCreator *creator)
std::cerr << "Allocated Offset: " << offset << " chunk: " << chunk << std::endl;
CHECK(offset <= max_offset);
sleep(1);
// sleep(1);
}
std::cerr << "Expect Repeats now";
@ -56,7 +56,7 @@ int test_timeout(ftFileCreator *creator)
for(i = 0; i < max_timeout; i++)
{
sleep(1);
// sleep(1);
creator->getMissingChunk(peer_id, size_hint, offset, chunk, toOld);
std::cerr << "Allocated Offset: " << offset << " chunk: " << chunk << std::endl;

View File

@ -33,7 +33,7 @@ int main()
}
}
ftFileCreator *creator = new ftFileCreator(filename, size, "hash");
ftFileCreator *creator = new ftFileCreator(filename, size, "hash", true);
for(offset = 0; offset != size; offset += chunk)
{
if (!creator->addFileData(offset, chunk, data))
@ -49,7 +49,7 @@ int main()
std::cerr << std::endl;
/* load it with file provider */
creator = new ftFileCreator(filename2, size, "hash");
creator = new ftFileCreator(filename2, size, "hash", true);
ftFileProvider *provider = new ftFileProvider(filename, size, "hash");
/* create duplicate with file creator */

View File

@ -84,7 +84,7 @@ bool AuthGPGtest::InitAuth()
/* Init by generating new Own PGP Cert, or selecting existing PGP Cert */
int AuthGPGtest::GPGInit(std::string ownId)
int AuthGPGtest::GPGInit(const std::string& ownId)
{
std::cerr << "AuthGPGtest::GPGInit(): new OwnId: " << ownId;
std::cerr << std::endl;
@ -118,14 +118,14 @@ bool AuthGPGtest::GeneratePGPCertificate(std::string name, std::string email, st
* provide access to details in cache list.
*
****/
std::string AuthGPGtest::getGPGName(GPG_id pgp_id)
std::string getGPGName(const std::string &pgp_id)
{
std::cerr << "AuthGPGtest::getGPGName()";
std::cerr << std::endl;
return "DUMMY_NAME";
}
std::string AuthGPGtest::getGPGEmail(GPG_id pgp_id)
std::string getGPGEmail(const std::string &pgp_id)
{
std::cerr << "AuthGPGtest::getGPGEmail()";
std::cerr << std::endl;
@ -158,7 +158,7 @@ std::string AuthGPGtest::getGPGOwnEmail()
}
#endif
bool AuthGPGtest::getGPGDetails(std::string id, RsPeerDetails &d)
bool AuthGPGtest::getGPGDetails(const std::string& id, RsPeerDetails &d)
{
std::cerr << "AuthGPGtest::getGPGDetails()";
std::cerr << std::endl;
@ -193,28 +193,28 @@ bool AuthGPGtest::getGPGSignedList(std::list<std::string> &ids)
return true;
}
bool AuthGPGtest::isGPGValid(std::string id)
bool AuthGPGtest::isGPGValid(const std::string& id)
{
std::cerr << "AuthGPGtest::isGPGValid()";
std::cerr << std::endl;
return true;
}
bool AuthGPGtest::isGPGSigned(std::string id)
bool AuthGPGtest::isGPGSigned(const std::string& id)
{
std::cerr << "AuthGPGtest::isGPGSigned()";
std::cerr << std::endl;
return true;
}
bool AuthGPGtest::isGPGAccepted(std::string id)
bool AuthGPGtest::isGPGAccepted(const std::string& id)
{
std::cerr << "AuthGPGtest::isGPGAccepted()";
std::cerr << std::endl;
return true;
}
bool AuthGPGtest::isGPGId(GPG_id id)
bool isGPGId(const std::string &id)
{
std::cerr << "AuthGPGtest::isGPGId()";
std::cerr << std::endl;
@ -229,14 +229,15 @@ bool AuthGPGtest::isGPGId(GPG_id id)
* STAGE 4: Loading and Saving Certificates. (Strings and Files)
*
****/
bool AuthGPGtest::LoadCertificateFromString(std::string pem, std::string &gpg_id)
bool AuthGPGtest::LoadCertificateFromString(const std::string& pem, std::string &gpg_id,
std::string& error_string)
{
std::cerr << "AuthGPGtest::LoadCertificateFromString()";
std::cerr << std::endl;
return false;
return true;
}
std::string AuthGPGtest::SaveCertificateToString(std::string id)
std::string AuthGPGtest::SaveCertificateToString(const std::string& id)
{
std::cerr << "AuthGPGtest::SaveCertificateToString()";
std::cerr << std::endl;
@ -254,27 +255,39 @@ std::string AuthGPGtest::SaveCertificateToString(std::string id)
* done in gpgroot already.
*
****/
bool AuthGPGtest::setAcceptToConnectGPGCertificate(std::string gpg_id, bool acceptance)
bool AuthGPGtest::setAcceptToConnectGPGCertificate(const std::string& gpg_id,
bool acceptance)
{
std::cerr << "AuthGPGtest::setAcceptToConnectGPGCertificate()";
std::cerr << std::endl;
return true;
}
bool AuthGPGtest::SignCertificateLevel0(std::string id)
bool AuthGPGtest::SignCertificateLevel0(const std::string& id)
{
std::cerr << "AuthGPGtest::SignCertificateLevel0()";
std::cerr << std::endl;
return true;
}
bool AuthGPGtest::RevokeCertificate(std::string id)
bool AuthGPGtest::RevokeCertificate(const std::string& id)
{
std::cerr << "AuthGPGtest::RevokeCertificate()";
std::cerr << std::endl;
return true;
}
virtual bool TrustCertificate(const std::string &id, int trustlvl)
{
std::cerr << "AuthGPGtest::TrustCertificate()";
std::cerr << std::endl;
return true;
}
void AuthGPGtest::run()
{
}
#if 0
bool AuthGPGtest::TrustCertificateNone(std::string id)
{
@ -343,21 +356,47 @@ bool AuthGPGtest::SignDataBin(const void *data, const uint32_t len, unsigned cha
{
std::cerr << "AuthGPGtest::SignDataBin()";
std::cerr << std::endl;
return false;
return true;
}
bool AuthGPGtest::VerifySignBin(const void*, uint32_t, unsigned char*, unsigned int, std::string withfingerprint)
bool AuthGPGtest::VerifySignBin(const void*, uint32_t, unsigned char*, unsigned int, const std::string& withfingerprint)
{
std::cerr << "AuthGPGtest::VerifySignBin()";
std::cerr << std::endl;
return false;
return true;
}
bool AuthGPGtest::decryptText(gpgme_data_t CIPHER, gpgme_data_t PLAIN)
{
std::cerr << "AuthGPGtest::decryptText()";
std::cerr << std::endl;
return false;
return true;
}
bool AuthGPGimpl::addService(AuthGPGService *service)
{
std::cerr << "AuthGPGtest::addService()";
std::cerr << std::endl;
return true;
}
std::string AuthGPGtest::getGPGName(const std::string & pgp_id)
{
std::cerr << "AuthGPGtest::getGPGName()";
std::cerr << std::endl;
return std::string("");
}
bool AuthGPGtest::TrustCertificate(const std::string & id, int trustlvl)
{
}
bool AuthGPGtest::isGPGId(const std::string & id)
{
}
std::string AuthGPGtest::getGPGEmail(const std::string & pgp_id)
{
}
bool AuthGPGtest::encryptText(gpgme_data_t PLAIN, gpgme_data_t CIPHER)

View File

@ -64,9 +64,10 @@ virtual bool active();
/* Initialize */
virtual bool InitAuth ();
virtual void run();
/* Init by generating new Own PGP Cert, or selecting existing PGP Cert */
virtual int GPGInit(std::string ownId);
virtual int GPGInit(const std::string& ownId);
virtual bool CloseAuth();
virtual bool GeneratePGPCertificate(std::string name, std::string email, std::string passwd, std::string &pgpId, std::string &errString);
@ -81,23 +82,23 @@ virtual bool GeneratePGPCertificate(std::string name, std::string email, std:
* provide access to details in cache list.
*
****/
virtual std::string getGPGName(GPG_id pgp_id);
virtual std::string getGPGEmail(GPG_id pgp_id);
virtual std::string getGPGName(const std::string &pgp_id);
virtual std::string getGPGEmail(const std::string &pgp_id);
/* PGP web of trust management */
virtual std::string getGPGOwnId();
virtual std::string getGPGOwnName();
//virtual std::string getGPGOwnEmail();
virtual bool getGPGDetails(std::string id, RsPeerDetails &d);
virtual bool getGPGDetails(const std::string& id, RsPeerDetails &d);
virtual bool getGPGAllList(std::list<std::string> &ids);
virtual bool getGPGValidList(std::list<std::string> &ids);
virtual bool getGPGAcceptedList(std::list<std::string> &ids);
virtual bool getGPGSignedList(std::list<std::string> &ids);
virtual bool isGPGValid(std::string id);
virtual bool isGPGSigned(std::string id);
virtual bool isGPGAccepted(std::string id);
virtual bool isGPGId(GPG_id id);
virtual bool isGPGValid(const std::string& id);
virtual bool isGPGSigned(const std::string& id);
virtual bool isGPGAccepted(const std::string& id);
virtual bool isGPGId(const std::string &id);
/*********************************************************************************/
/************************* STAGE 4 ***********************************************/
@ -106,8 +107,9 @@ virtual bool isGPGId(GPG_id id);
* STAGE 4: Loading and Saving Certificates. (Strings and Files)
*
****/
virtual bool LoadCertificateFromString(std::string pem, std::string &gpg_id);
virtual std::string SaveCertificateToString(std::string id);
virtual bool LoadCertificateFromString(const std::string& pem, std::string &gpg_id,
std::string& error_string);
virtual std::string SaveCertificateToString(const std::string& id);
/*********************************************************************************/
/************************* STAGE 6 ***********************************************/
@ -119,13 +121,14 @@ virtual std::string SaveCertificateToString(std::string id);
* done in gpgroot already.
*
****/
virtual bool setAcceptToConnectGPGCertificate(std::string gpg_id, bool acceptance); //don't act on the gpg key, use a seperate set
virtual bool SignCertificateLevel0(std::string id);
virtual bool RevokeCertificate(std::string id); /* Particularly hard - leave for later */
virtual bool setAcceptToConnectGPGCertificate(const std::string& gpg_id,
bool acceptance); //don't act on the gpg key, use a seperate set
virtual bool SignCertificateLevel0(const std::string& id);
virtual bool RevokeCertificate(const std::string& id); /* Particularly hard - leave for later */
//virtual bool TrustCertificateNone(std::string id);
//virtual bool TrustCertificateMarginally(std::string id);
//virtual bool TrustCertificateFully(std::string id);
virtual bool TrustCertificate(std::string id, int trustlvl); //trustlvl is 2 for none, 3 for marginal and 4 for full trust
virtual bool TrustCertificate(const std::string &id, int trustlvl); //trustlvl is 2 for none, 3 for marginal and 4 for full trust
/*********************************************************************************/
/************************* STAGE 7 ***********************************************/
@ -140,15 +143,18 @@ virtual bool TrustCertificate(std::string id, int trustlvl); //trustlvl is 2 fo
//virtual bool SignData(const void *data, const uint32_t len, std::string &sign);
//virtual bool SignDataBin(std::string input, unsigned char *sign, unsigned int *signlen);
virtual bool SignDataBin(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen);
virtual bool VerifySignBin(const void*, uint32_t, unsigned char*, unsigned int, std::string withfingerprint);
virtual bool VerifySignBin(const void*, uint32_t, unsigned char*, unsigned int, const std::string& withfingerprint);
virtual bool decryptText(gpgme_data_t CIPHER, gpgme_data_t PLAIN);
virtual bool encryptText(gpgme_data_t PLAIN, gpgme_data_t CIPHER);
//END of PGP public functions
virtual bool addService(AuthGPGService *service);
private:
std::string mOwnGPGId;
};
#endif

View File

@ -13,13 +13,13 @@ TESTOBJ = tlvbase_test.o tlvbase_test2.o rstunnelitem_test.o
TESTOBJ += tlvitems_test.o tlvstack_test.o rsserial_test.o
TESTOBJ += rstlvwidetest.o tlvrandom_test.o rsturtleitem_test.o
TESTOBJ += tlvtypes_test.o support.o distribitem_test.o rsmsgitem_test.o
TESTOBJ += rsstatusitem_test.o
TESTOBJ += rsstatusitem_test.o rsconfigitem_test.o
TESTS = tlvbase_test tlvbase_test2 rstlvwidetest
TESTS += tlvitems_test tlvstack_test rstunnelitem_test
TESTS += tlvrandom_test rsserial_test rsturtleitem_test
TESTS += tlvtypes_test distribitem_test rsmsgitem_test
TESTS += rsstatusitem_test
TESTS += rsstatusitem_test rsconfigitem_test
#rsbaseitem_test
@ -67,6 +67,9 @@ rsmsgitem_test : rsmsgitem_test.o support.o
rsstatusitem_test : rsstatusitem_test.o support.o
$(CC) $(CFLAGS) -o rsstatusitem_test rsstatusitem_test.o support.o $(OBJ) $(LIBS)
rsconfigitem_test : rsconfigitem_test.o
$(CC) $(CFLAGS) -o rsconfigitem_test rsconfigitem_test.o support.o $(OBJ) $(LIBS)
###############################################################
include $(RS_TOP_DIR)/scripts/rules.mk
###############################################################