2020-05-08 12:43:46 +02:00
|
|
|
#include "tests.h"
|
2020-05-31 19:24:35 +02:00
|
|
|
#include "msql_acces.h"
|
|
|
|
#include <openssl/evp.h>
|
|
|
|
#include <openssl/sha.h>
|
|
|
|
#include <string.h>
|
2020-05-08 12:43:46 +02:00
|
|
|
|
|
|
|
void test_basic::setUp(){
|
|
|
|
this->conf=new config_reader("config");
|
2020-05-31 19:24:35 +02:00
|
|
|
this->data=new msql_acces();
|
2020-05-08 12:43:46 +02:00
|
|
|
}
|
|
|
|
|
2020-05-31 19:24:35 +02:00
|
|
|
void test_basic::test_initial(){
|
2020-05-08 12:43:46 +02:00
|
|
|
std::string res;
|
|
|
|
CPPUNIT_ASSERT(true==this->conf->get_param("port",res));
|
|
|
|
CPPUNIT_ASSERT("4433"==res);
|
|
|
|
}
|
|
|
|
|
|
|
|
void test_basic::pass_tests(){
|
|
|
|
CPPUNIT_NS::TestResult testresult;
|
|
|
|
CPPUNIT_NS::TestResultCollector collectedresults;
|
|
|
|
testresult.addListener (&collectedresults);
|
|
|
|
CPPUNIT_NS::BriefTestProgressListener progress;
|
|
|
|
testresult.addListener (&progress);
|
|
|
|
CPPUNIT_NS::TestRunner testrunner;
|
|
|
|
testrunner.addTest (CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest ());
|
|
|
|
testrunner.run(testresult);
|
|
|
|
}
|
2020-05-31 19:24:35 +02:00
|
|
|
|
|
|
|
void test_basic::hash_test(){
|
|
|
|
CPPUNIT_ASSERT(strcmp(data_acces::get_hash("test1")
|
|
|
|
,data_acces::get_hash("test1"))==0);
|
|
|
|
CPPUNIT_ASSERT(strcmp(data_acces::get_hash("test1")
|
|
|
|
,data_acces::get_hash("test2"))!=0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void test_basic::msql_loggin_test(){
|
|
|
|
std::string pass = this->data->get_passwd("test");
|
|
|
|
CPPUNIT_ASSERT(pass==std::string(data_acces::get_hash("ok")));
|
|
|
|
CPPUNIT_ASSERT(pass!=std::string(data_acces::get_hash("fail")));
|
|
|
|
}
|
|
|
|
|
|
|
|
void test_basic::msql_package_test(){
|
|
|
|
data->write_install("p1","test");
|
|
|
|
CPPUNIT_ASSERT(data->get_package_exists("p1"));
|
|
|
|
data->write_remove("p1");
|
|
|
|
CPPUNIT_ASSERT(!data->get_package_exists("p1"));
|
|
|
|
}
|