| Index: chrome/browser/chromeos/arc/auth/arc_active_directory_enrollment_token_fetcher_browsertest.cc
|
| diff --git a/chrome/browser/chromeos/arc/auth/arc_active_directory_enrollment_token_fetcher_browsertest.cc b/chrome/browser/chromeos/arc/auth/arc_active_directory_enrollment_token_fetcher_browsertest.cc
|
| index 1ffaee4856c5aca1aa39ab67e07e4530b92b3672..5f63aa1f16e4a8584e6d753e337a9c0c1b4a2df8 100644
|
| --- a/chrome/browser/chromeos/arc/auth/arc_active_directory_enrollment_token_fetcher_browsertest.cc
|
| +++ b/chrome/browser/chromeos/arc/auth/arc_active_directory_enrollment_token_fetcher_browsertest.cc
|
| @@ -14,6 +14,7 @@
|
| #include "chrome/browser/chromeos/arc/arc_auth_service.h"
|
| #include "chrome/browser/chromeos/arc/arc_session_manager.h"
|
| #include "chrome/browser/chromeos/arc/auth/arc_active_directory_enrollment_token_fetcher.h"
|
| +#include "chrome/browser/chromeos/arc/auth/arc_auth_info_fetcher.h"
|
| #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
|
| #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
|
| #include "chrome/browser/chromeos/policy/dm_token_storage.h"
|
| @@ -164,15 +165,19 @@ class ArcActiveDirectoryEnrollmentTokenFetcherBrowserTest
|
|
|
| static void FetchEnrollmentToken(
|
| arc::ArcActiveDirectoryEnrollmentTokenFetcher* fetcher,
|
| + arc::ArcAuthInfoFetcher::Status* output_fetch_status,
|
| std::string* output_enrollment_token) {
|
| base::RunLoop run_loop;
|
| fetcher->Fetch(base::Bind(
|
| - [](std::string* output_enrollment_token, base::RunLoop* run_loop,
|
| + [](arc::ArcAuthInfoFetcher::Status* output_fetch_status,
|
| + std::string* output_enrollment_token, base::RunLoop* run_loop,
|
| + arc::ArcAuthInfoFetcher::Status fetch_status,
|
| const std::string& enrollment_token) {
|
| + *output_fetch_status = fetch_status;
|
| *output_enrollment_token = enrollment_token;
|
| run_loop->Quit();
|
| },
|
| - output_enrollment_token, &run_loop));
|
| + output_fetch_status, output_enrollment_token, &run_loop));
|
| // Because the Fetch() operation needs to interact with other threads,
|
| // RunUntilIdle() won't work here. Instead, use Run() and Quit() explicitly
|
| // in the callback.
|
| @@ -197,9 +202,14 @@ IN_PROC_BROWSER_TEST_F(ArcActiveDirectoryEnrollmentTokenFetcherBrowserTest,
|
| StoreCorrectDmToken();
|
|
|
| std::string enrollment_token;
|
| + arc::ArcAuthInfoFetcher::Status fetch_status =
|
| + arc::ArcAuthInfoFetcher::Status::FAILURE;
|
| +
|
| auto token_fetcher =
|
| base::MakeUnique<arc::ArcActiveDirectoryEnrollmentTokenFetcher>();
|
| - FetchEnrollmentToken(token_fetcher.get(), &enrollment_token);
|
| + FetchEnrollmentToken(token_fetcher.get(), &fetch_status, &enrollment_token);
|
| +
|
| + EXPECT_EQ(arc::ArcAuthInfoFetcher::Status::SUCCESS, fetch_status);
|
| EXPECT_EQ(kFakeEnrollmentToken, enrollment_token);
|
| }
|
|
|
| @@ -217,10 +227,14 @@ IN_PROC_BROWSER_TEST_F(ArcActiveDirectoryEnrollmentTokenFetcherBrowserTest,
|
| // We expect enrollment_token is empty in this case. So initialize with
|
| // non-empty value.
|
| std::string enrollment_token = "NOT-YET-FETCHED";
|
| + arc::ArcAuthInfoFetcher::Status fetch_status =
|
| + arc::ArcAuthInfoFetcher::Status::SUCCESS;
|
| +
|
| auto token_fetcher =
|
| base::MakeUnique<arc::ArcActiveDirectoryEnrollmentTokenFetcher>();
|
| - FetchEnrollmentToken(token_fetcher.get(), &enrollment_token);
|
| + FetchEnrollmentToken(token_fetcher.get(), &fetch_status, &enrollment_token);
|
|
|
| + EXPECT_EQ(arc::ArcAuthInfoFetcher::Status::FAILURE, fetch_status);
|
| EXPECT_EQ(std::string(), enrollment_token);
|
| }
|
|
|
| @@ -235,9 +249,35 @@ IN_PROC_BROWSER_TEST_F(ArcActiveDirectoryEnrollmentTokenFetcherBrowserTest,
|
| // We expect enrollment_token is empty in this case. So initialize with
|
| // non-empty value.
|
| std::string enrollment_token = "NOT-YET-FETCHED";
|
| + arc::ArcAuthInfoFetcher::Status fetch_status =
|
| + arc::ArcAuthInfoFetcher::Status::SUCCESS;
|
| +
|
| + auto token_fetcher =
|
| + base::MakeUnique<arc::ArcActiveDirectoryEnrollmentTokenFetcher>();
|
| + FetchEnrollmentToken(token_fetcher.get(), &fetch_status, &enrollment_token);
|
| +
|
| + EXPECT_EQ(arc::ArcAuthInfoFetcher::Status::FAILURE, fetch_status);
|
| + EXPECT_EQ(std::string(), enrollment_token);
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(ArcActiveDirectoryEnrollmentTokenFetcherBrowserTest,
|
| + ArcDisabled) {
|
| + interceptor()->PushJobCallback(
|
| + policy::TestRequestInterceptor::HttpErrorJob("904 Arc Disabled"));
|
| +
|
| + // Retrieving the DM token will succeed.
|
| + StoreCorrectDmToken();
|
| +
|
| + // We expect enrollment_token is empty in this case. So initialize with
|
| + // non-empty value.
|
| + std::string enrollment_token = "NOT-YET-FETCHED";
|
| + arc::ArcAuthInfoFetcher::Status fetch_status =
|
| + arc::ArcAuthInfoFetcher::Status::SUCCESS;
|
| +
|
| auto token_fetcher =
|
| base::MakeUnique<arc::ArcActiveDirectoryEnrollmentTokenFetcher>();
|
| - FetchEnrollmentToken(token_fetcher.get(), &enrollment_token);
|
| + FetchEnrollmentToken(token_fetcher.get(), &fetch_status, &enrollment_token);
|
|
|
| + EXPECT_EQ(arc::ArcAuthInfoFetcher::Status::ARC_DISABLED, fetch_status);
|
| EXPECT_EQ(std::string(), enrollment_token);
|
| }
|
|
|