Skip to content

Commit 160831b

Browse files
authored
chore: update conformance test (#3980)
This fixes #3943. Update to commit googleapis/conformance-tests@dfdfff5
1 parent 6a05c4c commit 160831b

File tree

5 files changed

+86
-75
lines changed

5 files changed

+86
-75
lines changed

google/cloud/storage/client_sign_policy_document_test.cc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ TEST_F(CreateSignedPolicyDocTest, SignV4) {
233233
"{\"bucket\":\"travel-maps\"},"
234234
"[\"eq\",\"$Content-Disposition\",\"inline\"],"
235235
"[\"content-length-range\",0,1000000],"
236+
"{\"bucket\":\"test-bucket\"},"
236237
"{\"key\":\"test-object\"},"
237238
"{\"x-goog-date\":\"20100616T111111Z\"},"
238239
"{\"x-goog-credential\":\"[email protected]/"
@@ -243,14 +244,14 @@ TEST_F(CreateSignedPolicyDocTest, SignV4) {
243244
Dec64(actual->policy));
244245

245246
EXPECT_EQ(
246-
"1ad929a8db0f03f6617f20c448998467d048a74ebbd1e794a36eb81d2a99de9b1a173037"
247-
"27e1f5b9793759c35bb3449f6bf496c384e8d62b079d9fa8acc2646ec2638697f9a83fef"
248-
"aa5c44cc1877bfa0cd590003ccfc958cc29bed4fb5467a32063221eb0bfa6e27107eb43e"
249-
"c7d6c70da40ac7e86d70410ed6ef53d3a8da3a072b781b83dd285bb8d57e07f1acc27d13"
250-
"98193ae09baee4f6331b67df91bd3e7f745cd772a660378128f5ea21fa0613adbe17b68a"
251-
"844c8783e725de9927dc3da183bbd6a908971eef946c240bfdafc8c0b728b312b969871a"
252-
"1efe7820f5bd362d03c953005e48c9dc50cc82d54613208aee82fcae4d6e27fd5dd8d33d"
253-
"3fd3735e",
247+
"25b5ef60e9d80fc94ac8c0d94bb8533b6d59de07371091ecf3f698cf465c8d54240a60bf"
248+
"39840c3e1133d3d07345842809ee97e809a73a801b20ad1a6bcb4d2fb8dfd796b99a85c5"
249+
"8dde9f76f28d4724543bad012b6f69fd822179c338852d717272313456b895ca95303ced"
250+
"6fbdee01e23f983df8a594b23a6977b24ff5027a3b491ef2c54fb008cac1eccec15da422"
251+
"fb6422722edad8e4208e82f8bee82e095441b22a721b8a1d64139958d3fa91739244b203"
252+
"62998a73258afc68b1bf7bdb9cbeec392829a401e186ec6fb810f647b502005b1742d333"
253+
"421393b555fc1446f5c6e2b715054f1dd6abbc21b5aade89f17de8edcbae9720bc4bfcb7"
254+
"ace38d22",
254255
actual->signature);
255256

256257
EXPECT_EQ("GOOG4-RSA-SHA256", actual->signing_algorithm);

google/cloud/storage/internal/policy_document_request.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ std::vector<PolicyDocumentCondition> PolicyDocumentV4Request::GetAllConditions()
228228
auto const& document = policy_document();
229229
std::copy(document.conditions.begin(), document.conditions.end(),
230230
std::back_inserter(conditions));
231+
conditions.push_back(PolicyDocumentCondition({"bucket", document.bucket}));
231232
conditions.push_back(PolicyDocumentCondition({"key", document.object}));
232233
conditions.push_back(PolicyDocumentCondition(
233234
{"x-goog-date", google::cloud::internal::FormatV4SignedUrlTimestamp(
@@ -252,6 +253,10 @@ std::map<std::string, std::string> PolicyDocumentV4Request::RequiredFormFields()
252253
std::map<std::string, std::string> res;
253254
for (auto const& condition : GetAllConditions()) {
254255
auto const& elements = condition.elements();
256+
// According to conformance tests, bucket should not be present.
257+
if (elements.size() == 2 && elements[0] == "bucket") {
258+
continue;
259+
}
255260
if (elements.size() == 2) {
256261
res[elements[0]] = elements[1];
257262
continue;

google/cloud/storage/internal/policy_document_request_test.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ TEST(PolicyDocumentV4Request, Printing) {
9090
std::stringstream stream;
9191
stream << req;
9292
EXPECT_EQ(
93-
"PolicyDocumentRequest={{\"conditions\":[{\"key\":\"test-object\"},{\"x-"
94-
"goog-date\":\"20100616T111111Z\"},{\"x-goog-credential\":\"/20100616/"
95-
"auto/storage/"
93+
"PolicyDocumentRequest={{\"conditions\":[{\"bucket\":\"test-bucket\"},{"
94+
"\"key\":\"test-object\"},{\"x-goog-date\":\"20100616T111111Z\"},{\"x-"
95+
"goog-credential\":\"/20100616/auto/storage/"
9696
"goog4_request\"},{\"x-goog-algorithm\":\"GOOG4-RSA-SHA256\"}],"
9797
"\"expiration\":\"2010-06-16T11:11:24Z\"}}",
9898
stream.str());
@@ -115,7 +115,6 @@ TEST(PolicyDocumentV4Request, RequiredFormFields) {
115115
std::map<std::string, std::string> expected_fields{
116116
{"Content-Type", "image/jpeg"},
117117
{"acl", "bucket-owner-read"},
118-
{"bucket", "travel-maps"},
119118
{"key", "test-object"},
120119
{"x-goog-algorithm", "GOOG4-RSA-SHA256"},
121120
{"x-goog-credential", "/20100616/auto/storage/goog4_request"},

google/cloud/storage/tests/signed_url_conformance_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ TEST_P(V4SignedUrlConformanceTest, V4SignJson) {
118118
}
119119
std::string const date = j_obj["timestamp"];
120120
auto const valid_for =
121-
std::chrono::seconds(std::stoi(j_obj["expiration"].get<std::string>()));
121+
std::chrono::seconds(internal::ParseIntField(j_obj, "expiration"));
122122
std::string const expected = j_obj["expectedUrl"];
123123
std::string const expected_canonical_request =
124124
j_obj["expectedCanonicalRequest"];

0 commit comments

Comments
 (0)