unity8: initial packaging (!27)
* Mir starts up and is able to display system settings * x86_64 only for now, because at least ubuntu-app-test did not build on aarch64 Based on PureTryOut's work. Getting it to this stage was a huge effort (as it shows in the package count: 111(!)). See the merge request for details. [skip ci]: this won't finish in CI; ollieparanoid made sure that everything builds for x86_64.
This commit is contained in:
parent
7df8828dfb
commit
8c2a95dbe2
111 changed files with 8125 additions and 0 deletions
591
main/net-cpp/0001-Port-to-new-jsoncpp-API.patch
Normal file
591
main/net-cpp/0001-Port-to-new-jsoncpp-API.patch
Normal file
|
@ -0,0 +1,591 @@
|
|||
From 137154eacd98118beef0664d47a2eae82eefd1f0 Mon Sep 17 00:00:00 2001
|
||||
From: Luca Weiss <luca@z3ntu.xyz>
|
||||
Date: Sat, 9 Feb 2019 01:31:42 +0100
|
||||
Subject: [PATCH 1/3] Port to new jsoncpp API
|
||||
|
||||
---
|
||||
tests/http_client_load_test.cpp | 14 +++--
|
||||
tests/http_client_test.cpp | 80 +++++++++++++++++-----------
|
||||
tests/http_streaming_client_test.cpp | 75 +++++++++++++++-----------
|
||||
3 files changed, 99 insertions(+), 70 deletions(-)
|
||||
|
||||
diff --git a/tests/http_client_load_test.cpp b/tests/http_client_load_test.cpp
|
||||
index 79d125b..105c316 100644
|
||||
--- a/tests/http_client_load_test.cpp
|
||||
+++ b/tests/http_client_load_test.cpp
|
||||
@@ -132,10 +132,6 @@ TEST_F(HttpClientLoadTest, async_head_request_for_existing_resource_succeeds)
|
||||
|
||||
auto response_verifier = [](const http::Response& response) -> bool
|
||||
{
|
||||
- // All endpoint data on httpbin.org is JSON encoded.
|
||||
- json::Value root;
|
||||
- json::Reader reader;
|
||||
-
|
||||
// We expect the query to complete successfully
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
|
||||
@@ -159,12 +155,13 @@ TEST_F(HttpClientLoadTest, async_get_request_for_existing_resource_succeeds)
|
||||
{
|
||||
// All endpoint data on httpbin.org is JSON encoded.
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
// We expect the query to complete successfully
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
// Parsing the body of the response as JSON should succeed.
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
// The url field of the payload should equal the original url we requested.
|
||||
EXPECT_EQ(url, root["url"].asString());
|
||||
|
||||
@@ -191,12 +188,13 @@ TEST_F(HttpClientLoadTest, async_post_request_for_existing_resource_succeeds)
|
||||
{
|
||||
// All endpoint data on httpbin.org is JSON encoded.
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
// We expect the query to complete successfully
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
// Parsing the body of the response as JSON should succeed.
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
// The url field of the payload should equal the original url we requested.
|
||||
EXPECT_EQ(payload, root["data"].asString());
|
||||
|
||||
diff --git a/tests/http_client_test.cpp b/tests/http_client_test.cpp
|
||||
index dd37d4f..e7cdd73 100644
|
||||
--- a/tests/http_client_test.cpp
|
||||
+++ b/tests/http_client_test.cpp
|
||||
@@ -144,7 +144,8 @@ TEST(HttpClient, get_request_for_existing_resource_succeeds)
|
||||
|
||||
// All endpoint data on httpbin.org is JSON encoded.
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
// We finally execute the query synchronously and story the response.
|
||||
auto response = request->execute(default_progress_reporter);
|
||||
@@ -152,7 +153,7 @@ TEST(HttpClient, get_request_for_existing_resource_succeeds)
|
||||
// We expect the query to complete successfully
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
// Parsing the body of the response as JSON should succeed.
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
// The url field of the payload should equal the original url we requested.
|
||||
EXPECT_EQ(url, root["url"].asString());
|
||||
}
|
||||
@@ -174,7 +175,8 @@ TEST(HttpClient, get_request_with_custom_headers_for_existing_resource_succeeds)
|
||||
|
||||
// All endpoint data on httpbin.org is JSON encoded.
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
// We finally execute the query synchronously and story the response.
|
||||
auto response = request->execute(default_progress_reporter);
|
||||
@@ -183,7 +185,7 @@ TEST(HttpClient, get_request_with_custom_headers_for_existing_resource_succeeds)
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
|
||||
// Parsing the body of the response as JSON should succeed.
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
|
||||
auto headers = root["headers"];
|
||||
|
||||
@@ -207,7 +209,8 @@ TEST(HttpClient, empty_header_values_are_handled_correctly)
|
||||
|
||||
// All endpoint data on httpbin.org is JSON encoded.
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
// We finally execute the query synchronously and story the response.
|
||||
auto response = request->execute(default_progress_reporter);
|
||||
@@ -216,7 +219,7 @@ TEST(HttpClient, empty_header_values_are_handled_correctly)
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
|
||||
// Parsing the body of the response as JSON should succeed.
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
|
||||
auto headers = root["headers"];
|
||||
EXPECT_EQ(std::string{}, headers["Empty"].asString());
|
||||
@@ -240,7 +243,8 @@ TEST(HttpClient, get_request_for_existing_resource_guarded_by_basic_auth_succeed
|
||||
|
||||
// All endpoint data on httpbin.org is JSON encoded.
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
// We finally execute the query synchronously and story the response.
|
||||
auto response = request->execute(default_progress_reporter);
|
||||
@@ -248,7 +252,7 @@ TEST(HttpClient, get_request_for_existing_resource_guarded_by_basic_auth_succeed
|
||||
// We expect the query to complete successfully
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
// Parsing the body of the response as JSON should succeed.
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
// We expect authentication to work.
|
||||
EXPECT_TRUE(root["authenticated"].asBool());
|
||||
// With the correct user id
|
||||
@@ -274,7 +278,8 @@ TEST(HttpClient, DISABLED_get_request_for_existing_resource_guarded_by_digest_au
|
||||
|
||||
// All endpoint data on httpbin.org is JSON encoded.
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
// We finally execute the query synchronously and story the response.
|
||||
auto response = request->execute(default_progress_reporter);
|
||||
@@ -282,7 +287,7 @@ TEST(HttpClient, DISABLED_get_request_for_existing_resource_guarded_by_digest_au
|
||||
// We expect the query to complete successfully
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
// Parsing the body of the response as JSON should succeed.
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
// We expect authentication to work.
|
||||
EXPECT_TRUE(root["authenticated"].asBool());
|
||||
// With the correct user id
|
||||
@@ -323,12 +328,13 @@ TEST(HttpClient, async_get_request_for_existing_resource_succeeds)
|
||||
|
||||
// All endpoint data on httpbin.org is JSON encoded.
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
// We expect the query to complete successfully
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
// Parsing the body of the response as JSON should succeed.
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
// The url field of the payload should equal the original url we requested.
|
||||
EXPECT_EQ(url, root["url"].asString());
|
||||
|
||||
@@ -362,7 +368,8 @@ TEST(HttpClient, async_get_request_for_existing_resource_guarded_by_basic_authen
|
||||
|
||||
// All endpoint data on httpbin.org is JSON encoded.
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
std::promise<core::net::http::Response> promise;
|
||||
auto future = promise.get_future();
|
||||
@@ -392,7 +399,7 @@ TEST(HttpClient, async_get_request_for_existing_resource_guarded_by_basic_authen
|
||||
// We expect the query to complete successfully
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
// Parsing the body of the response as JSON should succeed.
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
// We expect authentication to work.
|
||||
EXPECT_TRUE(root["authenticated"].asBool());
|
||||
// With the correct user id
|
||||
@@ -416,7 +423,8 @@ TEST(HttpClient, post_request_for_existing_resource_succeeds)
|
||||
|
||||
// All endpoint data on httpbin.org is JSON encoded.
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
// We finally execute the query synchronously and story the response.
|
||||
auto response = request->execute(default_progress_reporter);
|
||||
@@ -424,7 +432,7 @@ TEST(HttpClient, post_request_for_existing_resource_succeeds)
|
||||
// We expect the query to complete successfully
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
// Parsing the body of the response as JSON should succeed.
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
// The url field of the payload should equal the original url we requested.
|
||||
EXPECT_EQ(payload, root["data"].asString());
|
||||
}
|
||||
@@ -451,10 +459,11 @@ TEST(HttpClient, post_form_request_for_existing_resource_succeeds)
|
||||
|
||||
// All endpoint data on httpbin.org is JSON encoded.
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
EXPECT_EQ("test", root["form"]["test"].asString());
|
||||
}
|
||||
|
||||
@@ -476,12 +485,13 @@ TEST(HttpClient, post_request_for_file_with_large_chunk_succeeds)
|
||||
size);
|
||||
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
auto response = request->execute(default_progress_reporter);
|
||||
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
EXPECT_EQ(url, root["url"].asString());
|
||||
}
|
||||
|
||||
@@ -498,12 +508,13 @@ TEST(HttpClient, put_request_for_existing_resource_succeeds)
|
||||
value.size());
|
||||
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
auto response = request->execute(default_progress_reporter);
|
||||
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
EXPECT_EQ(payload.str(), root["data"].asString());
|
||||
}
|
||||
|
||||
@@ -525,12 +536,13 @@ TEST(HttpClient, put_request_for_file_with_large_chunk_succeeds)
|
||||
size);
|
||||
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
auto response = request->execute(default_progress_reporter);
|
||||
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
EXPECT_EQ(url, root["url"].asString());
|
||||
}
|
||||
|
||||
@@ -542,12 +554,13 @@ TEST(HttpClient, del_request_for_existing_resource_succeeds)
|
||||
auto request = client->del(http::Request::Configuration::from_uri_as_string(url));
|
||||
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
auto response = request->execute(default_progress_reporter);
|
||||
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
EXPECT_EQ(url, root["url"].asString());
|
||||
}
|
||||
|
||||
@@ -615,7 +628,8 @@ const char* submit() { return "/v1/submit?key=net-cpp-testing"; }
|
||||
// for API and endpoint documentation.
|
||||
TEST(HttpClient, DISABLED_search_for_location_on_mozillas_location_service_succeeds)
|
||||
{
|
||||
- json::FastWriter writer;
|
||||
+ json::StreamWriterBuilder wbuilder;
|
||||
+ std::unique_ptr<json::StreamWriter> writer(wbuilder.newStreamWriter());
|
||||
json::Value search;
|
||||
json::Value cell;
|
||||
cell["radio"] = "umts";
|
||||
@@ -642,16 +656,17 @@ TEST(HttpClient, DISABLED_search_for_location_on_mozillas_location_service_succe
|
||||
std::string(com::mozilla::services::location::host) +
|
||||
com::mozilla::services::location::resources::v1::search();
|
||||
auto request = client->post(http::Request::Configuration::from_uri_as_string(url),
|
||||
- writer.write(search),
|
||||
+ Json::writeString(wbuilder, search),
|
||||
http::ContentType::json);
|
||||
|
||||
auto response = request->execute(default_progress_reporter);
|
||||
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder rbuilder;
|
||||
+ std::unique_ptr<Json::CharReader> reader(rbuilder.newCharReader());
|
||||
json::Value result;
|
||||
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
- EXPECT_TRUE(reader.parse(response.body, result));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &result, NULL));
|
||||
|
||||
// We cannot be sure that the server has got information for the given
|
||||
// cell and wifi ids. For that, we disable the test.
|
||||
@@ -693,13 +708,14 @@ TEST(HttpClient, DISABLED_submit_of_location_on_mozillas_location_service_succee
|
||||
|
||||
submit["items"].append(item);
|
||||
|
||||
- json::FastWriter writer;
|
||||
+ json::StreamWriterBuilder wbuilder;
|
||||
+ std::unique_ptr<json::StreamWriter> writer(wbuilder.newStreamWriter());
|
||||
auto client = http::make_client();
|
||||
auto url =
|
||||
std::string(com::mozilla::services::location::host) +
|
||||
com::mozilla::services::location::resources::v1::submit();
|
||||
auto request = client->post(http::Request::Configuration::from_uri_as_string(url),
|
||||
- writer.write(submit),
|
||||
+ Json::writeString(wbuilder, submit),
|
||||
http::ContentType::json);
|
||||
auto response = request->execute(default_progress_reporter);
|
||||
|
||||
diff --git a/tests/http_streaming_client_test.cpp b/tests/http_streaming_client_test.cpp
|
||||
index 68ad100..7e9faa1 100644
|
||||
--- a/tests/http_streaming_client_test.cpp
|
||||
+++ b/tests/http_streaming_client_test.cpp
|
||||
@@ -156,7 +156,8 @@ TEST(StreamingHttpClient, get_request_for_existing_resource_succeeds)
|
||||
|
||||
// All endpoint data on httpbin.org is JSON encoded.
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
// We finally execute the query synchronously and story the response.
|
||||
auto response = request->execute(default_progress_reporter, dh->to_data_handler());
|
||||
@@ -164,7 +165,7 @@ TEST(StreamingHttpClient, get_request_for_existing_resource_succeeds)
|
||||
// We expect the query to complete successfully
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
// Parsing the body of the response as JSON should succeed.
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
// The url field of the payload should equal the original url we requested.
|
||||
EXPECT_EQ(url, root["url"].asString());
|
||||
}
|
||||
@@ -191,7 +192,8 @@ TEST(StreamingHttpClient, get_request_with_custom_headers_for_existing_resource_
|
||||
|
||||
// All endpoint data on httpbin.org is JSON encoded.
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
// We finally execute the query synchronously and story the response.
|
||||
auto response = request->execute(default_progress_reporter, dh->to_data_handler());
|
||||
@@ -200,7 +202,7 @@ TEST(StreamingHttpClient, get_request_with_custom_headers_for_existing_resource_
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
|
||||
// Parsing the body of the response as JSON should succeed.
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
|
||||
auto headers = root["headers"];
|
||||
|
||||
@@ -229,7 +231,8 @@ TEST(StreamingHttpClient, empty_header_values_are_handled_correctly)
|
||||
|
||||
// All endpoint data on httpbin.org is JSON encoded.
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
// We finally execute the query synchronously and story the response.
|
||||
auto response = request->execute(default_progress_reporter, dh->to_data_handler());
|
||||
@@ -238,7 +241,7 @@ TEST(StreamingHttpClient, empty_header_values_are_handled_correctly)
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
|
||||
// Parsing the body of the response as JSON should succeed.
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
|
||||
auto headers = root["headers"];
|
||||
EXPECT_EQ(std::string{}, headers["Empty"].asString());
|
||||
@@ -267,7 +270,8 @@ TEST(StreamingHttpClient, get_request_for_existing_resource_guarded_by_basic_aut
|
||||
|
||||
// All endpoint data on httpbin.org is JSON encoded.
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
// We finally execute the query synchronously and story the response.
|
||||
auto response = request->execute(default_progress_reporter, dh->to_data_handler());
|
||||
@@ -275,7 +279,7 @@ TEST(StreamingHttpClient, get_request_for_existing_resource_guarded_by_basic_aut
|
||||
// We expect the query to complete successfully
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
// Parsing the body of the response as JSON should succeed.
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
// We expect authentication to work.
|
||||
EXPECT_TRUE(root["authenticated"].asBool());
|
||||
// With the correct user id
|
||||
@@ -306,7 +310,8 @@ TEST(StreamingHttpClient, DISABLED_get_request_for_existing_resource_guarded_by_
|
||||
|
||||
// All endpoint data on httpbin.org is JSON encoded.
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
// We finally execute the query synchronously and story the response.
|
||||
auto response = request->execute(default_progress_reporter, dh->to_data_handler());
|
||||
@@ -314,7 +319,7 @@ TEST(StreamingHttpClient, DISABLED_get_request_for_existing_resource_guarded_by_
|
||||
// We expect the query to complete successfully
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
// Parsing the body of the response as JSON should succeed.
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
// We expect authentication to work.
|
||||
EXPECT_TRUE(root["authenticated"].asBool());
|
||||
// With the correct user id
|
||||
@@ -361,12 +366,13 @@ TEST(StreamingHttpClient, async_get_request_for_existing_resource_succeeds)
|
||||
|
||||
// All endpoint data on httpbin.org is JSON encoded.
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
// We expect the query to complete successfully
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
// Parsing the body of the response as JSON should succeed.
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
// The url field of the payload should equal the original url we requested.
|
||||
EXPECT_EQ(url, root["url"].asString());
|
||||
|
||||
@@ -405,7 +411,8 @@ TEST(StreamingHttpClient, async_get_request_for_existing_resource_guarded_by_bas
|
||||
|
||||
// All endpoint data on httpbin.org is JSON encoded.
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
std::promise<core::net::http::Response> promise;
|
||||
auto future = promise.get_future();
|
||||
@@ -436,7 +443,7 @@ TEST(StreamingHttpClient, async_get_request_for_existing_resource_guarded_by_bas
|
||||
// We expect the query to complete successfully
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
// Parsing the body of the response as JSON should succeed.
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
// We expect authentication to work.
|
||||
EXPECT_TRUE(root["authenticated"].asBool());
|
||||
// With the correct user id
|
||||
@@ -465,7 +472,8 @@ TEST(StreamingHttpClient, post_request_for_existing_resource_succeeds)
|
||||
|
||||
// All endpoint data on httpbin.org is JSON encoded.
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
// We finally execute the query synchronously and story the response.
|
||||
auto response = request->execute(default_progress_reporter, dh->to_data_handler());
|
||||
@@ -473,7 +481,7 @@ TEST(StreamingHttpClient, post_request_for_existing_resource_succeeds)
|
||||
// We expect the query to complete successfully
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
// Parsing the body of the response as JSON should succeed.
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
// The url field of the payload should equal the original url we requested.
|
||||
EXPECT_EQ(payload, root["data"].asString());
|
||||
}
|
||||
@@ -505,10 +513,11 @@ TEST(StreamingHttpClient, post_form_request_for_existing_resource_succeeds)
|
||||
|
||||
// All endpoint data on httpbin.org is JSON encoded.
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
EXPECT_EQ("test", root["form"]["test"].asString());
|
||||
}
|
||||
|
||||
@@ -536,10 +545,11 @@ TEST(StreamingHttpClient, post_request_for_file_with_large_chunk_succeeds)
|
||||
auto response = request->execute(default_progress_reporter, dh->to_data_handler());
|
||||
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
EXPECT_EQ(url, root["url"].asString());
|
||||
}
|
||||
|
||||
@@ -569,10 +579,11 @@ TEST(StreamingHttpClient, post_request_for_file_with_large_chunk_with_read_callb
|
||||
auto response = request->execute(default_progress_reporter, dh->to_data_handler());
|
||||
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
EXPECT_EQ(url, root["url"].asString());
|
||||
}
|
||||
|
||||
@@ -596,10 +607,11 @@ TEST(StreamingHttpClient, put_request_for_existing_resource_succeeds)
|
||||
auto response = request->execute(default_progress_reporter, dh->to_data_handler());
|
||||
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
EXPECT_EQ(payload.str(), root["data"].asString());
|
||||
}
|
||||
|
||||
@@ -627,10 +639,11 @@ TEST(StreamingHttpClient, put_request_for_file_with_large_chunk_succeeds)
|
||||
auto response = request->execute(default_progress_reporter, dh->to_data_handler());
|
||||
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
EXPECT_EQ(url, root["url"].asString());
|
||||
}
|
||||
|
||||
@@ -660,10 +673,11 @@ TEST(StreamingHttpClient, put_request_for_file_with_large_chunk_with_read_callba
|
||||
auto response = request->execute(default_progress_reporter, dh->to_data_handler());
|
||||
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
EXPECT_EQ(url, root["url"].asString());
|
||||
}
|
||||
|
||||
@@ -682,10 +696,11 @@ TEST(StreamingHttpClient, del_request_for_existing_resource_succeeds)
|
||||
auto response = request->execute(default_progress_reporter, dh->to_data_handler());
|
||||
|
||||
json::Value root;
|
||||
- json::Reader reader;
|
||||
+ json::CharReaderBuilder builder;
|
||||
+ std::unique_ptr<json::CharReader> reader(builder.newCharReader());
|
||||
|
||||
EXPECT_EQ(core::net::http::Status::ok, response.status);
|
||||
- EXPECT_TRUE(reader.parse(response.body, root));
|
||||
+ EXPECT_TRUE(reader->parse(response.body.c_str(), response.body.c_str() + response.body.size(), &root, NULL));
|
||||
EXPECT_EQ(url, root["url"].asString());
|
||||
}
|
||||
|
||||
--
|
||||
2.20.1
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
From e028baabc3627d5d13b9a9db2d096990ce7b7459 Mon Sep 17 00:00:00 2001
|
||||
From: Luca Weiss <luca@z3ntu.xyz>
|
||||
Date: Sat, 9 Feb 2019 01:32:13 +0100
|
||||
Subject: [PATCH 2/3] Don't bundle httpbin, don't fail silently
|
||||
|
||||
---
|
||||
tests/CMakeLists.txt | 4 ----
|
||||
tests/httpbin.h.in | 2 +-
|
||||
tests/httpbin.tar.bz2 | Bin 15383 -> 0 bytes
|
||||
3 files changed, 1 insertion(+), 5 deletions(-)
|
||||
delete mode 100644 tests/httpbin.tar.bz2
|
||||
|
||||
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
|
||||
index a21e322..0fcea99 100644
|
||||
--- a/tests/CMakeLists.txt
|
||||
+++ b/tests/CMakeLists.txt
|
||||
@@ -14,10 +14,6 @@
|
||||
#
|
||||
# Authored by: Thomas Voss <thomas.voss@canonical.com>
|
||||
|
||||
-execute_process(
|
||||
- COMMAND ${CMAKE_COMMAND} -E tar xf ${CMAKE_CURRENT_SOURCE_DIR}/httpbin.tar.bz2
|
||||
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
-
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/httpbin.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/httpbin.h
|
||||
diff --git a/tests/httpbin.h.in b/tests/httpbin.h.in
|
||||
index 30703a2..0010068 100644
|
||||
--- a/tests/httpbin.h.in
|
||||
+++ b/tests/httpbin.h.in
|
||||
@@ -42,7 +42,7 @@ struct Instance
|
||||
Instance()
|
||||
: server
|
||||
{
|
||||
- core::posix::exec("/usr/bin/python", {"@CMAKE_CURRENT_BINARY_DIR@/httpbin/run.py"}, {}, core::posix::StandardStream::stdout | core::posix::StandardStream::stderr)
|
||||
+ core::posix::exec("/usr/bin/python3", {"-c", "from httpbin import app; app.run()"}, {}, core::posix::StandardStream::stdout /*| core::posix::StandardStream::stderr*/)
|
||||
}
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds{1000});
|
||||
|
||||
--
|
||||
2.20.1
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
From 8567cc6014399259bf6efa5574f0ac7e98e70094 Mon Sep 17 00:00:00 2001
|
||||
From: Luca Weiss <luca@z3ntu.xyz>
|
||||
Date: Sat, 9 Feb 2019 01:32:44 +0100
|
||||
Subject: [PATCH 3/3] Set the Content-Type header on POST, otherwise stuff
|
||||
breaks
|
||||
|
||||
---
|
||||
src/core/net/http/impl/curl/client.cpp | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/src/core/net/http/impl/curl/client.cpp b/src/core/net/http/impl/curl/client.cpp
|
||||
index ba68cda..f49ce67 100644
|
||||
--- a/src/core/net/http/impl/curl/client.cpp
|
||||
+++ b/src/core/net/http/impl/curl/client.cpp
|
||||
@@ -158,9 +158,12 @@ std::shared_ptr<http::impl::curl::Request> http::impl::curl::Client::post_impl(
|
||||
const std::string& ct)
|
||||
{
|
||||
::curl::easy::Handle handle;
|
||||
+ http::Header ctheader;
|
||||
+ ctheader.set("Content-Type", ct);
|
||||
handle.method(http::Method::post)
|
||||
.url(configuration.uri.c_str())
|
||||
.header(configuration.header)
|
||||
+ .header(ctheader)
|
||||
.post_data(payload.c_str(), ct);
|
||||
|
||||
handle.set_option(::curl::Option::ssl_verify_host,
|
||||
--
|
||||
2.20.1
|
||||
|
42
main/net-cpp/APKBUILD
Normal file
42
main/net-cpp/APKBUILD
Normal file
|
@ -0,0 +1,42 @@
|
|||
# Maintainer: Luca Weiss <luca@z3ntu.xyz>
|
||||
pkgname=net-cpp
|
||||
pkgver=2.2.1
|
||||
_commit="01fc17e8ce09bcee37e83422520e4c3f26e8c8dd"
|
||||
pkgrel=0
|
||||
pkgdesc="A simple yet beautiful networking API for C++11"
|
||||
url="https://launchpad.net/process-cpp"
|
||||
arch="x86_64"
|
||||
license="LGPL3 GPL3"
|
||||
makedepends="cmake cmake-extras boost-dev curl-dev"
|
||||
checkdepends="gtest-dev gmock process-cpp-dev properties-cpp-dev jsoncpp-dev py3-httpbin"
|
||||
subpackages="$pkgname-dev"
|
||||
source="https://github.com/lib-cpp/net-cpp/archive/$_commit.tar.gz
|
||||
0001-Port-to-new-jsoncpp-API.patch
|
||||
0002-Don-t-bundle-httpbin-don-t-fail-silently.patch
|
||||
0003-Set-the-Content-Type-header-on-POST-otherwise-stuff-.patch"
|
||||
builddir="$srcdir/$pkgname-$_commit"
|
||||
|
||||
build() {
|
||||
mkdir "$builddir"/build
|
||||
cd "$builddir"/build
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_INSTALL_LIBDIR=lib \
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
make
|
||||
}
|
||||
|
||||
check() {
|
||||
cd "$builddir"/build
|
||||
env CTEST_OUTPUT_ON_FAILURE=1 make test
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "$builddir"/build
|
||||
make DESTDIR="$pkgdir/" install
|
||||
}
|
||||
|
||||
sha512sums="b8aa59f6fdb6f2358a7f78845acf1af866186995613daa10a04497c3072dfbc034a552561d76c2d91c6e55b98c41bbf069052ca459531538ada4032a38d09afb 01fc17e8ce09bcee37e83422520e4c3f26e8c8dd.tar.gz
|
||||
2893f20ef1028d016fccf77af6c24dbe1a7967a9e03cadbccc3cde18a0a0eb3b1f8ffb1f1b3afc7d9e4c046fb3b5d6cf907023638dcdb37273dd514c9139c99e 0001-Port-to-new-jsoncpp-API.patch
|
||||
ba4c2737504ddf9475a8a4c01fe31756dbc32d3bfb00c1a10e342cd2f7989cc87466c921d8430ff7003ebf48369d5daeb0ebeefc3d2b1955142d6a35681840e7 0002-Don-t-bundle-httpbin-don-t-fail-silently.patch
|
||||
357669776625f4476feaf76336a976c596572028e165d54eb5078baca42c2f8304e60a3898f4ce0b4494f9a40d303720e539a0da281f5f33159b8576b89d7d71 0003-Set-the-Content-Type-header-on-POST-otherwise-stuff-.patch"
|
Loading…
Add table
Add a link
Reference in a new issue