Skip to content

Commit c136d25

Browse files
authored
Merge pull request #274 from offa/update_cpr
Update cpr v1.11.0
2 parents 9c1c84e + e86f0da commit c136d25

File tree

4 files changed

+8
-44
lines changed

4 files changed

+8
-44
lines changed

conanfile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class InfluxdbCxxConan(ConanFile):
1717
}
1818

1919
def requirements(self):
20-
self.requires("cpr/1.10.5")
20+
self.requires("cpr/1.11.0")
2121
if not self.options.system and self.options.boost:
2222
self.requires("boost/1.85.0")
2323
if self.options.tests:

script/ci_testdeploy.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ conan install \
2222
--build=missing \
2323
-s build_type=${BUILD_TYPE} \
2424
-s compiler.cppstd=20 \
25-
--requires=cpr/1.10.0
25+
--requires=cpr/1.11.0
2626

2727
cmake -DCMAKE_TOOLCHAIN_FILE=./conan_toolchain.cmake -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" "$@" ..
2828
cmake --build . -j

test/HttpTest.cxx

+6-5
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ namespace influxdb::test
9393
{
9494
auto http = createHttp();
9595

96-
REQUIRE_CALL(sessionMock, Post()).RETURN(createResponse(cpr::ErrorCode::INTERNAL_ERROR, cpr::status::HTTP_OK));
96+
REQUIRE_CALL(sessionMock, Post()).RETURN(createResponse(cpr::ErrorCode::SEND_ERROR, cpr::status::HTTP_OK));
9797
ALLOW_CALL(sessionMock, SetUrl(_));
9898
ALLOW_CALL(sessionMock, UpdateHeader(_));
9999
ALLOW_CALL(sessionMock, SetBody(_));
@@ -144,7 +144,7 @@ namespace influxdb::test
144144
{
145145
auto http = createHttp();
146146

147-
REQUIRE_CALL(sessionMock, Get()).RETURN(createResponse(cpr::ErrorCode::CONNECTION_FAILURE, cpr::status::HTTP_OK));
147+
REQUIRE_CALL(sessionMock, Get()).RETURN(createResponse(cpr::ErrorCode::COULDNT_CONNECT, cpr::status::HTTP_OK));
148148
ALLOW_CALL(sessionMock, SetUrl(_));
149149
ALLOW_CALL(sessionMock, SetParameters(_));
150150

@@ -188,7 +188,7 @@ namespace influxdb::test
188188
{
189189
auto http = createHttp();
190190

191-
REQUIRE_CALL(sessionMock, Post()).RETURN(createResponse(cpr::ErrorCode::INTERNAL_ERROR, cpr::status::HTTP_OK));
191+
REQUIRE_CALL(sessionMock, Post()).RETURN(createResponse(cpr::ErrorCode::UNKNOWN_ERROR, cpr::status::HTTP_OK));
192192
ALLOW_CALL(sessionMock, SetUrl(_));
193193
ALLOW_CALL(sessionMock, SetParameters(_));
194194

@@ -243,10 +243,11 @@ namespace influxdb::test
243243

244244
TEST_CASE("Set proxy with authentication", "[HttpTest]")
245245
{
246+
using namespace std::string_literals;
246247
auto http = createHttp();
247248

248249
REQUIRE_CALL(sessionMock, SetProxies(_)).WITH(_1["http"] == std::string{"https://auth-proxy-server:1234"} && _1["https"] == std::string{"https://auth-proxy-server:1234"});
249-
REQUIRE_CALL(sessionMock, SetProxyAuth(_)).WITH(_1["http"] == std::string{"abc:def"} && _1["https"] == std::string{"abc:def"});
250+
REQUIRE_CALL(sessionMock, SetProxyAuth(_)).WITH(_1.GetUsername("http") == "abc"s && _1.GetPassword("http") == "def"s && _1.GetUsername("https") == "abc"s && _1.GetPassword("https") == "def"s);
250251

251252
http.setProxy(Proxy{"https://auth-proxy-server:1234", Proxy::Auth{"abc", "def"}});
252253
}
@@ -288,7 +289,7 @@ namespace influxdb::test
288289
{
289290
auto http = createHttp();
290291

291-
REQUIRE_CALL(sessionMock, Get()).RETURN(createResponse(cpr::ErrorCode::CONNECTION_FAILURE, cpr::status::HTTP_OK));
292+
REQUIRE_CALL(sessionMock, Get()).RETURN(createResponse(cpr::ErrorCode::COULDNT_CONNECT, cpr::status::HTTP_OK));
292293
ALLOW_CALL(sessionMock, SetUrl(_));
293294
ALLOW_CALL(sessionMock, SetParameters(_));
294295

test/mock/CprMock.cxx

-37
Original file line numberDiff line numberDiff line change
@@ -115,37 +115,16 @@ namespace cpr
115115
influxdb::test::sessionMock.UpdateHeader(header);
116116
}
117117

118-
Parameters::Parameters(const std::initializer_list<Parameter>& parameters)
119-
: CurlContainer<Parameter>(parameters)
120-
{
121-
}
122-
123118
Proxies::Proxies(const std::initializer_list<std::pair<const std::string, std::string>>& hosts)
124119
: hosts_{hosts}
125120
{
126121
}
127122

128-
Authentication::~Authentication() noexcept = default;
129-
130-
131123
bool CaseInsensitiveCompare::operator()([[maybe_unused]] const std::string& a, [[maybe_unused]] const std::string& b) const noexcept
132124
{
133125
return false;
134126
}
135127

136-
std::string util::urlEncode(const std::string& s)
137-
{
138-
return s;
139-
}
140-
141-
CurlHolder::CurlHolder() = default;
142-
CurlHolder::~CurlHolder() = default;
143-
144-
const char* Authentication::GetAuthString() const noexcept
145-
{
146-
return auth_string_.c_str();
147-
}
148-
149128
const std::string& Proxies::operator[](const std::string& protocol)
150129
{
151130
if (hosts_.count(protocol) == 0)
@@ -155,20 +134,4 @@ namespace cpr
155134
return hosts_[protocol];
156135
}
157136

158-
const char* ProxyAuthentication::operator[](const std::string& protocol)
159-
{
160-
if (proxyAuth_.count(protocol) == 0)
161-
{
162-
FAIL("ProxyAuthentication: No entry '" << protocol << "' available");
163-
}
164-
return proxyAuth_[protocol].GetAuthString();
165-
}
166-
167-
EncodedAuthentication::~EncodedAuthentication() noexcept = default;
168-
169-
const char* EncodedAuthentication::GetAuthString() const noexcept
170-
{
171-
return auth_string_.c_str();
172-
}
173-
174137
}

0 commit comments

Comments
 (0)