Mercurial > hg > orthanc
annotate OrthancFramework/UnitTestsSources/RestApiTests.cpp @ 4046:7ff1e6c80627 framework
moving ImageTests.cpp to framework
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 10 Jun 2020 21:43:31 +0200 |
parents | 05b8fd21089c |
children | 0953b3dc3261 |
rev | line source |
---|---|
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
1 /** |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1064
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
3640
94f4a18a79cc
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3399
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
6 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
8 * modify it under the terms of the GNU General Public License as |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
9 * published by the Free Software Foundation, either version 3 of the |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
10 * License, or (at your option) any later version. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
11 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
12 * In addition, as a special exception, the copyright holders of this |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
13 * program give permission to link the code of its release with the |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
15 * that use the same license as the "OpenSSL" library), and distribute |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
16 * the linked executables. You must obey the GNU General Public License |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
17 * in all respects for all of the code used other than "OpenSSL". If you |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
18 * modify file(s) with this exception, you may extend this exception to |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
19 * your version of the file(s), but you are not obligated to do so. If |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
20 * you do not wish to do so, delete this exception statement from your |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
21 * version. If you delete this exception statement from all source files |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
22 * in the program, then also delete it here. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
23 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
24 * This program is distributed in the hope that it will be useful, but |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
25 * WITHOUT ANY WARRANTY; without even the implied warranty of |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
27 * General Public License for more details. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
28 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
29 * You should have received a copy of the GNU General Public License |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
31 **/ |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
32 |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
707
diff
changeset
|
33 |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3853
diff
changeset
|
34 #if ORTHANC_UNIT_TESTS_LINK_FRAMEWORK == 1 |
4014
27628b0f6ada
merging logging code for plugins and files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3992
diff
changeset
|
35 # include <OrthancFramework.h> |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3853
diff
changeset
|
36 #endif |
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3853
diff
changeset
|
37 |
209 | 38 #include "gtest/gtest.h" |
39 | |
40 #include <ctype.h> | |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
41 #include <boost/lexical_cast.hpp> |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
42 #include <algorithm> |
209 | 43 |
4045 | 44 #include "../Sources/ChunkedBuffer.h" |
45 #include "../Sources/HttpClient.h" | |
46 #include "../Sources/Logging.h" | |
47 #include "../Sources/SystemToolbox.h" | |
48 #include "../Sources/RestApi/RestApi.h" | |
49 #include "../Sources/OrthancException.h" | |
50 #include "../Sources/Compression/ZlibCompressor.h" | |
51 #include "../Sources/RestApi/RestApiHierarchy.h" | |
52 #include "../Sources/HttpServer/HttpContentNegociation.h" | |
53 #include "../Sources/HttpServer/MultipartStreamReader.h" | |
3398
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
54 |
209 | 55 |
56 using namespace Orthanc; | |
57 | |
707
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
58 #if !defined(UNIT_TESTS_WITH_HTTP_CONNEXIONS) |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
59 #error "Please set UNIT_TESTS_WITH_HTTP_CONNEXIONS" |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
60 #endif |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
61 |
1534
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
62 |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
63 |
707
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
64 TEST(HttpClient, Basic) |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
65 { |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
66 HttpClient c; |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
67 ASSERT_FALSE(c.IsVerbose()); |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
68 c.SetVerbose(true); |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
69 ASSERT_TRUE(c.IsVerbose()); |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
70 c.SetVerbose(false); |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
71 ASSERT_FALSE(c.IsVerbose()); |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
72 |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
73 #if UNIT_TESTS_WITH_HTTP_CONNEXIONS == 1 |
2386
883387e2b379
remove dependendy upon ULg Montefiore Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2363
diff
changeset
|
74 // The "http://www.orthanc-server.com/downloads/third-party/" does |
883387e2b379
remove dependendy upon ULg Montefiore Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2363
diff
changeset
|
75 // not automatically redirect to HTTPS, so we cas use it even if the |
883387e2b379
remove dependendy upon ULg Montefiore Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2363
diff
changeset
|
76 // OpenSSL/HTTPS support is disabled in curl |
883387e2b379
remove dependendy upon ULg Montefiore Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2363
diff
changeset
|
77 const std::string BASE = "http://www.orthanc-server.com/downloads/third-party/"; |
2363
f8ef157f2d73
fix unit tests given www.orthanc-server.com now mandatory uses HTTPS
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
78 |
707
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
79 Json::Value v; |
2363
f8ef157f2d73
fix unit tests given www.orthanc-server.com now mandatory uses HTTPS
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
80 c.SetUrl(BASE + "Product.json"); |
f8ef157f2d73
fix unit tests given www.orthanc-server.com now mandatory uses HTTPS
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
81 |
707
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
82 c.Apply(v); |
2187
ad72fbd700b7
move of third party downloads to the main server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
83 ASSERT_TRUE(v.type() == Json::objectValue); |
ad72fbd700b7
move of third party downloads to the main server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
84 ASSERT_TRUE(v.isMember("Description")); |
707
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
85 #endif |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
86 } |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
87 |
1532 | 88 |
2136
dd609a99d39a
uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
89 #if UNIT_TESTS_WITH_HTTP_CONNEXIONS == 1 && ORTHANC_ENABLE_SSL == 1 |
1534
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
90 |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
91 /** |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
92 The HTTPS CA certificates for BitBucket were extracted as follows: |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
93 |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
94 (1) We retrieve the certification chain of BitBucket: |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
95 |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
96 # echo | openssl s_client -showcerts -connect www.bitbucket.org:443 |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
97 |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
98 (2) We see that the certification authority (CA) is |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
99 "www.digicert.com", and the root certificate is "DigiCert High |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
100 Assurance EV Root CA". As a consequence, we navigate to DigiCert to |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
101 find the URL to this CA certificate: |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
102 |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
103 firefox https://www.digicert.com/digicert-root-certificates.htm |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
104 |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
105 (3) Once we get the URL to the CA certificate, we convert it to a C |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
106 macro that can be used by libcurl: |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
107 |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
108 # cd UnitTestsSources |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
109 # ../Resources/RetrieveCACertificates.py BITBUCKET_CERTIFICATES https://www.digicert.com/CACerts/DigiCertHighAssuranceEVRootCA.crt > BitbucketCACertificates.h |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
110 **/ |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
111 |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
112 #include "BitbucketCACertificates.h" |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
113 |
1533
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1532
diff
changeset
|
114 TEST(HttpClient, Ssl) |
1532 | 115 { |
2140 | 116 SystemToolbox::WriteFile(BITBUCKET_CERTIFICATES, "UnitTestsResults/bitbucket.cert"); |
1534
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
117 |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
118 /*{ |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
119 std::string s; |
2140 | 120 SystemToolbox::ReadFile(s, "/usr/share/ca-certificates/mozilla/WoSign.crt"); |
121 SystemToolbox::WriteFile(s, "UnitTestsResults/bitbucket.cert"); | |
1534
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
122 }*/ |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
123 |
1532 | 124 HttpClient c; |
1534
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
125 c.SetHttpsVerifyPeers(true); |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
126 c.SetHttpsCACertificates("UnitTestsResults/bitbucket.cert"); |
3853 | 127 |
128 // Test file modified on 2020-04-20, in order to use a git | |
129 // repository on BitBucket instead of a Mercurial repository | |
130 // (because Mercurial support disappears on 2020-05-31) | |
131 c.SetUrl("https://bitbucket.org/osimis/orthanc-setup-samples/raw/master/docker/serve-folders/orthanc/serve-folders.json"); | |
1532 | 132 |
1534
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
133 Json::Value v; |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
134 c.Apply(v); |
3853 | 135 ASSERT_TRUE(v.isMember("ServeFolders")); |
1534
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
136 } |
1533
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1532
diff
changeset
|
137 |
1534
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
138 TEST(HttpClient, SslNoVerification) |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
139 { |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
140 HttpClient c; |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
141 c.SetHttpsVerifyPeers(false); |
3853 | 142 c.SetUrl("https://bitbucket.org/osimis/orthanc-setup-samples/raw/master/docker/serve-folders/orthanc/serve-folders.json"); |
1534
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
143 |
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
144 Json::Value v; |
1532 | 145 c.Apply(v); |
3853 | 146 ASSERT_TRUE(v.isMember("ServeFolders")); |
1532 | 147 } |
1534
95b3b0260240
Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1533
diff
changeset
|
148 |
1532 | 149 #endif |
150 | |
151 | |
707
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
152 TEST(RestApi, ChunkedBuffer) |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
153 { |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
154 ChunkedBuffer b; |
1492 | 155 ASSERT_EQ(0u, b.GetNumBytes()); |
707
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
156 |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
157 b.AddChunk("hello", 5); |
1492 | 158 ASSERT_EQ(5u, b.GetNumBytes()); |
707
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
159 |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
160 b.AddChunk("world", 5); |
1492 | 161 ASSERT_EQ(10u, b.GetNumBytes()); |
707
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
162 |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
163 std::string s; |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
164 b.Flatten(s); |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
165 ASSERT_EQ("helloworld", s); |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
166 } |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
167 |
330 | 168 TEST(RestApi, ParseCookies) |
169 { | |
1441
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1419
diff
changeset
|
170 IHttpHandler::Arguments headers; |
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1419
diff
changeset
|
171 IHttpHandler::Arguments cookies; |
330 | 172 |
332 | 173 headers["cookie"] = "a=b;c=d;;;e=f;;g=h;"; |
1441
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1419
diff
changeset
|
174 HttpToolbox::ParseCookies(cookies, headers); |
330 | 175 ASSERT_EQ(4u, cookies.size()); |
176 ASSERT_EQ("b", cookies["a"]); | |
177 ASSERT_EQ("d", cookies["c"]); | |
178 ASSERT_EQ("f", cookies["e"]); | |
179 ASSERT_EQ("h", cookies["g"]); | |
180 | |
332 | 181 headers["cookie"] = " name = value ; name2=value2"; |
1441
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1419
diff
changeset
|
182 HttpToolbox::ParseCookies(cookies, headers); |
330 | 183 ASSERT_EQ(2u, cookies.size()); |
184 ASSERT_EQ("value", cookies["name"]); | |
185 ASSERT_EQ("value2", cookies["name2"]); | |
186 | |
332 | 187 headers["cookie"] = " ;;; "; |
1441
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1419
diff
changeset
|
188 HttpToolbox::ParseCookies(cookies, headers); |
330 | 189 ASSERT_EQ(0u, cookies.size()); |
190 | |
332 | 191 headers["cookie"] = " ; n=v ;; "; |
1441
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1419
diff
changeset
|
192 HttpToolbox::ParseCookies(cookies, headers); |
330 | 193 ASSERT_EQ(1u, cookies.size()); |
194 ASSERT_EQ("v", cookies["n"]); | |
195 } | |
196 | |
209 | 197 TEST(RestApi, RestApiPath) |
198 { | |
1441
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1419
diff
changeset
|
199 IHttpHandler::Arguments args; |
209 | 200 UriComponents trail; |
201 | |
202 { | |
203 RestApiPath uri("/coucou/{abc}/d/*"); | |
204 ASSERT_TRUE(uri.Match(args, trail, "/coucou/moi/d/e/f/g")); | |
205 ASSERT_EQ(1u, args.size()); | |
206 ASSERT_EQ(3u, trail.size()); | |
207 ASSERT_EQ("moi", args["abc"]); | |
208 ASSERT_EQ("e", trail[0]); | |
209 ASSERT_EQ("f", trail[1]); | |
210 ASSERT_EQ("g", trail[2]); | |
211 | |
212 ASSERT_FALSE(uri.Match(args, trail, "/coucou/moi/f")); | |
213 ASSERT_TRUE(uri.Match(args, trail, "/coucou/moi/d/")); | |
214 ASSERT_FALSE(uri.Match(args, trail, "/a/moi/d")); | |
215 ASSERT_FALSE(uri.Match(args, trail, "/coucou/moi")); | |
966
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
216 |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
217 ASSERT_EQ(3u, uri.GetLevelCount()); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
218 ASSERT_TRUE(uri.IsUniversalTrailing()); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
219 |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
220 ASSERT_EQ("coucou", uri.GetLevelName(0)); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
221 ASSERT_THROW(uri.GetWildcardName(0), OrthancException); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
222 |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
223 ASSERT_EQ("abc", uri.GetWildcardName(1)); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
224 ASSERT_THROW(uri.GetLevelName(1), OrthancException); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
225 |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
226 ASSERT_EQ("d", uri.GetLevelName(2)); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
227 ASSERT_THROW(uri.GetWildcardName(2), OrthancException); |
209 | 228 } |
229 | |
230 { | |
231 RestApiPath uri("/coucou/{abc}/d"); | |
232 ASSERT_FALSE(uri.Match(args, trail, "/coucou/moi/d/e/f/g")); | |
233 ASSERT_TRUE(uri.Match(args, trail, "/coucou/moi/d")); | |
234 ASSERT_EQ(1u, args.size()); | |
235 ASSERT_EQ(0u, trail.size()); | |
236 ASSERT_EQ("moi", args["abc"]); | |
966
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
237 |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
238 ASSERT_EQ(3u, uri.GetLevelCount()); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
239 ASSERT_FALSE(uri.IsUniversalTrailing()); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
240 |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
241 ASSERT_EQ("coucou", uri.GetLevelName(0)); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
242 ASSERT_THROW(uri.GetWildcardName(0), OrthancException); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
243 |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
244 ASSERT_EQ("abc", uri.GetWildcardName(1)); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
245 ASSERT_THROW(uri.GetLevelName(1), OrthancException); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
246 |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
247 ASSERT_EQ("d", uri.GetLevelName(2)); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
248 ASSERT_THROW(uri.GetWildcardName(2), OrthancException); |
209 | 249 } |
250 | |
251 { | |
252 RestApiPath uri("/*"); | |
253 ASSERT_TRUE(uri.Match(args, trail, "/a/b/c")); | |
254 ASSERT_EQ(0u, args.size()); | |
255 ASSERT_EQ(3u, trail.size()); | |
256 ASSERT_EQ("a", trail[0]); | |
257 ASSERT_EQ("b", trail[1]); | |
258 ASSERT_EQ("c", trail[2]); | |
966
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
259 |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
260 ASSERT_EQ(0u, uri.GetLevelCount()); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
261 ASSERT_TRUE(uri.IsUniversalTrailing()); |
209 | 262 } |
263 } | |
966
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
264 |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
265 |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
266 |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
267 |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
268 |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
269 |
968 | 270 static int testValue; |
271 | |
272 template <int value> | |
974 | 273 static void SetValue(RestApiGetCall& get) |
966
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
274 { |
968 | 275 testValue = value; |
966
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
276 } |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
277 |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
278 |
969 | 279 static bool GetDirectory(Json::Value& target, |
280 RestApiHierarchy& hierarchy, | |
281 const std::string& uri) | |
282 { | |
283 UriComponents p; | |
284 Toolbox::SplitUriComponents(p, uri); | |
285 return hierarchy.GetDirectory(target, p); | |
286 } | |
287 | |
288 | |
978 | 289 |
290 namespace | |
291 { | |
292 class MyVisitor : public RestApiHierarchy::IVisitor | |
293 { | |
294 public: | |
295 virtual bool Visit(const RestApiHierarchy::Resource& resource, | |
296 const UriComponents& uri, | |
1441
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1419
diff
changeset
|
297 const IHttpHandler::Arguments& components, |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2824
diff
changeset
|
298 const UriComponents& trailing) ORTHANC_OVERRIDE |
978 | 299 { |
2543 | 300 return resource.Handle(*(RestApiGetCall*) NULL); |
978 | 301 } |
302 }; | |
303 } | |
304 | |
305 | |
969 | 306 static bool HandleGet(RestApiHierarchy& hierarchy, |
307 const std::string& uri) | |
308 { | |
309 UriComponents p; | |
310 Toolbox::SplitUriComponents(p, uri); | |
978 | 311 MyVisitor visitor; |
312 return hierarchy.LookupResource(p, visitor); | |
969 | 313 } |
314 | |
315 | |
968 | 316 TEST(RestApi, RestApiHierarchy) |
966
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
317 { |
968 | 318 RestApiHierarchy root; |
970 | 319 root.Register("/hello/world/test", SetValue<1>); |
320 root.Register("/hello/world/test2", SetValue<2>); | |
321 root.Register("/hello/{world}/test3/test4", SetValue<3>); | |
322 root.Register("/hello2/*", SetValue<4>); | |
968 | 323 |
324 Json::Value m; | |
325 root.CreateSiteMap(m); | |
326 std::cout << m; | |
327 | |
328 Json::Value d; | |
969 | 329 ASSERT_FALSE(GetDirectory(d, root, "/hello")); |
968 | 330 |
969 | 331 ASSERT_TRUE(GetDirectory(d, root, "/hello/a")); |
968 | 332 ASSERT_EQ(1u, d.size()); |
333 ASSERT_EQ("test3", d[0].asString()); | |
334 | |
969 | 335 ASSERT_TRUE(GetDirectory(d, root, "/hello/world")); |
968 | 336 ASSERT_EQ(2u, d.size()); |
966
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
337 |
969 | 338 ASSERT_TRUE(GetDirectory(d, root, "/hello/a/test3")); |
968 | 339 ASSERT_EQ(1u, d.size()); |
340 ASSERT_EQ("test4", d[0].asString()); | |
341 | |
1064 | 342 ASSERT_TRUE(GetDirectory(d, root, "/hello/world/test")); |
343 ASSERT_TRUE(GetDirectory(d, root, "/hello/world/test2")); | |
969 | 344 ASSERT_FALSE(GetDirectory(d, root, "/hello2")); |
968 | 345 |
346 testValue = 0; | |
969 | 347 ASSERT_TRUE(HandleGet(root, "/hello/world/test")); |
968 | 348 ASSERT_EQ(testValue, 1); |
969 | 349 ASSERT_TRUE(HandleGet(root, "/hello/world/test2")); |
968 | 350 ASSERT_EQ(testValue, 2); |
969 | 351 ASSERT_TRUE(HandleGet(root, "/hello/b/test3/test4")); |
968 | 352 ASSERT_EQ(testValue, 3); |
969 | 353 ASSERT_FALSE(HandleGet(root, "/hello/b/test3/test")); |
968 | 354 ASSERT_EQ(testValue, 3); |
969 | 355 ASSERT_TRUE(HandleGet(root, "/hello2/a/b")); |
968 | 356 ASSERT_EQ(testValue, 4); |
966
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
357 } |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
358 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
359 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
360 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
361 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
362 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
363 namespace |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
364 { |
3398
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
365 class AcceptHandler : public HttpContentNegociation::IHandler |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
366 { |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
367 private: |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
368 std::string type_; |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
369 std::string subtype_; |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
370 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
371 public: |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
372 AcceptHandler() |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
373 { |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
374 Reset(); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
375 } |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
376 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
377 void Reset() |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
378 { |
1782 | 379 Handle("nope", "nope"); |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
380 } |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
381 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
382 const std::string& GetType() const |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
383 { |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
384 return type_; |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
385 } |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
386 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
387 const std::string& GetSubType() const |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
388 { |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
389 return subtype_; |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
390 } |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
391 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
392 virtual void Handle(const std::string& type, |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2824
diff
changeset
|
393 const std::string& subtype) ORTHANC_OVERRIDE |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
394 { |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
395 type_ = type; |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
396 subtype_ = subtype; |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
397 } |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
398 }; |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
399 } |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
400 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
401 |
1782 | 402 TEST(RestApi, HttpContentNegociation) |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
403 { |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
404 // Reference: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
405 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
406 AcceptHandler h; |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
407 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
408 { |
3398
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
409 HttpContentNegociation d; |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
410 d.Register("audio/mp3", h); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
411 d.Register("audio/basic", h); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
412 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
413 ASSERT_TRUE(d.Apply("audio/*; q=0.2, audio/basic")); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
414 ASSERT_EQ("audio", h.GetType()); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
415 ASSERT_EQ("basic", h.GetSubType()); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
416 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
417 ASSERT_TRUE(d.Apply("audio/*; q=0.2, audio/nope")); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
418 ASSERT_EQ("audio", h.GetType()); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
419 ASSERT_EQ("mp3", h.GetSubType()); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
420 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
421 ASSERT_FALSE(d.Apply("application/*; q=0.2, application/pdf")); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
422 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
423 ASSERT_TRUE(d.Apply("*/*; application/*; q=0.2, application/pdf")); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
424 ASSERT_EQ("audio", h.GetType()); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
425 } |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
426 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
427 // "This would be interpreted as "text/html and text/x-c are the |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
428 // preferred media types, but if they do not exist, then send the |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
429 // text/x-dvi entity, and if that does not exist, send the |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
430 // text/plain entity."" |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
431 const std::string T1 = "text/plain; q=0.5, text/html, text/x-dvi; q=0.8, text/x-c"; |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
432 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
433 { |
3398
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
434 HttpContentNegociation d; |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
435 d.Register("text/plain", h); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
436 d.Register("text/html", h); |
1782 | 437 d.Register("text/x-dvi", h); |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
438 ASSERT_TRUE(d.Apply(T1)); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
439 ASSERT_EQ("text", h.GetType()); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
440 ASSERT_EQ("html", h.GetSubType()); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
441 } |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
442 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
443 { |
3398
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
444 HttpContentNegociation d; |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
445 d.Register("text/plain", h); |
1782 | 446 d.Register("text/x-dvi", h); |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
447 d.Register("text/x-c", h); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
448 ASSERT_TRUE(d.Apply(T1)); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
449 ASSERT_EQ("text", h.GetType()); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
450 ASSERT_EQ("x-c", h.GetSubType()); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
451 } |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
452 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
453 { |
3398
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
454 HttpContentNegociation d; |
1782 | 455 d.Register("text/plain", h); |
456 d.Register("text/x-dvi", h); | |
457 d.Register("text/x-c", h); | |
458 d.Register("text/html", h); | |
459 ASSERT_TRUE(d.Apply(T1)); | |
460 ASSERT_EQ("text", h.GetType()); | |
461 ASSERT_TRUE(h.GetSubType() == "x-c" || h.GetSubType() == "html"); | |
462 } | |
463 | |
464 { | |
3398
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
465 HttpContentNegociation d; |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
466 d.Register("text/plain", h); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
467 d.Register("text/x-dvi", h); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
468 ASSERT_TRUE(d.Apply(T1)); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
469 ASSERT_EQ("text", h.GetType()); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
470 ASSERT_EQ("x-dvi", h.GetSubType()); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
471 } |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
472 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
473 { |
3398
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
474 HttpContentNegociation d; |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
475 d.Register("text/plain", h); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
476 ASSERT_TRUE(d.Apply(T1)); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
477 ASSERT_EQ("text", h.GetType()); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
478 ASSERT_EQ("plain", h.GetSubType()); |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
479 } |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
480 } |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
481 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
482 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
483 TEST(WebServiceParameters, Serialization) |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
484 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
485 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
486 Json::Value v = Json::arrayValue; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
487 v.append("http://localhost:8042/"); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
488 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
489 WebServiceParameters p(v); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
490 ASSERT_FALSE(p.IsAdvancedFormatNeeded()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
491 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
492 Json::Value v2; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
493 p.Serialize(v2, false, true); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
494 ASSERT_EQ(v, v2); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
495 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
496 WebServiceParameters p2(v2); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
497 ASSERT_EQ("http://localhost:8042/", p2.GetUrl()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
498 ASSERT_TRUE(p2.GetUsername().empty()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
499 ASSERT_TRUE(p2.GetPassword().empty()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
500 ASSERT_TRUE(p2.GetCertificateFile().empty()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
501 ASSERT_TRUE(p2.GetCertificateKeyFile().empty()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
502 ASSERT_TRUE(p2.GetCertificateKeyPassword().empty()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
503 ASSERT_FALSE(p2.IsPkcs11Enabled()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
504 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
505 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
506 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
507 Json::Value v = Json::arrayValue; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
508 v.append("http://localhost:8042/"); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
509 v.append("user"); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
510 v.append("pass"); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
511 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
512 WebServiceParameters p(v); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
513 ASSERT_FALSE(p.IsAdvancedFormatNeeded()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
514 ASSERT_EQ("http://localhost:8042/", p.GetUrl()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
515 ASSERT_EQ("user", p.GetUsername()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
516 ASSERT_EQ("pass", p.GetPassword()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
517 ASSERT_TRUE(p.GetCertificateFile().empty()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
518 ASSERT_TRUE(p.GetCertificateKeyFile().empty()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
519 ASSERT_TRUE(p.GetCertificateKeyPassword().empty()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
520 ASSERT_FALSE(p.IsPkcs11Enabled()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
521 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
522 Json::Value v2; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
523 p.Serialize(v2, false, true); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
524 ASSERT_EQ(v, v2); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
525 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
526 p.Serialize(v2, false, false /* no password */); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
527 WebServiceParameters p2(v2); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
528 ASSERT_EQ(Json::arrayValue, v2.type()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
529 ASSERT_EQ(3u, v2.size()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
530 ASSERT_EQ("http://localhost:8042/", v2[0u].asString()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
531 ASSERT_EQ("user", v2[1u].asString()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
532 ASSERT_TRUE(v2[2u].asString().empty()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
533 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
534 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
535 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
536 Json::Value v = Json::arrayValue; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
537 v.append("http://localhost:8042/"); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
538 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
539 WebServiceParameters p(v); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
540 ASSERT_FALSE(p.IsAdvancedFormatNeeded()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
541 p.SetPkcs11Enabled(true); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
542 ASSERT_TRUE(p.IsAdvancedFormatNeeded()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
543 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
544 Json::Value v2; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
545 p.Serialize(v2, false, true); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
546 WebServiceParameters p2(v2); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
547 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
548 ASSERT_EQ(Json::objectValue, v2.type()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
549 ASSERT_EQ(3u, v2.size()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
550 ASSERT_EQ("http://localhost:8042/", v2["Url"].asString()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
551 ASSERT_TRUE(v2["Pkcs11"].asBool()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
552 ASSERT_EQ(Json::objectValue, v2["HttpHeaders"].type()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
553 ASSERT_EQ(0u, v2["HttpHeaders"].size()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
554 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
555 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
556 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
557 Json::Value v = Json::arrayValue; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
558 v.append("http://localhost:8042/"); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
559 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
560 WebServiceParameters p(v); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
561 ASSERT_FALSE(p.IsAdvancedFormatNeeded()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
562 p.SetClientCertificate("a", "b", "c"); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
563 ASSERT_TRUE(p.IsAdvancedFormatNeeded()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
564 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
565 Json::Value v2; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
566 p.Serialize(v2, false, true); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
567 WebServiceParameters p2(v2); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
568 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
569 ASSERT_EQ(Json::objectValue, v2.type()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
570 ASSERT_EQ(6u, v2.size()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
571 ASSERT_EQ("http://localhost:8042/", v2["Url"].asString()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
572 ASSERT_EQ("a", v2["CertificateFile"].asString()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
573 ASSERT_EQ("b", v2["CertificateKeyFile"].asString()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
574 ASSERT_EQ("c", v2["CertificateKeyPassword"].asString()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
575 ASSERT_FALSE(v2["Pkcs11"].asBool()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
576 ASSERT_EQ(Json::objectValue, v2["HttpHeaders"].type()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
577 ASSERT_EQ(0u, v2["HttpHeaders"].size()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
578 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
579 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
580 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
581 Json::Value v = Json::arrayValue; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
582 v.append("http://localhost:8042/"); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
583 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
584 WebServiceParameters p(v); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
585 ASSERT_FALSE(p.IsAdvancedFormatNeeded()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
586 p.AddHttpHeader("a", "b"); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
587 p.AddHttpHeader("c", "d"); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
588 ASSERT_TRUE(p.IsAdvancedFormatNeeded()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
589 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
590 Json::Value v2; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
591 p.Serialize(v2, false, true); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
592 WebServiceParameters p2(v2); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
593 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
594 ASSERT_EQ(Json::objectValue, v2.type()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
595 ASSERT_EQ(3u, v2.size()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
596 ASSERT_EQ("http://localhost:8042/", v2["Url"].asString()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
597 ASSERT_FALSE(v2["Pkcs11"].asBool()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
598 ASSERT_EQ(Json::objectValue, v2["HttpHeaders"].type()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
599 ASSERT_EQ(2u, v2["HttpHeaders"].size()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
600 ASSERT_EQ("b", v2["HttpHeaders"]["a"].asString()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
601 ASSERT_EQ("d", v2["HttpHeaders"]["c"].asString()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
602 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
603 std::set<std::string> a; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
604 p2.ListHttpHeaders(a); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
605 ASSERT_EQ(2u, a.size()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
606 ASSERT_TRUE(a.find("a") != a.end()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
607 ASSERT_TRUE(a.find("c") != a.end()); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
608 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
609 std::string s; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
610 ASSERT_TRUE(p2.LookupHttpHeader(s, "a")); ASSERT_EQ("b", s); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
611 ASSERT_TRUE(p2.LookupHttpHeader(s, "c")); ASSERT_EQ("d", s); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
612 ASSERT_FALSE(p2.LookupHttpHeader(s, "nope")); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
613 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2543
diff
changeset
|
614 } |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
615 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
616 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
617 TEST(WebServiceParameters, UserProperties) |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
618 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
619 Json::Value v = Json::nullValue; |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
620 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
621 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
622 WebServiceParameters p; |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
623 p.SetUrl("http://localhost:8042/"); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
624 ASSERT_FALSE(p.IsAdvancedFormatNeeded()); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
625 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
626 ASSERT_THROW(p.AddUserProperty("Url", "nope"), OrthancException); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
627 p.AddUserProperty("Hello", "world"); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
628 p.AddUserProperty("a", "b"); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
629 ASSERT_TRUE(p.IsAdvancedFormatNeeded()); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
630 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
631 p.Serialize(v, false, true); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
632 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
633 p.ClearUserProperties(); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
634 ASSERT_FALSE(p.IsAdvancedFormatNeeded()); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
635 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
636 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
637 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
638 WebServiceParameters p(v); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
639 ASSERT_TRUE(p.IsAdvancedFormatNeeded()); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
640 ASSERT_TRUE(p.GetHttpHeaders().empty()); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
641 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
642 std::set<std::string> tmp; |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
643 p.ListUserProperties(tmp); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
644 ASSERT_EQ(2u, tmp.size()); |
2824 | 645 ASSERT_TRUE(tmp.find("a") != tmp.end()); |
646 ASSERT_TRUE(tmp.find("Hello") != tmp.end()); | |
647 ASSERT_TRUE(tmp.find("hello") == tmp.end()); | |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
648 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
649 std::string s; |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
650 ASSERT_TRUE(p.LookupUserProperty(s, "a")); ASSERT_TRUE(s == "b"); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
651 ASSERT_TRUE(p.LookupUserProperty(s, "Hello")); ASSERT_TRUE(s == "world"); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
652 ASSERT_FALSE(p.LookupUserProperty(s, "hello")); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
653 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
654 } |
3398
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
655 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
656 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
657 TEST(StringMatcher, Basic) |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
658 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
659 StringMatcher matcher("---"); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
660 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
661 ASSERT_THROW(matcher.GetMatchBegin(), OrthancException); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
662 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
663 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
664 const std::string s = ""; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
665 ASSERT_FALSE(matcher.Apply(s)); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
666 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
667 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
668 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
669 const std::string s = "abc----def"; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
670 ASSERT_TRUE(matcher.Apply(s)); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
671 ASSERT_EQ(3, std::distance(s.begin(), matcher.GetMatchBegin())); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
672 ASSERT_EQ("---", std::string(matcher.GetMatchBegin(), matcher.GetMatchEnd())); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
673 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
674 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
675 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
676 const std::string s = "abc---"; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
677 ASSERT_TRUE(matcher.Apply(s)); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
678 ASSERT_EQ(3, std::distance(s.begin(), matcher.GetMatchBegin())); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
679 ASSERT_EQ(s.end(), matcher.GetMatchEnd()); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
680 ASSERT_EQ("---", std::string(matcher.GetMatchBegin(), matcher.GetMatchEnd())); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
681 ASSERT_EQ("", std::string(matcher.GetMatchEnd(), s.end())); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
682 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
683 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
684 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
685 const std::string s = "abc--def"; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
686 ASSERT_FALSE(matcher.Apply(s)); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
687 ASSERT_THROW(matcher.GetMatchBegin(), OrthancException); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
688 ASSERT_THROW(matcher.GetMatchEnd(), OrthancException); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
689 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
690 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
691 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
692 std::string s(10u, '\0'); // String with null values |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
693 ASSERT_EQ(10u, s.size()); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
694 ASSERT_EQ(10u, s.size()); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
695 ASSERT_FALSE(matcher.Apply(s)); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
696 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
697 s[9] = '-'; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
698 ASSERT_FALSE(matcher.Apply(s)); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
699 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
700 s[8] = '-'; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
701 ASSERT_FALSE(matcher.Apply(s)); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
702 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
703 s[7] = '-'; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
704 ASSERT_TRUE(matcher.Apply(s)); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
705 ASSERT_EQ(s.c_str() + 7, matcher.GetPointerBegin()); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
706 ASSERT_EQ(s.c_str() + 10, matcher.GetPointerEnd()); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
707 ASSERT_EQ(s.end() - 3, matcher.GetMatchBegin()); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
708 ASSERT_EQ(s.end(), matcher.GetMatchEnd()); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
709 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
710 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
711 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
712 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
713 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
714 class MultipartTester : public MultipartStreamReader::IHandler |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
715 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
716 private: |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
717 struct Part |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
718 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
719 MultipartStreamReader::HttpHeaders headers_; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
720 std::string data_; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
721 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
722 Part(const MultipartStreamReader::HttpHeaders& headers, |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
723 const void* part, |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
724 size_t size) : |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
725 headers_(headers), |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
726 data_(reinterpret_cast<const char*>(part), size) |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
727 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
728 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
729 }; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
730 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
731 std::vector<Part> parts_; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
732 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
733 public: |
3399
4e8205871967
OrthancPluginRegisterMultipartRestCallback() is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3398
diff
changeset
|
734 virtual void HandlePart(const MultipartStreamReader::HttpHeaders& headers, |
4e8205871967
OrthancPluginRegisterMultipartRestCallback() is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3398
diff
changeset
|
735 const void* part, |
4e8205871967
OrthancPluginRegisterMultipartRestCallback() is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3398
diff
changeset
|
736 size_t size) |
3398
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
737 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
738 parts_.push_back(Part(headers, part, size)); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
739 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
740 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
741 unsigned int GetCount() const |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
742 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
743 return parts_.size(); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
744 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
745 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
746 MultipartStreamReader::HttpHeaders& GetHeaders(size_t i) |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
747 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
748 return parts_[i].headers_; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
749 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
750 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
751 const std::string& GetData(size_t i) const |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
752 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
753 return parts_[i].data_; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
754 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
755 }; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
756 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
757 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
758 TEST(MultipartStreamReader, ParseHeaders) |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
759 { |
3399
4e8205871967
OrthancPluginRegisterMultipartRestCallback() is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3398
diff
changeset
|
760 std::string ct, b, st, header; |
3398
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
761 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
762 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
763 MultipartStreamReader::HttpHeaders h; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
764 h["hello"] = "world"; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
765 h["Content-Type"] = "world"; // Should be in lower-case |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
766 h["CONTENT-type"] = "world"; // Should be in lower-case |
3399
4e8205871967
OrthancPluginRegisterMultipartRestCallback() is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3398
diff
changeset
|
767 ASSERT_FALSE(MultipartStreamReader::GetMainContentType(header, h)); |
3398
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
768 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
769 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
770 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
771 MultipartStreamReader::HttpHeaders h; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
772 h["content-type"] = "world"; |
3399
4e8205871967
OrthancPluginRegisterMultipartRestCallback() is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3398
diff
changeset
|
773 ASSERT_TRUE(MultipartStreamReader::GetMainContentType(header, h)); |
4e8205871967
OrthancPluginRegisterMultipartRestCallback() is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3398
diff
changeset
|
774 ASSERT_EQ(header, "world"); |
4e8205871967
OrthancPluginRegisterMultipartRestCallback() is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3398
diff
changeset
|
775 ASSERT_FALSE(MultipartStreamReader::ParseMultipartContentType(ct, st, b, header)); |
3398
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
776 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
777 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
778 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
779 MultipartStreamReader::HttpHeaders h; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
780 h["content-type"] = "multipart/related; dummy=value; boundary=1234; hello=world"; |
3399
4e8205871967
OrthancPluginRegisterMultipartRestCallback() is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3398
diff
changeset
|
781 ASSERT_TRUE(MultipartStreamReader::GetMainContentType(header, h)); |
4e8205871967
OrthancPluginRegisterMultipartRestCallback() is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3398
diff
changeset
|
782 ASSERT_EQ(header, h["content-type"]); |
4e8205871967
OrthancPluginRegisterMultipartRestCallback() is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3398
diff
changeset
|
783 ASSERT_TRUE(MultipartStreamReader::ParseMultipartContentType(ct, st, b, header)); |
3398
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
784 ASSERT_EQ(ct, "multipart/related"); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
785 ASSERT_EQ(b, "1234"); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
786 ASSERT_TRUE(st.empty()); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
787 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
788 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
789 { |
3399
4e8205871967
OrthancPluginRegisterMultipartRestCallback() is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3398
diff
changeset
|
790 ASSERT_FALSE(MultipartStreamReader::ParseMultipartContentType |
4e8205871967
OrthancPluginRegisterMultipartRestCallback() is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3398
diff
changeset
|
791 (ct, st, b, "multipart/related; boundary=")); // Empty boundary |
3398
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
792 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
793 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
794 { |
3399
4e8205871967
OrthancPluginRegisterMultipartRestCallback() is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3398
diff
changeset
|
795 ASSERT_TRUE(MultipartStreamReader::ParseMultipartContentType |
4e8205871967
OrthancPluginRegisterMultipartRestCallback() is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3398
diff
changeset
|
796 (ct, st, b, "Multipart/Related; TYPE=Application/Dicom; Boundary=heLLO")); |
3398
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
797 ASSERT_EQ(ct, "multipart/related"); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
798 ASSERT_EQ(b, "heLLO"); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
799 ASSERT_EQ(st, "application/dicom"); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
800 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
801 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
802 { |
3399
4e8205871967
OrthancPluginRegisterMultipartRestCallback() is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3398
diff
changeset
|
803 ASSERT_TRUE(MultipartStreamReader::ParseMultipartContentType |
4e8205871967
OrthancPluginRegisterMultipartRestCallback() is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3398
diff
changeset
|
804 (ct, st, b, "Multipart/Related; type=\"application/DICOM\"; Boundary=a")); |
3398
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
805 ASSERT_EQ(ct, "multipart/related"); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
806 ASSERT_EQ(b, "a"); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
807 ASSERT_EQ(st, "application/dicom"); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
808 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
809 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
810 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
811 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
812 TEST(MultipartStreamReader, BytePerByte) |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
813 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
814 std::string stream = "GARBAGE"; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
815 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
816 std::string boundary = "123456789123456789"; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
817 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
818 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
819 for (size_t i = 0; i < 10; i++) |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
820 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
821 std::string f = "hello " + boost::lexical_cast<std::string>(i); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
822 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
823 stream += "\r\n--" + boundary + "\r\n"; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
824 if (i % 2 == 0) |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
825 stream += "Content-Length: " + boost::lexical_cast<std::string>(f.size()) + "\r\n"; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
826 stream += "Content-Type: toto " + boost::lexical_cast<std::string>(i) + "\r\n\r\n"; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
827 stream += f; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
828 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
829 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
830 stream += "\r\n--" + boundary + "--"; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
831 stream += "GARBAGE"; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
832 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
833 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
834 for (unsigned int k = 0; k < 2; k++) |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
835 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
836 MultipartTester decoded; |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
837 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
838 MultipartStreamReader reader(boundary); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
839 reader.SetBlockSize(1); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
840 reader.SetHandler(decoded); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
841 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
842 if (k == 0) |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
843 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
844 for (size_t i = 0; i < stream.size(); i++) |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
845 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
846 reader.AddChunk(&stream[i], 1); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
847 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
848 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
849 else |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
850 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
851 reader.AddChunk(stream); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
852 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
853 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
854 reader.CloseStream(); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
855 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
856 ASSERT_EQ(10u, decoded.GetCount()); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
857 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
858 for (size_t i = 0; i < 10; i++) |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
859 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
860 ASSERT_EQ("hello " + boost::lexical_cast<std::string>(i), decoded.GetData(i)); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
861 ASSERT_EQ("toto " + boost::lexical_cast<std::string>(i), decoded.GetHeaders(i)["content-type"]); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
862 |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
863 if (i % 2 == 0) |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
864 { |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
865 ASSERT_EQ(2u, decoded.GetHeaders(i).size()); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
866 ASSERT_TRUE(decoded.GetHeaders(i).find("content-length") != decoded.GetHeaders(i).end()); |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
867 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
868 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
869 } |
4acd1431e603
new classes: StringMatcher and MultipartStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
870 } |