5#include <userver/http/common_headers.hpp>
6#include <userver/utest/utest.hpp>
7#include <userver/utils/algo.hpp>
11namespace s3api::api_methods {
13TEST(S3ApiMethods, CopyObject) {
14 const std::string source_bucket =
"source_bucket";
15 const std::string source_key =
"source_key";
16 const std::string dest_bucket =
"dest_bucket";
17 const std::string dest_key =
"dest_key";
18 const std::string content_type =
"application/json";
20 const Request request = CopyObject(source_bucket, source_key, dest_bucket, dest_key, content_type);
21 EXPECT_EQ(request.method, USERVER_NAMESPACE::clients::
http::
HttpMethod::kPut);
22 EXPECT_EQ(request.req, dest_key);
23 EXPECT_EQ(request.bucket, dest_bucket);
24 EXPECT_TRUE(request.body.empty());
25 const std::string* copy_source = USERVER_NAMESPACE::
utils::FindOrNullptr(request.headers, headers::kAmzCopySource);
26 ASSERT_NE(copy_source,
nullptr);
27 EXPECT_EQ(*copy_source, fmt::format(
"/{}/{}", source_bucket, source_key));
30TEST(S3ApiMethods, GetObjectWithRange) {
31 const std::string bucket =
"bucket";
32 const std::string path =
"path";
33 const std::optional<std::string_view> version =
"version";
34 Request request = GetObject(bucket, path, version);
35 SetRange(request,
"Range: bytes=0-100");
36 const std::string expected_value =
"Range: bytes=0-100";
38 USERVER_NAMESPACE::
utils::FindOrNullptr(request.headers, USERVER_NAMESPACE::http::
headers::kRange)->c_str(),
39 expected_value.c_str()