Default to allowing updates when we can't determine the network type.
BUG=None
TEST=Manual -- kill shill.
Change-Id: Ibed384b42ef461d0fb728f587c8e3d15c76a6de1
Reviewed-on: https://chromium-review.googlesource.com/176021
Tested-by: Chris Sosa <sosa@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
diff --git a/http_fetcher_unittest.cc b/http_fetcher_unittest.cc
index 3b3ffe5..140bf81 100644
--- a/http_fetcher_unittest.cc
+++ b/http_fetcher_unittest.cc
@@ -824,6 +824,16 @@
scoped_ptr<HttpFetcher> fetcher(this->test_.NewSmallFetcher());
fetcher->set_delegate(&delegate);
+ // Don't allow connection to server by denying access over ethernet.
+ MockConnectionManager* mock_cm = dynamic_cast<MockConnectionManager*>(
+ fetcher->GetSystemState()->connection_manager());
+ EXPECT_CALL(*mock_cm, GetConnectionType(_,_))
+ .WillRepeatedly(DoAll(SetArgumentPointee<1>(kNetEthernet), Return(true)));
+ EXPECT_CALL(*mock_cm, IsUpdateAllowedOver(kNetEthernet))
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(*mock_cm, StringForConnectionType(kNetEthernet))
+ .WillRepeatedly(Return(shill::kTypeEthernet));
+
StartTransferArgs start_xfer_args = {
fetcher.get(),
LocalServerUrlForPath(0,
@@ -832,7 +842,6 @@
kFlakySleepEvery,
kFlakySleepSecs))
};
-
g_timeout_add(0, StartTransfer, &start_xfer_args);
g_main_loop_run(loop);
diff --git a/libcurl_http_fetcher.cc b/libcurl_http_fetcher.cc
index be49ef3..b5c67e0 100644
--- a/libcurl_http_fetcher.cc
+++ b/libcurl_http_fetcher.cc
@@ -42,8 +42,11 @@
NetworkConnectionType type;
ConcreteDbusGlib dbus_iface;
ConnectionManager* connection_manager = system_state_->connection_manager();
- TEST_AND_RETURN_FALSE(connection_manager->GetConnectionType(&dbus_iface,
- &type));
+ if (!connection_manager->GetConnectionType(&dbus_iface, &type)) {
+ LOG(INFO) << "We could not determine our connection type. "
+ << "Defaulting to allow updates.";
+ return true;
+ }
bool is_allowed = connection_manager->IsUpdateAllowedOver(type);
LOG(INFO) << "We are connected via "
<< connection_manager->StringForConnectionType(type)