Chromium Code Reviews| Index: net/spdy/spdy_network_transaction_unittest.cc |
| diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc |
| index 780d1476be378b625414c9241b666c6a3a76b311..451a15caa3085647f8da6928f55080849d5b6813 100644 |
| --- a/net/spdy/spdy_network_transaction_unittest.cc |
| +++ b/net/spdy/spdy_network_transaction_unittest.cc |
| @@ -12,6 +12,7 @@ |
| #include "base/memory/scoped_vector.h" |
| #include "base/run_loop.h" |
| #include "base/stl_util.h" |
| +#include "base/test/test_file_util.h" |
| #include "net/base/auth.h" |
| #include "net/base/net_log_unittest.h" |
| #include "net/base/request_priority.h" |
| @@ -459,6 +460,33 @@ class SpdyNetworkTransactionTest |
| return google_post_request_; |
| } |
| + const HttpRequestInfo& CreateUnreadableFilePostRequest() { |
| + if (google_post_request_initialized_) |
| + return google_post_request_; |
| + |
| + base::FilePath file_path; |
| + CHECK(file_util::CreateTemporaryFileInDir(temp_dir_.path(), &file_path)); |
| + CHECK_EQ(static_cast<int>(kUploadDataSize), |
| + file_util::WriteFile(file_path, kUploadData, kUploadDataSize)); |
| + CHECK(file_util::MakeFileUnreadable(file_path)); |
| + |
| + ScopedVector<UploadElementReader> element_readers; |
| + element_readers.push_back( |
| + new UploadFileElementReader(base::MessageLoopProxy::current().get(), |
| + file_path, |
| + 0, |
| + kUploadDataSize, |
| + base::Time())); |
| + upload_data_stream_.reset( |
| + new UploadDataStream(element_readers.Pass(), 0)); |
| + |
| + google_post_request_.method = "POST"; |
| + google_post_request_.url = GURL(kDefaultURL); |
| + google_post_request_.upload_data_stream = upload_data_stream_.get(); |
| + google_post_request_initialized_ = true; |
| + return google_post_request_; |
| + } |
| + |
| const HttpRequestInfo& CreateComplexPostRequest() { |
| if (!google_post_request_initialized_) { |
| const int kFileRangeOffset = 1; |
| @@ -1785,6 +1813,31 @@ TEST_P(SpdyNetworkTransactionTest, FilePost) { |
| EXPECT_EQ("hello!", out.response_data); |
| } |
| +// Test that a POST with a unreadable file fails. |
| +TEST_P(SpdyNetworkTransactionTest, UnreadableFilePost) { |
| + scoped_ptr<SpdyFrame> req( |
| + spdy_util_.ConstructSpdyPost( |
| + kRequestUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); |
| + MockWrite writes[] = { |
| + CreateMockWrite(*req), |
|
mmenke
2013/11/07 20:29:00
I believe this can just be NULL, too? Since we ca
mmenke
2013/11/07 21:55:51
(To make it NULL, best to just get rid of writes c
tzik
2013/11/11 04:03:04
Done.
tzik
2013/11/11 04:03:04
Passing empty writes and using StaticSocketDataPro
|
| + }; |
| + MockRead reads[] = { |
| + MockRead(ASYNC, 0, 0) // EOF |
| + }; |
| + |
| + DelayedSocketData data(2, reads, arraysize(reads), writes, arraysize(writes)); |
|
mmenke
2013/11/07 21:55:51
I believe this can just be a StaticSocketDataProvi
tzik
2013/11/11 05:33:52
Using it causes hang around line 213. (see reply a
|
| + NormalSpdyTransactionHelper helper(CreateUnreadableFilePostRequest(), |
| + DEFAULT_PRIORITY, |
| + BoundNetLog(), GetParam(), NULL); |
| + helper.RunPreTestSetup(); |
| + helper.AddData(&data); |
| + helper.RunDefaultTest(); |
| + |
| + base::RunLoop().RunUntilIdle(); |
| + helper.VerifyDataNotConsumed(); |
| + EXPECT_EQ(ERR_ACCESS_DENIED, helper.output().rv); |
| +} |
| + |
| // Test that a complex POST works. |
| TEST_P(SpdyNetworkTransactionTest, ComplexPost) { |
| scoped_ptr<SpdyFrame> req( |