Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
strategy:
fail-fast: false
matrix:
osver: [14, 15]
osver: [15]
steps:
- name: Checkout Drogon source code
uses: actions/checkout@v4
Expand Down
8 changes: 8 additions & 0 deletions lib/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ set(COOKIE_SAME_SITE
CookieSameSite.cc
)
add_executable(cookie_same_site ${COOKIE_SAME_SITE})
add_custom_command(
TARGET cookie_same_site POST_BUILD
COMMAND ${CMAKE_COMMAND}
-E
copy_if_different
${PROJECT_SOURCE_DIR}/trantor/trantor/tests/server.crt
${PROJECT_SOURCE_DIR}/trantor/trantor/tests/server.key
${CMAKE_CURRENT_BINARY_DIR})

add_executable(real_ip_resolver RealIpResolverTest.cc)

Expand Down
22 changes: 6 additions & 16 deletions lib/tests/unittests/HttpFileTest.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "../../lib/src/HttpFileImpl.h"
#include <drogon/drogon_test.h>
#include <drogon/HttpAppFramework.h>
#include <drogon/utils/Utilities.h>
#include <filesystem>
#include <fstream>
#if !defined(_WIN32)
Expand Down Expand Up @@ -147,27 +148,16 @@ DROGON_TEST(HttpFileExceptionSafety)
{
// Normal relative paths (not starting with "." or "..") must resolve
// against the configured upload directory (app().getUploadPath()).
struct UploadPathGuard
{
std::string originalPath_{drogon::app().getUploadPath()};

~UploadPathGuard()
{
drogon::app().setUploadPath(originalPath_);
}
} guard;

auto customUploadDir =
filesystem::current_path() / "test_custom_uploads";
filesystem::create_directories(customUploadDir);
drogon::app().setUploadPath(customUploadDir.string());
const auto subdir = "test_relative_upload_" + utils::getUuid();
const auto customUploadDir =
filesystem::path(drogon::app().getUploadPath()) / subdir;

HttpFileImpl file;
file.setFileName("normal_rel.txt");
file.setFile("test", 4);
int res = file.save("custom_sub");
int res = file.save(subdir);
CHECK(res == 0);
auto expectedPath = customUploadDir / "custom_sub" / "normal_rel.txt";
auto expectedPath = customUploadDir / "normal_rel.txt";
CHECK(filesystem::exists(expectedPath));

filesystem::remove_all(customUploadDir);
Expand Down
Loading