comparison OrthancFramework/UnitTestsSources/RestApiTests.cpp @ 4325:b96aedfa8cc1

unit tests now running in WebAssembly
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 24 Nov 2020 16:21:29 +0100
parents 318c16cfccab
children 83c5bd439fcc
comparison
equal deleted inserted replaced
4324:433e94d08e36 4325:b96aedfa8cc1
26 #endif 26 #endif
27 27
28 #include <gtest/gtest.h> 28 #include <gtest/gtest.h>
29 29
30 #include "../Sources/ChunkedBuffer.h" 30 #include "../Sources/ChunkedBuffer.h"
31 #include "../Sources/HttpClient.h"
32 #include "../Sources/Logging.h"
33 #include "../Sources/SystemToolbox.h"
34 #include "../Sources/RestApi/RestApi.h"
35 #include "../Sources/OrthancException.h"
36 #include "../Sources/Compression/ZlibCompressor.h" 31 #include "../Sources/Compression/ZlibCompressor.h"
37 #include "../Sources/RestApi/RestApiHierarchy.h"
38 #include "../Sources/HttpServer/HttpContentNegociation.h" 32 #include "../Sources/HttpServer/HttpContentNegociation.h"
39 #include "../Sources/HttpServer/MultipartStreamReader.h" 33 #include "../Sources/HttpServer/MultipartStreamReader.h"
34 #include "../Sources/Logging.h"
35 #include "../Sources/OrthancException.h"
36 #include "../Sources/RestApi/RestApi.h"
37 #include "../Sources/RestApi/RestApiHierarchy.h"
38 #include "../Sources/WebServiceParameters.h"
40 39
41 #include <ctype.h> 40 #include <ctype.h>
42 #include <boost/lexical_cast.hpp> 41 #include <boost/lexical_cast.hpp>
43 #include <algorithm> 42 #include <algorithm>
44 43
45 44
46 using namespace Orthanc; 45 using namespace Orthanc;
47 46
48 #if !defined(UNIT_TESTS_WITH_HTTP_CONNEXIONS) 47 #if !defined(UNIT_TESTS_WITH_HTTP_CONNEXIONS) && (ORTHANC_SANDBOXED != 1)
49 # error UNIT_TESTS_WITH_HTTP_CONNEXIONS is not defined 48 # error UNIT_TESTS_WITH_HTTP_CONNEXIONS is not defined
50 #endif 49 #endif
51 50
52 #if !defined(ORTHANC_ENABLE_SSL) 51 #if !defined(ORTHANC_ENABLE_SSL)
53 # error ORTHANC_ENABLE_SSL is not defined 52 # error ORTHANC_ENABLE_SSL is not defined
54 #endif 53 #endif
55 54
56 55 #if ORTHANC_SANDBOXED != 1
57 56 # include "../Sources/HttpClient.h"
57 # include "../Sources/SystemToolbox.h"
58 #endif
59
60
61 #if ORTHANC_SANDBOXED != 1
58 TEST(HttpClient, Basic) 62 TEST(HttpClient, Basic)
59 { 63 {
60 HttpClient c; 64 HttpClient c;
61 ASSERT_FALSE(c.IsVerbose()); 65 ASSERT_FALSE(c.IsVerbose());
62 c.SetVerbose(true); 66 c.SetVerbose(true);
76 c.Apply(v); 80 c.Apply(v);
77 ASSERT_TRUE(v.type() == Json::objectValue); 81 ASSERT_TRUE(v.type() == Json::objectValue);
78 ASSERT_TRUE(v.isMember("Description")); 82 ASSERT_TRUE(v.isMember("Description"));
79 #endif 83 #endif
80 } 84 }
81 85 #endif
82 86
83 #if UNIT_TESTS_WITH_HTTP_CONNEXIONS == 1 && ORTHANC_ENABLE_SSL == 1 87
88 #if (UNIT_TESTS_WITH_HTTP_CONNEXIONS == 1) && (ORTHANC_ENABLE_SSL == 1) && (ORTHANC_SANDBOXED != 1)
84 89
85 /** 90 /**
86 The HTTPS CA certificates for BitBucket were extracted as follows: 91 The HTTPS CA certificates for BitBucket were extracted as follows:
87 92
88 (1) We retrieve the certification chain of BitBucket: 93 (1) We retrieve the certification chain of BitBucket:
966 } 971 }
967 } 972 }
968 } 973 }
969 974
970 975
976
977 #if ORTHANC_SANDBOXED != 1
971 978
972 namespace 979 namespace
973 { 980 {
974 class TotoBody : public HttpClient::IRequestBody 981 class TotoBody : public HttpClient::IRequestBody
975 { 982 {
1057 } 1064 }
1058 }; 1065 };
1059 } 1066 }
1060 1067
1061 1068
1069
1062 #include "../Sources/HttpServer/HttpServer.h" 1070 #include "../Sources/HttpServer/HttpServer.h"
1063 1071
1064 TEST(HttpClient, DISABLED_Issue156_Slow) 1072 TEST(HttpClient, DISABLED_Issue156_Slow)
1065 { 1073 {
1066 // https://bugs.orthanc-server.com/show_bug.cgi?id=156 1074 // https://bugs.orthanc-server.com/show_bug.cgi?id=156
1115 ASSERT_TRUE(c.Apply(s)); 1123 ASSERT_TRUE(c.Apply(s));
1116 ASSERT_EQ("ok", s); 1124 ASSERT_EQ("ok", s);
1117 1125
1118 server.Stop(); 1126 server.Stop();
1119 } 1127 }
1128 #endif