Commit bd81bc26 authored by Toni Barzic's avatar Toni Barzic Committed by Commit Bot

Better handling of offline demo sessions

When launching (online enrolled) demo sessions with no connectivity, ARC
provisioning for the demo mode public account will timeout (it will
fail to get the account auth token), and restart the public session.

This CL adds a fallback for demo session when the auth token for the
demo account cannot be fetched - it continues ARC provisioning with
offline demo mode provisioning.

BUG=875504
TEST=Start demo session with no network - ARC successfully provisions,
  and the session is not forcibly restarted

Change-Id: I76fe36cf939a5ac8d34b89f821fc142d2618d7d4
Reviewed-on: https://chromium-review.googlesource.com/1180415
Commit-Queue: Toni Baržić <tbarzic@chromium.org>
Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585308}
parent 5dc384bf
......@@ -365,6 +365,16 @@ void ArcAuthService::OnAuthCodeFetched(bool success,
ArcSessionManager::Get()->auth_context()->full_account_id(),
GetAccountType(profile_), policy_util::IsAccountManaged(profile_)),
mojom::ArcSignInStatus::SUCCESS);
} else if (chromeos::DemoSession::Get() &&
chromeos::DemoSession::Get()->started()) {
// For demo sessions, if auth code fetch failed (e.g. because the device is
// offline), fall back to accountless offline demo mode provisioning.
OnAccountInfoReady(
CreateAccountInfo(true /* is_enforced */, std::string() /* auth_info */,
std::string() /* auth_name */,
mojom::ChromeAccountType::OFFLINE_DEMO_ACCOUNT,
true /* is_managed */),
mojom::ArcSignInStatus::SUCCESS);
} else {
// Send error to ARC.
OnAccountInfoReady(
......
......@@ -393,6 +393,30 @@ IN_PROC_BROWSER_TEST_F(ArcRobotAccountAuthServiceTest, GetOfflineDemoAccount) {
EXPECT_TRUE(auth_instance().account_info()->is_managed);
}
IN_PROC_BROWSER_TEST_F(ArcRobotAccountAuthServiceTest,
GetDemoAccountOnAuthTokenFetchFailure) {
chromeos::DemoSession::SetDemoModeEnrollmentTypeForTesting(
chromeos::DemoSession::EnrollmentType::kOnline);
chromeos::DemoSession::StartIfInDemoMode();
SetAccountAndProfile(user_manager::USER_TYPE_PUBLIC_ACCOUNT);
interceptor()->PushJobCallback(
policy::TestRequestInterceptor::HttpErrorJob("404 Not Found"));
base::RunLoop run_loop;
auth_instance().RequestAccountInfo(run_loop.QuitClosure());
run_loop.Run();
ASSERT_TRUE(auth_instance().account_info());
EXPECT_TRUE(auth_instance().account_info()->account_name.value().empty());
EXPECT_TRUE(auth_instance().account_info()->auth_code.value().empty());
EXPECT_EQ(mojom::ChromeAccountType::OFFLINE_DEMO_ACCOUNT,
auth_instance().account_info()->account_type);
EXPECT_FALSE(auth_instance().account_info()->enrollment_token);
EXPECT_TRUE(auth_instance().account_info()->is_managed);
}
class ArcAuthServiceChildAccountTest : public ArcAuthServiceTest {
protected:
ArcAuthServiceChildAccountTest() = default;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment