diff --git a/cpp/src/license/License.cpp b/cpp/src/license/License.cpp index 193a322e50..eb6c563e4f 100644 --- a/cpp/src/license/License.cpp +++ b/cpp/src/license/License.cpp @@ -43,7 +43,7 @@ Licensefileread(const std::string& path) fileread.open(path,std::ios::in); if(!fileread) { - printf("Can't open file\n"); + printf("NO License\n"); return SERVER_UNEXPECTED_ERROR; } fileread.close(); diff --git a/cpp/src/license/LicenseCreateTime.cpp b/cpp/src/license/LicenseCreateTime.cpp index 7683fae24c..0c2f951511 100644 --- a/cpp/src/license/LicenseCreateTime.cpp +++ b/cpp/src/license/LicenseCreateTime.cpp @@ -12,10 +12,14 @@ using namespace zilliz::vecwise; + + //TEST(LicenseTest, LICENSE_TEST) { // // std::string path1 = "/tmp/vecwise_engine.sha"; // std::string path2 = "/tmp/vecwise_engine.license"; +// std::string path3 = "/tmp/vecwise_engine2.license"; +// // std::cout << "This is create licenseTime " << std::endl; // // server::ServerError err; @@ -39,13 +43,29 @@ using namespace zilliz::vecwise; // err = server::LiSave(path2,deviceCount,uuidEncryption,RemainingTime); // ASSERT_EQ(err, server::SERVER_SUCCESS); // -// int64_t RemainingTimecheck; -// std::map uuidEncryptioncheck; -// int deviceCountcheck; -// err = server::LiLoad(path2,deviceCountcheck,uuidEncryptioncheck,RemainingTimecheck); +//// int64_t RemainingTimecheck; +//// std::map uuidEncryptioncheck; +//// int deviceCountcheck; +//// err = server::LiLoad(path2,deviceCountcheck,uuidEncryptioncheck,RemainingTimecheck); +//// +//// printf("\n deviceCountcheck = %d\n",deviceCountcheck); +//// std::cout<< "RemainingTimecheck: " << RemainingTimecheck<< std::endl; +// +// time_t update_time; +// off_t file_size; +// std::string filemd5; +// +// server::LicenseGetfiletime(path2,update_time); +// ASSERT_EQ(err, server::SERVER_SUCCESS); +// server::LicenseGetfilesize(path2,file_size); +// ASSERT_EQ(err, server::SERVER_SUCCESS); +// server::LicenseGetfilemd5(path2,filemd5); +// ASSERT_EQ(err, server::SERVER_SUCCESS); +// +// +// err = server::LifileSave(path3,update_time,file_size,filemd5); +// ASSERT_EQ(err, server::SERVER_SUCCESS); // -// printf("\n deviceCountcheck = %d\n",deviceCountcheck); -// std::cout<< "RemainingTimecheck: " << RemainingTimecheck<< std::endl; // std::cout<< "success" << std::endl; // -//} \ No newline at end of file +//} diff --git a/cpp/src/license/LicensePublic.cpp b/cpp/src/license/LicensePublic.cpp index 6534674476..632b4cb73d 100644 --- a/cpp/src/license/LicensePublic.cpp +++ b/cpp/src/license/LicensePublic.cpp @@ -223,6 +223,78 @@ LifileLoad(const string& path,time_t& update_time,off_t& file_size,string& filem return SERVER_SUCCESS; } +ServerError +LicenseLegality_check(const std::string& path) +{ + int deviceCount; + std::vector uuids; + LicenseGetuuid(deviceCount,uuids); + + std::vector shas; + LicenseGetuuidsha(deviceCount,uuids,shas); + + + int deviceCountcheck; + std::map uuidEncryption; + int64_t RemainingTime; + LiLoad(path,deviceCountcheck,uuidEncryption,RemainingTime); + + if(deviceCount!=deviceCountcheck) + { + printf("deviceCount is wrong\n"); + return SERVER_UNEXPECTED_ERROR; + } + for(int i=0;i& uuidEncryption, const int64_t& RemainingTime); -void Alterfile(const std::string &path1, const std::string &path2 ,const boost::system::error_code &ec, boost::asio::deadline_timer* pt); -void Runtime(const std::string &path1, const std::string &path2 ); +ServerError +LicenseIntegrity_check(const std::string& path,const std::string& path2); + +ServerError +LicenseLegality_check(const std::string& path); + +void +Alterfile(const std::string &path1, const std::string &path2 ,const boost::system::error_code &ec, boost::asio::deadline_timer* pt); + +void +Runtime(const std::string &path1, const std::string &path2 ); + + + -// void Print(const boost::system::error_code &ec,boost::asio::deadline_timer* pt, int * pcount ); -// void Run(); } } diff --git a/cpp/src/license/LicenseRun.cpp b/cpp/src/license/LicenseRun.cpp index 660fd5fa0c..a059d2f7e2 100644 --- a/cpp/src/license/LicenseRun.cpp +++ b/cpp/src/license/LicenseRun.cpp @@ -10,4 +10,31 @@ #include "license/LicensePublic.h" using namespace zilliz::vecwise; - +//TEST(LicenseTest, LICENSE_TEST) { +// +// std::string path1 = "/tmp/vecwise_engine.license"; +// std::string path2 = "/tmp/vecwise_engine2.license"; +// std::cout << "This is run " << std::endl; +// +// server::ServerError err; +// +// err = server::Licensefileread(path1); +// if(err!=server::SERVER_SUCCESS) +// { +// exit(1); +// } +// err = server::LicenseIntegrity_check(path1,path2); +// if(err!=server::SERVER_SUCCESS) +// { +// std::cout << "Integrity_check is wrong " << std::endl; +// exit(1); +// } +// err = server::LicenseLegality_check(path1); +// if(err!=server::SERVER_SUCCESS) +// { +// std::cout << "Legality_check is wrong " << std::endl; +// exit(1); +// } +// std::cout << " runing " << std::endl; +// server::Runtime(path1,path2); +//} \ No newline at end of file diff --git a/cpp/unittest/license/license_tests.cpp b/cpp/unittest/license/license_tests.cpp index 4ee6898dd9..3da698c1d1 100644 --- a/cpp/unittest/license/license_tests.cpp +++ b/cpp/unittest/license/license_tests.cpp @@ -24,22 +24,26 @@ TEST(LicenseTest, LICENSE_TEST) { { exit(1); } - - int deviceCount=0; - std::vector uuids; - - err = server::LicenseGetuuid(deviceCount,uuids); - ASSERT_EQ(err, server::SERVER_SUCCESS); - - std::vector shas; - err = server::LicenseGetuuidsha(deviceCount,uuids,shas); - ASSERT_EQ(err, server::SERVER_SUCCESS); - - err = server::LicenseSave(path1,deviceCount,shas); - ASSERT_EQ(err, server::SERVER_SUCCESS); - + err = server::LicenseIntegrity_check(path1,path2); + if(err!=server::SERVER_SUCCESS) + { + std::cout << "Integrity_check is wrong " << std::endl; + exit(1); + } + err = server::LicenseLegality_check(path1); + if(err!=server::SERVER_SUCCESS) + { + std::cout << "Legality_check is wrong " << std::endl; + exit(1); + } + std::cout << " runing " << std::endl; + server::Runtime(path1,path2); } + + + + //TEST(LicenseTest, LICENSE_TEST) { // std::string path1 = "/tmp/vecwise_engine.license"; // std::string path2 = "/tmp/vecwise_engine2.license";