From 66fbc002ecf1adb48840f93228d7c7a064a0c4cb Mon Sep 17 00:00:00 2001 From: dongjulim Date: Thu, 21 Mar 2024 16:54:02 +0900 Subject: [PATCH] add https, smtp test --- .gitignore | 6 +- CMakeLists.txt | 34 +- crypto_digest.cpp | 52 --- filesystem_test.cpp | 170 ---------- http_test1.cpp | 62 ---- icmp_test.cpp | 16 - json_test.cpp | 44 --- ntp_test.cpp | 26 -- os_check.cpp | 16 - pocoTest.cbp | 647 +++++++++++++++++++++++++++++++++--- process_test.cpp | 50 --- secure_http_test.properties | 27 ++ secure_smtp_test.cpp | 4 - task_test.cpp | 75 ----- tcp_client_test.cpp | 40 --- tcp_server_test.cpp | 92 ----- thread_test.cpp | 94 ------ timer_test.cpp | 45 --- udp_rcev_test.cpp | 45 --- udp_send_test.cpp | 48 --- win_service_test.cpp | 17 - xml_test.cpp | 101 ------ 22 files changed, 642 insertions(+), 1069 deletions(-) delete mode 100644 crypto_digest.cpp delete mode 100644 filesystem_test.cpp delete mode 100644 http_test1.cpp delete mode 100644 icmp_test.cpp delete mode 100644 json_test.cpp delete mode 100644 ntp_test.cpp delete mode 100644 os_check.cpp delete mode 100644 process_test.cpp create mode 100644 secure_http_test.properties delete mode 100644 secure_smtp_test.cpp delete mode 100644 task_test.cpp delete mode 100644 tcp_client_test.cpp delete mode 100644 tcp_server_test.cpp delete mode 100644 thread_test.cpp delete mode 100644 timer_test.cpp delete mode 100644 udp_rcev_test.cpp delete mode 100644 udp_send_test.cpp delete mode 100644 win_service_test.cpp delete mode 100644 xml_test.cpp diff --git a/.gitignore b/.gitignore index e96d6a8..4478cce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +#binaray file 제외 +* +!*.* /cmake-build-debug /CMakeFiles /Testing @@ -6,6 +9,3 @@ cmake_install.cmake Makefile CMakeCache.txt -#binaray file 제외 -* -!*.* \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d571ea..6444c1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,23 +11,27 @@ set(LIBRARY_SET stdc++ Poco::Foundation Poco::Net Poco::Util Poco::XML Poco::JSON Poco::NetSSL ) -add_executable(http_test1 http_test1.cpp) -add_executable(filesystem_test filesystem_test.cpp) -add_executable(process_test process_test.cpp) -add_executable(thread_test thread_test.cpp) -add_executable(os_check os_check.cpp) -add_executable(task_test task_test.cpp) +add_executable(http_test1 src/http_test1.cpp) +add_executable(filesystem_test src/filesystem_test.cpp) +add_executable(process_test src/process_test.cpp) +add_executable(thread_test src/thread_test.cpp) +add_executable(os_check src/os_check.cpp) +add_executable(task_test src/task_test.cpp) #add_executable(win_service_test win_service_test.cpp) -add_executable(crypto_certificate crypto_digest.cpp) -add_executable(json_test json_test.cpp) -add_executable(xml_test xml_test.cpp) -add_executable(tcp_server_test tcp_server_test.cpp) -add_executable(tcp_client_test tcp_client_test.cpp) +add_executable(crypto_certificate src/crypto_digest.cpp) +add_executable(json_test src/json_test.cpp) +add_executable(xml_test src/xml_test.cpp) +add_executable(tcp_server_test src/tcp_server_test.cpp) +add_executable(tcp_client_test src/tcp_client_test.cpp) #add_executable(ntp_test ntp_test.cpp) #add_executable(icmp_test icmp_test.cpp) -add_executable(udp_recv_test udp_rcev_test.cpp) -add_executable(udp_send_test udp_send_test.cpp) -add_executable(timer_test timer_test.cpp) +add_executable(udp_recv_test src/udp_rcev_test.cpp) +add_executable(udp_send_test src/udp_send_test.cpp) +add_executable(timer_test src/timer_test.cpp) +add_executable(secure_smtp_test src/secure_smtp_test.cpp) +add_executable(secure_http_test ssl_https/secure_http_test.cpp) + + target_link_libraries(http_test1 ${LIBRARY_SET}) target_link_libraries(filesystem_test ${LIBRARY_SET}) @@ -46,3 +50,5 @@ target_link_libraries(tcp_client_test ${LIBRARY_SET}) target_link_libraries(udp_recv_test ${LIBRARY_SET}) target_link_libraries(udp_send_test ${LIBRARY_SET}) target_link_libraries(timer_test ${LIBRARY_SET}) +target_link_libraries(secure_smtp_test ${LIBRARY_SET}) +target_link_libraries(secure_http_test ${LIBRARY_SET}) \ No newline at end of file diff --git a/crypto_digest.cpp b/crypto_digest.cpp deleted file mode 100644 index 0c118fa..0000000 --- a/crypto_digest.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "Poco/HMACEngine.h" -#include "Poco/SHA1Engine.h" -#include "Poco/DigestStream.h" -#include "Poco/MD5Engine.h" -using Poco::DigestOutputStream; -using Poco::MD5Engine; -using Poco::DigestEngine; -using Poco::HMACEngine; -using Poco::SHA1Engine; - -void hmac_sha1_engine() -{ - std::cout<<"hmac-sha1 crypto test...."; - std::string message1("This is a top-secret message."); - std::string message2("Don't tell anyone!"); - std::string passphrase("s3cr3t"); // HMAC needs a passphrase - HMACEngine hmac(passphrase); // we'll compute a HMAC-SHA1 - hmac.update(message1); - hmac.update(message2); - const DigestEngine::Digest& digest = hmac.digest(); -// finish HMAC computation and obtain digest - std::string digestString(DigestEngine::digestToHex(digest)); -// convert to a string of hexadecimal numbers - if(digestString=="53e5ff04f787d1f72e8385bb1e7ccc4542d86238"){ - std::cout<<"ok"< -#include "Poco/Path.h" -#include "Poco/Environment.h" -#include "Poco/Foundation.h" -#include "Poco/Glob.h" -#include -#include -#include - -void make_path(){ - std::cout<<"----------make path----------"< files; - tmpDir.list(files); - std::vector::iterator it = files.begin(); - for (; it != files.end(); ++it) - { - std::cout <<"\t"<< *it << std::endl; - } - tmpDir.remove(true); - std::cout<<"-------------------------"< files; - if (POCO_OS==POCO_OS_WINDOWS_NT){ - Poco::Glob::glob("%WINDIR%\\system32\\*.exe", files); - } else { - Poco::Glob::glob("/usr/include/*/*.h", files); - } - Poco::File file(Poco::Path(Poco::Path::current(),std::string("glob_test.txt"))); - std::ofstream ostr(file.path().c_str()); - std::cout<<"checkout the result of Glob test for '"<::iterator it = files.begin(); - for (; it != files.end(); ++it) - { - ostr<<*it< - -using namespace Poco; -using namespace Poco::Net; -using namespace Poco::Util; - -class HelloRequestHandler: public HTTPRequestHandler -{ - void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response) - { - Application& app = Application::instance(); - std::cout<<"Request from "<" - << "Hello" - << "

Hello from the POCO Web Server

" - << ""; - } -}; - -class HelloRequestHandlerFactory: public HTTPRequestHandlerFactory -{ - HTTPRequestHandler* createRequestHandler(const HTTPServerRequest&) - { - return new HelloRequestHandler; - } -}; - -class WebServerApp: public ServerApplication -{ - void initialize(Application& self) - { - loadConfiguration(); - ServerApplication::initialize(self); - } - - int main(const std::vector&) - { - UInt16 port = static_cast(config().getUInt("port", 8080)); - - HTTPServer srv(new HelloRequestHandlerFactory, port); - srv.start(); - std::cout<<"HTTP Server started on port"< -#include -#include -#include -#include -int main(){ - Poco::Net::SocketAddress addr("172.0.0.1",8080); - Poco::Net::ICMPClient client(addr.family()); - - std::cout< -#include -#include -#include "Poco/JSON/Object.h" -#include "Poco/JSON/Parser.h" -void JsonObjectTest(){ - Poco::JSON::Object obj; - obj.set("id","userid"); - obj.set("pass","password"); - Poco::JSON::Array array; - array.set(0,"one"); - array.set(1,"two"); - array.set(2,"three"); - obj.set("array",array); - - std::ostringstream oss,oss_indent; - obj.stringify(oss_indent,1); - std::cout<(); - std::string name = pObject->getValue("name"); -// std::cout<getArray("have"); - Poco::Dynamic::Var first = pChildren->get(0); - Poco::Dynamic::Var second = pChildren->get(1); -// std::cout< -#include "Poco/Net/NTPClient.h" -#include "Poco/BasicEvent.h" -#include -int main() { - Poco::Net::SocketAddress address("127.0.0.1", 123); - Poco::Net::NTPClient ntp_client(address.family()); - - Poco::Net::NTPEventArgs ntp_ev(address); - std::cout< -using Poco::Environment; -int main(int argc, char** argv) -{ - std::cout - << "OS Name: " << Environment::osName() << std::endl - << "OS Version: " << Environment::osVersion() << std::endl - << "OS Arch: " << Environment::osArchitecture() << std::endl - << "Node Name: " << Environment::nodeName() << std::endl - << "Node ID: " << Environment::nodeId() << std::endl; - if (Environment::has("HOME")) - std::cout << "Home: " << Environment::get("HOME") << std::endl; - Environment::set("POCO", "foo"); - return 0; -} \ No newline at end of file diff --git a/pocoTest.cbp b/pocoTest.cbp index 9166582..8c51c60 100644 --- a/pocoTest.cbp +++ b/pocoTest.cbp @@ -27,9 +27,316 @@ - -