testHttpProbe.cpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #define CATCH_CONFIG_MAIN
  2. #include <catch2.hpp>
  3. #include "RestfulFunc.h"
  4. TEST_CASE("test http connected probe", "[probe1]")
  5. {
  6. std::string msg;
  7. REQUIRE(HttpProbe("http://mayun.itc.cmbchina.cn", msg) > 0);
  8. std::cout << msg << std::endl;
  9. }
  10. TEST_CASE("test http baidu probe", "[probe2]")
  11. {
  12. std::string msg;
  13. REQUIRE(HttpProbe("https://www.baidu.com/", msg) > 0);
  14. std::cout << msg << std::endl;
  15. }
  16. TEST_CASE("test http illgal format probe", "[probe3]")
  17. {
  18. std::string msg;
  19. REQUIRE(HttpProbe("", msg) == -3);
  20. std::cout << msg << std::endl;
  21. }
  22. TEST_CASE("test http illgal format probe 2", "[probe4]")
  23. {
  24. std::string msg;
  25. REQUIRE(HttpProbe("http", msg) == -3);
  26. std::cout << msg << std::endl;
  27. }
  28. TEST_CASE("test http illgal format probe 3", "[probe5]")
  29. {
  30. std::string msg;
  31. REQUIRE(HttpProbe("99.12.23.78", msg) == -3);
  32. std::cout << msg << std::endl;
  33. }
  34. TEST_CASE("test http illgal format probe 4", "[probe6]")
  35. {
  36. std::string msg;
  37. REQUIRE(HttpProbe("55.4.33.22", msg) == -3);
  38. std::cout << msg << std::endl;
  39. }
  40. TEST_CASE("test http cmb format probe json", "[probe7]")
  41. {
  42. std::string msg;
  43. REQUIRE(HttpProbe("https://rvcgateway.paas.cmbchina.cn/health", msg) > 0);
  44. std::cout << msg << std::endl;
  45. }
  46. TEST_CASE("test http cmb format probe 2", "[probe8]")
  47. {
  48. std::string msg;
  49. REQUIRE(HttpProbe("https://tsaccess.paas.cmbchina.cn/tsas/detect", msg, -1) == -2);
  50. std::cout << msg << std::endl;
  51. }
  52. TEST_CASE("test http cmb format probe 3", "[probe9]")
  53. {
  54. std::string msg;
  55. REQUIRE(HttpProbe("https://uploadservice.paas.cmbchina.cn/rvc/detect", msg) > 0);
  56. std::cout << msg << std::endl;
  57. }
  58. TEST_CASE("test http cmb format probe 4", "[probe10]")
  59. {
  60. std::string msg;
  61. REQUIRE(HttpProbe("https://rvcterminal.paasst.cmbchina.cn/health", msg) > 0);
  62. std::cout << msg << std::endl;
  63. }
  64. TEST_CASE("test http github probe", "[probe11]")
  65. {
  66. std::string msg;
  67. REQUIRE(HttpProbe("https://github.com/gifur", msg) == -1);
  68. std::cout << msg << std::endl;
  69. }
  70. TEST_CASE("test http github with timeout probe", "[probe]")
  71. {
  72. std::string msg;
  73. REQUIRE(HttpProbe("https://github.com/gifur", msg) == -1);
  74. std::cout << msg << std::endl;
  75. }
  76. TEST_CASE("Test http probe protocols implement", "[normal]")
  77. {
  78. std::string msg;
  79. REQUIRE(HttpProbe("https://rvcgateway.paas.cmbchina.cn/health", msg) == 200);
  80. std::cout << msg << std::endl;
  81. }