diff --git a/google/cloud/storage/client.h b/google/cloud/storage/client.h index 59fd9dc8dfffc..d8a939407ed9c 100644 --- a/google/cloud/storage/client.h +++ b/google/cloud/storage/client.h @@ -2829,6 +2829,7 @@ class Client { std::string bucket_name, std::string object_name, Options&&... options) { + auto const span = MakeSpan(std::forward(options)...); internal::V2SignUrlRequest request(std::move(verb), std::move(bucket_name), std::move(object_name)); request.set_multiple_options(std::forward(options)...); @@ -2892,6 +2893,7 @@ class Client { std::string bucket_name, std::string object_name, Options&&... options) { + auto const span = MakeSpan(std::forward(options)...); internal::V4SignUrlRequest request(std::move(verb), std::move(bucket_name), std::move(object_name)); request.set_multiple_options(std::forward(options)...); diff --git a/google/cloud/storage/client_sign_url_test.cc b/google/cloud/storage/client_sign_url_test.cc index 6ffbd35679813..49d95d93a95e7 100644 --- a/google/cloud/storage/client_sign_url_test.cc +++ b/google/cloud/storage/client_sign_url_test.cc @@ -27,6 +27,7 @@ namespace storage { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN namespace { +using ::google::cloud::internal::CurrentOptions; using ::google::cloud::storage::testing::canonical_errors::TransientError; using ::testing::HasSubstr; using ::testing::Return; @@ -92,12 +93,15 @@ TEST_F(CreateSignedUrlTest, V2SignRemote) { EXPECT_CALL(*mock_, SignBlob) .WillOnce(Return(StatusOr(TransientError()))) .WillOnce([&expected_signed_blob](internal::SignBlobRequest const&) { + EXPECT_EQ(CurrentOptions().get(), "a-default"); + EXPECT_EQ(CurrentOptions().get(), "u-p-test"); return make_status_or( internal::SignBlobResponse{"test-key-id", expected_signed_blob}); }); auto client = ClientForMock(); StatusOr actual = - client.CreateV2SignedUrl("GET", "test-bucket", "test-object"); + client.CreateV2SignedUrl("GET", "test-bucket", "test-object", + Options{}.set("u-p-test")); ASSERT_STATUS_OK(actual); EXPECT_THAT(*actual, HasSubstr(expected_signed_blob_safe)); } @@ -235,12 +239,15 @@ TEST_F(CreateSignedUrlTest, V4SignRemote) { EXPECT_CALL(*mock_, SignBlob) .WillOnce(Return(StatusOr(TransientError()))) .WillOnce([&expected_signed_blob](internal::SignBlobRequest const&) { + EXPECT_EQ(CurrentOptions().get(), "a-default"); + EXPECT_EQ(CurrentOptions().get(), "u-p-test"); return make_status_or( internal::SignBlobResponse{"test-key-id", expected_signed_blob}); }); auto client = ClientForMock(); StatusOr actual = - client.CreateV4SignedUrl("GET", "test-bucket", "test-object"); + client.CreateV4SignedUrl("GET", "test-bucket", "test-object", + Options{}.set("u-p-test")); ASSERT_STATUS_OK(actual); EXPECT_THAT(*actual, HasSubstr(expected_signed_blob_hex)); } diff --git a/google/cloud/storage/internal/signed_url_requests.h b/google/cloud/storage/internal/signed_url_requests.h index e6a0229a226f8..6fd63111425de 100644 --- a/google/cloud/storage/internal/signed_url_requests.h +++ b/google/cloud/storage/internal/signed_url_requests.h @@ -146,6 +146,25 @@ class V2SignUrlRequest { } V2SignUrlRequest& set_multiple_options() { return *this; } + template + V2SignUrlRequest& set_multiple_options(google::cloud::Options const&&, + T&&... tail) { + return set_multiple_options(std::forward(tail)...); + } + template + V2SignUrlRequest& set_multiple_options(google::cloud::Options const&, + T&&... tail) { + return set_multiple_options(std::forward(tail)...); + } + template + V2SignUrlRequest& set_multiple_options(google::cloud::Options&&, + T&&... tail) { + return set_multiple_options(std::forward(tail)...); + } + template + V2SignUrlRequest& set_multiple_options(google::cloud::Options&, T&&... tail) { + return set_multiple_options(std::forward(tail)...); + } private: static std::chrono::system_clock::time_point DefaultExpirationTime(); @@ -258,6 +277,25 @@ class V4SignUrlRequest { } V4SignUrlRequest& set_multiple_options() { return *this; } + template + V4SignUrlRequest& set_multiple_options(google::cloud::Options const&&, + T&&... tail) { + return set_multiple_options(std::forward(tail)...); + } + template + V4SignUrlRequest& set_multiple_options(google::cloud::Options const&, + T&&... tail) { + return set_multiple_options(std::forward(tail)...); + } + template + V4SignUrlRequest& set_multiple_options(google::cloud::Options&&, + T&&... tail) { + return set_multiple_options(std::forward(tail)...); + } + template + V4SignUrlRequest& set_multiple_options(google::cloud::Options&, T&&... tail) { + return set_multiple_options(std::forward(tail)...); + } Status Validate();