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

Unified Diff: http_fetcher_unittest.cc

Issue 4004004: AU: Restrict to HTTPS for official builds. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: Created 10 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | libcurl_http_fetcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: http_fetcher_unittest.cc
diff --git a/http_fetcher_unittest.cc b/http_fetcher_unittest.cc
index bd167685c6bfa7d473460b273528961b36465fac..6c420a0b513266def80515303ebb39f9deecde5d 100644
--- a/http_fetcher_unittest.cc
+++ b/http_fetcher_unittest.cc
@@ -136,6 +136,7 @@ class HttpFetcherTest<LibcurlHttpFetcher> : public ::testing::Test {
ret->set_idle_seconds(1);
ret->set_retry_seconds(1);
ret->SetConnectionAsExpensive(false);
+ ret->SetBuildType(false);
return ret;
}
HttpFetcher* NewSmallFetcher() {
@@ -169,6 +170,8 @@ class HttpFetcherTest<MultiHttpFetcher<LibcurlHttpFetcher> >
// Speed up test execution.
ret->set_idle_seconds(1);
ret->set_retry_seconds(1);
+ ret->SetConnectionAsExpensive(false);
+ ret->SetBuildType(false);
return ret;
}
bool IsMulti() const { return true; }
@@ -613,6 +616,8 @@ void MultiTest(HttpFetcher* fetcher_in,
dynamic_cast<MultiHttpFetcher<LibcurlHttpFetcher>*>(fetcher.get());
ASSERT_TRUE(multi_fetcher);
multi_fetcher->set_ranges(ranges);
+ multi_fetcher->SetConnectionAsExpensive(false);
+ multi_fetcher->SetBuildType(false);
fetcher->set_delegate(&delegate);
StartTransferArgs start_xfer_args = {fetcher.get(), url};
@@ -698,7 +703,7 @@ TYPED_TEST(HttpFetcherTest, MultiHttpFetcherInsufficientTest) {
}
namespace {
-class ExpensiveConnectionTestDelegate : public HttpFetcherDelegate {
+class BlockedTransferTestDelegate : public HttpFetcherDelegate {
public:
virtual void ReceivedBytes(HttpFetcher* fetcher,
const char* bytes, int length) {
@@ -713,28 +718,37 @@ class ExpensiveConnectionTestDelegate : public HttpFetcherDelegate {
} // namespace
-TYPED_TEST(HttpFetcherTest, ExpensiveConnectionTest) {
+TYPED_TEST(HttpFetcherTest, BlockedTransferTest) {
if (this->IsMock() || this->IsMulti())
return;
- typename TestFixture::HttpServer server;
-
- ASSERT_TRUE(server.started_);
- GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE);
- ExpensiveConnectionTestDelegate delegate;
- delegate.loop_ = loop;
+ for (int i = 0; i < 2; i++) {
+ typename TestFixture::HttpServer server;
- scoped_ptr<HttpFetcher> fetcher(this->NewLargeFetcher());
- dynamic_cast<LibcurlHttpFetcher*>(
- fetcher.get())->SetConnectionAsExpensive(true);
- fetcher->set_delegate(&delegate);
+ ASSERT_TRUE(server.started_);
- StartTransferArgs start_xfer_args =
- { fetcher.get(), LocalServerUrlForPath(this->SmallUrl()) };
+ GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE);
+ BlockedTransferTestDelegate delegate;
+ delegate.loop_ = loop;
- g_timeout_add(0, StartTransfer, &start_xfer_args);
- g_main_loop_run(loop);
- g_main_loop_unref(loop);
+ scoped_ptr<HttpFetcher> fetcher(this->NewLargeFetcher());
+ LibcurlHttpFetcher* curl_fetcher =
+ dynamic_cast<LibcurlHttpFetcher*>(fetcher.get());
+ bool is_expensive_connection = (i == 0);
+ bool is_official_build = (i == 1);
+ LOG(INFO) << "is_expensive_connection: " << is_expensive_connection;
+ LOG(INFO) << "is_official_build: " << is_official_build;
+ curl_fetcher->SetConnectionAsExpensive(is_expensive_connection);
+ curl_fetcher->SetBuildType(is_official_build);
+ fetcher->set_delegate(&delegate);
+
+ StartTransferArgs start_xfer_args =
+ { fetcher.get(), LocalServerUrlForPath(this->SmallUrl()) };
+
+ g_timeout_add(0, StartTransfer, &start_xfer_args);
+ g_main_loop_run(loop);
+ g_main_loop_unref(loop);
+ }
}
} // namespace chromeos_update_engine
« no previous file with comments | « no previous file | libcurl_http_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698