Skip to content

Commit

Permalink
Remove HTTP from supported protocols in Downloader
Browse files Browse the repository at this point in the history
  • Loading branch information
OleksandrChaika committed Jul 21, 2023
1 parent f13ee27 commit efa821e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/curl
Submodule curl updated 2767 files
3 changes: 2 additions & 1 deletion src/Download/Downloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,14 @@ namespace {
} else {
curl_easy_setopt(easy_handle, CURLOPT_CAPATH, caPath.c_str());
}
curl_easy_setopt(easy_handle, CURLOPT_SSL_VERIFYPEER, 1);
curl_easy_setopt(easy_handle, CURLOPT_SSL_VERIFYPEER, 1L);
curl_easy_setopt(easy_handle, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(easy_handle, CURLOPT_WRITEDATA, fp);
curl_easy_setopt(easy_handle, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(easy_handle, CURLOPT_PROGRESSDATA, &data);
curl_easy_setopt(easy_handle, CURLOPT_PROGRESSFUNCTION, progress_callback);
curl_easy_setopt(easy_handle, CURLOPT_NOPROGRESS, 0);
curl_easy_setopt(easy_handle, CURLOPT_PROTOCOLS_STR, "https");
CURLcode res = curl_easy_perform(easy_handle);

sua::Logger::debug("curl_easy_perform ended with code = '{}'", res);
Expand Down
25 changes: 22 additions & 3 deletions utest/TestSelfUpdateScenarios.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace {
std::this_thread::sleep_for(1s);
}

void triggerIdentify(const std::string & bundle, const std::string & version) {
void triggerIdentify(const std::string & /*bundle*/, const std::string & version) {
// clang-format off
const std::string json = sua::jsonTemplate(R"(
{
Expand All @@ -119,7 +119,7 @@ namespace {
"config": [
{
"key": "image",
"value": "https://127.0.0.1/bundle"
"value": "{}://127.0.0.1/bundle"
}
]
}
Expand All @@ -131,7 +131,7 @@ namespace {
)");
// clang-format on

execute(sua::IMqttProcessor::TOPIC_IDENTIFY, fmt::format(json, version, bundle));
execute(sua::IMqttProcessor::TOPIC_IDENTIFY, fmt::format(json, version, downloadProtocol));
}

void trigger(const std::string & action) {
Expand Down Expand Up @@ -202,6 +202,8 @@ namespace {
std::string testBrokerHost = "localhost";
int testBrokerPort = 1883;

std::string downloadProtocol = "https";

std::string bundleUnderTest;

std::vector<std::string> visitedStates;
Expand Down Expand Up @@ -409,4 +411,21 @@ namespace {
EXPECT_EQ(sentMessages, expectedMessages);
}

TEST_F(TestSelfUpdateScenarios, downloadFromHTTPFails_endsInFailedState)
{
expectedStates = {"Uninitialized", "Connected", "Downloading", "Failed"};
expectedMessages = {M::SystemVersion, M::Identifying, M::Identified, M::DownloadFailed};

downloadProtocol = "http";

sua.init();
start();

triggerIdentify(BUNDLE_11, "1.2");
trigger(COMMAND_DOWNLOAD);

EXPECT_EQ(visitedStates, expectedStates);
EXPECT_EQ(sentMessages, expectedMessages);
}

}

0 comments on commit efa821e

Please sign in to comment.