buffet: CheckDeviceRegistered works offline

CheckDeviceRegistered previously worked differently if buffet had never
been online vs if it just went offline. Basically it should just care if
the device_reg_info file has a registration configured. Specifically
it shouldn't try to refresh the access_token.

BUG=brillo:785
TEST=FEATURES=test emerge-$BOARD buffet

Change-Id: I7da25f7e9507a131a37fd16efeb2e8e7352985b8
Reviewed-on: https://chromium-review.googlesource.com/264792
Reviewed-by: Nathan Bullock <nathanbullock@google.com>
Tested-by: Nathan Bullock <nathanbullock@google.com>
Commit-Queue: Nathan Bullock <nathanbullock@google.com>
diff --git a/buffet/device_registration_info_unittest.cc b/buffet/device_registration_info_unittest.cc
index 7e09cfd..4d1279b 100644
--- a/buffet/device_registration_info_unittest.cc
+++ b/buffet/device_registration_info_unittest.cc
@@ -170,10 +170,16 @@
   static bool Save(DeviceRegistrationInfo* info) {
     return info->Save();
   }
+
   static void PublishCommands(DeviceRegistrationInfo* info,
                               const base::ListValue& commands) {
     return info->PublishCommands(commands);
   }
+
+  static bool CheckRegistration(DeviceRegistrationInfo* info,
+                                chromeos::ErrorPtr* error) {
+    return info->CheckRegistration(error);
+  }
 };
 
 class DeviceRegistrationInfoTest : public ::testing::Test {
@@ -274,7 +280,8 @@
 
 TEST_F(DeviceRegistrationInfoTest, CheckRegistration) {
   EXPECT_TRUE(dev_reg_->Load());
-  EXPECT_FALSE(dev_reg_->CheckRegistration(nullptr));
+  EXPECT_FALSE(DeviceRegistrationInfo::TestHelper::CheckRegistration(
+      dev_reg_.get(), nullptr));
   EXPECT_EQ(0, transport_->GetRequestCount());
 
   SetDefaultDeviceRegistration(&data_);
@@ -285,7 +292,8 @@
                          chromeos::http::request_type::kPost,
                          base::Bind(OAuth2Handler));
   transport_->ResetRequestCount();
-  EXPECT_TRUE(dev_reg_->CheckRegistration(nullptr));
+  EXPECT_TRUE(DeviceRegistrationInfo::TestHelper::CheckRegistration(
+      dev_reg_.get(), nullptr));
   EXPECT_EQ(1, transport_->GetRequestCount());
 }
 
@@ -300,7 +308,8 @@
                          base::Bind(OAuth2HandlerFail));
   transport_->ResetRequestCount();
   chromeos::ErrorPtr error;
-  EXPECT_FALSE(dev_reg_->CheckRegistration(&error));
+  EXPECT_FALSE(DeviceRegistrationInfo::TestHelper::CheckRegistration(
+      dev_reg_.get(), &error));
   EXPECT_EQ(1, transport_->GetRequestCount());
   EXPECT_TRUE(error->HasError(buffet::kErrorDomainOAuth2,
                               "unable_to_authenticate"));
@@ -318,7 +327,8 @@
                          base::Bind(OAuth2HandlerDeregister));
   transport_->ResetRequestCount();
   chromeos::ErrorPtr error;
-  EXPECT_FALSE(dev_reg_->CheckRegistration(&error));
+  EXPECT_FALSE(DeviceRegistrationInfo::TestHelper::CheckRegistration(
+      dev_reg_.get(), &error));
   EXPECT_EQ(1, transport_->GetRequestCount());
   EXPECT_TRUE(error->HasError(buffet::kErrorDomainOAuth2,
                               "invalid_grant"));