testNormlReqAns.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #define CATCH_CONFIG_MAIN
  2. #include <catch2.hpp>
  3. #include "RestfulFunc.h"
  4. TEST_CASE("test api manage", "[restful]")
  5. {
  6. HttpClientRequestConfig config("https://rvcgateway.paasst.cmbchina.cn/terminal");
  7. HttpClientResponseResult result;
  8. config.SetChildUri("/api/manage/regist/7555980103");
  9. RestfulClient client = RestfulClient::getInstance();
  10. client.Do(&config, &result, NULL);
  11. std::cout << result.content << std::endl;
  12. REQUIRE(!result.content.empty());
  13. }
  14. TEST_CASE("test api stage get api", "[restful]")
  15. {
  16. HttpClientRequestConfig config("https://rvcterminal.paasst.cmbchina.cn");
  17. HttpClientResponseResult result;
  18. config.SetChildUri("/api/stage");
  19. config.AppendQuery("terminalNo", "7555980001");
  20. RestfulClient client = RestfulClient::getInstance();
  21. client.Do(&config, &result, NULL);
  22. std::cout << result.content << std::endl;
  23. REQUIRE(!result.content.empty());
  24. }
  25. TEST_CASE("test api stage post api", "[restful]")
  26. {
  27. HttpClientRequestConfig config("https://rvcterminal.paasst.cmbchina.cn");
  28. config.SetRequestType(HttpRequestMethod::POST);
  29. config.SetChildUri("/api/stage");
  30. config.SetJsonBody("{\"terminalNo\":\"7555980001\", \"errEntityList\":\"566666\"}");
  31. RestfulClient client = RestfulClient::getInstance();
  32. HttpClientResponseResult result;
  33. client.Do(&config, &result, NULL);
  34. std::cout << result.content << std::endl;
  35. REQUIRE(!result.content.empty());
  36. }
  37. TEST_CASE("test api stage upload api", "[restful]")
  38. {
  39. HttpClientUploadRequest config("http://55.6.78.29:8080");
  40. config.SetChildUri("/api/upload/file");
  41. config.SetDefaultParam("{\"branch_no\":\"755\",\"file_head_custom\":\"\",\"file_name\":\"20220301.log\",\"file_path\":\"/home/rvc/dbg/mod_initiativetransfer/20220301.log\",\"file_type\":\"O\",\"first_file_length\":\"105116\",\"last_file_length\":\"\",\"plan_id\":\"dbg\",\"system_type\":\"L\",\"terminal_no\":\"7555980012\",\"upload_length\":\"0\"}");
  42. config.AddFiles("/home/rvc/dbg/mod_initiativetransfer/20220301.log");
  43. RestfulClient client = RestfulClient::getInstance();
  44. HttpClientResponseResult result;
  45. config.PreDo();
  46. client.Do(&config, &result, NULL);
  47. std::cout << result.content << std::endl;
  48. REQUIRE(!result.content.empty());
  49. }