Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: third_party/crashpad/crashpad/util/net/http_multipart_builder_test.cc

Issue 2710663006: Update Crashpad to 4a2043ea65e2641ef1a921801c0aaa15ada02fc7 (Closed)
Patch Set: Update Crashpad to 4a2043ea65e2 Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 builder.SetFormData(kKey2, kValue2); 64 builder.SetFormData(kKey2, kValue2);
65 65
66 const char kKey3[] = "key-three"; 66 const char kKey3[] = "key-three";
67 const char kValue3[] = "More tests"; 67 const char kValue3[] = "More tests";
68 builder.SetFormData(kKey3, kValue3); 68 builder.SetFormData(kKey3, kValue3);
69 69
70 std::unique_ptr<HTTPBodyStream> body(builder.GetBodyStream()); 70 std::unique_ptr<HTTPBodyStream> body(builder.GetBodyStream());
71 ASSERT_TRUE(body.get()); 71 ASSERT_TRUE(body.get());
72 std::string contents = ReadStreamToString(body.get()); 72 std::string contents = ReadStreamToString(body.get());
73 auto lines = SplitCRLF(contents); 73 auto lines = SplitCRLF(contents);
74 ASSERT_EQ(13u, lines.size());
74 auto lines_it = lines.begin(); 75 auto lines_it = lines.begin();
75 76
76 // The first line is the boundary. All subsequent boundaries must match this. 77 // The first line is the boundary. All subsequent boundaries must match this.
77 const std::string& boundary = *lines_it++; 78 const std::string& boundary = *lines_it++;
78 EXPECT_GE(boundary.length(), 1u); 79 EXPECT_GE(boundary.length(), 1u);
79 EXPECT_LE(boundary.length(), 70u); 80 EXPECT_LE(boundary.length(), 70u);
80 81
81 EXPECT_EQ("Content-Disposition: form-data; name=\"key-three\"", *lines_it++); 82 EXPECT_EQ("Content-Disposition: form-data; name=\"key-three\"", *lines_it++);
82 EXPECT_EQ("", *lines_it++); 83 EXPECT_EQ("", *lines_it++);
83 EXPECT_EQ(kValue3, *lines_it++); 84 EXPECT_EQ(kValue3, *lines_it++);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 158
158 TEST(HTTPMultipartBuilder, OverwriteFormDataWithEscapedKey) { 159 TEST(HTTPMultipartBuilder, OverwriteFormDataWithEscapedKey) {
159 HTTPMultipartBuilder builder; 160 HTTPMultipartBuilder builder;
160 const char kKey[] = "a 100% \"silly\"\r\ntest"; 161 const char kKey[] = "a 100% \"silly\"\r\ntest";
161 builder.SetFormData(kKey, "some dummy value"); 162 builder.SetFormData(kKey, "some dummy value");
162 builder.SetFormData(kKey, "overwrite"); 163 builder.SetFormData(kKey, "overwrite");
163 std::unique_ptr<HTTPBodyStream> body(builder.GetBodyStream()); 164 std::unique_ptr<HTTPBodyStream> body(builder.GetBodyStream());
164 ASSERT_TRUE(body.get()); 165 ASSERT_TRUE(body.get());
165 std::string contents = ReadStreamToString(body.get()); 166 std::string contents = ReadStreamToString(body.get());
166 auto lines = SplitCRLF(contents); 167 auto lines = SplitCRLF(contents);
168 ASSERT_EQ(5u, lines.size());
167 auto lines_it = lines.begin(); 169 auto lines_it = lines.begin();
168 170
169 const std::string& boundary = *lines_it++; 171 const std::string& boundary = *lines_it++;
170 EXPECT_GE(boundary.length(), 1u); 172 EXPECT_GE(boundary.length(), 1u);
171 EXPECT_LE(boundary.length(), 70u); 173 EXPECT_LE(boundary.length(), 70u);
172 174
173 EXPECT_EQ( 175 EXPECT_EQ(
174 "Content-Disposition: form-data; name=\"a 100%25 %22silly%22%0d%0atest\"", 176 "Content-Disposition: form-data; name=\"a 100%25 %22silly%22%0d%0atest\"",
175 *lines_it++); 177 *lines_it++);
176 EXPECT_EQ("", *lines_it++); 178 EXPECT_EQ("", *lines_it++);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 "minidump.dmp", 248 "minidump.dmp",
247 ascii_http_body_path, 249 ascii_http_body_path,
248 ""); 250 "");
249 const char kValue2[] = "this is not a file"; 251 const char kValue2[] = "this is not a file";
250 builder.SetFormData("minidump", kValue2); 252 builder.SetFormData("minidump", kValue2);
251 253
252 std::unique_ptr<HTTPBodyStream> body(builder.GetBodyStream()); 254 std::unique_ptr<HTTPBodyStream> body(builder.GetBodyStream());
253 ASSERT_TRUE(body.get()); 255 ASSERT_TRUE(body.get());
254 std::string contents = ReadStreamToString(body.get()); 256 std::string contents = ReadStreamToString(body.get());
255 auto lines = SplitCRLF(contents); 257 auto lines = SplitCRLF(contents);
258 ASSERT_EQ(9u, lines.size());
256 auto lines_it = lines.begin(); 259 auto lines_it = lines.begin();
257 260
258 const std::string& boundary = *lines_it++; 261 const std::string& boundary = *lines_it++;
259 EXPECT_GE(boundary.length(), 1u); 262 EXPECT_GE(boundary.length(), 1u);
260 EXPECT_LE(boundary.length(), 70u); 263 EXPECT_LE(boundary.length(), 70u);
261 264
262 EXPECT_EQ("Content-Disposition: form-data; name=\"minidump\"", *lines_it++); 265 EXPECT_EQ("Content-Disposition: form-data; name=\"minidump\"", *lines_it++);
263 EXPECT_EQ("", *lines_it++); 266 EXPECT_EQ("", *lines_it++);
264 EXPECT_EQ(kValue2, *lines_it++); 267 EXPECT_EQ(kValue2, *lines_it++);
265 268
(...skipping 20 matching lines...) Expand all
286 builder.SetFileAttachment("", "", base::FilePath(), "<>"), ""); 289 builder.SetFileAttachment("", "", base::FilePath(), "<>"), "");
287 // Invalid but safe: 290 // Invalid but safe:
288 builder.SetFileAttachment("", "", base::FilePath(), "0/totally/-invalid.pdf"); 291 builder.SetFileAttachment("", "", base::FilePath(), "0/totally/-invalid.pdf");
289 // Valid and safe: 292 // Valid and safe:
290 builder.SetFileAttachment("", "", base::FilePath(), "application/xml+xhtml"); 293 builder.SetFileAttachment("", "", base::FilePath(), "application/xml+xhtml");
291 } 294 }
292 295
293 } // namespace 296 } // namespace
294 } // namespace test 297 } // namespace test
295 } // namespace crashpad 298 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698