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

Unified Diff: chrome/browser/chromeos/arc/auth/arc_active_directory_enrollment_token_fetcher_browsertest.cc

Issue 2705213002: Show different error message if ARC is disabled. (Closed)
Patch Set: Fix browsertests and add a new test for 904 Arc Disabled Created 3 years, 10 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
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 d643cfda603fd55b8b4f1efc23ef714a82bba1cd..e8f268a70daa100da3760d13b8a1341eef5fe8b3 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"
@@ -158,15 +159,19 @@ class ArcActiveDirectoryEnrollmentTokenFetcherBrowserTest
static void FetchEnrollmentToken(
arc::ArcActiveDirectoryEnrollmentTokenFetcher* fetcher,
+ arc::ArcAuthInfoFetchStatus* 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::ArcAuthInfoFetchStatus* output_fetch_status,
+ std::string* output_enrollment_token, base::RunLoop* run_loop,
+ arc::ArcAuthInfoFetchStatus 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.
@@ -190,9 +195,13 @@ IN_PROC_BROWSER_TEST_F(ArcActiveDirectoryEnrollmentTokenFetcherBrowserTest,
StoreCorrectDmToken();
std::string enrollment_token;
+ arc::ArcAuthInfoFetchStatus fetch_status = arc::ArcAuthInfoFetchStatus::SIZE;
+
auto token_fetcher =
base::MakeUnique<arc::ArcActiveDirectoryEnrollmentTokenFetcher>();
- FetchEnrollmentToken(token_fetcher.get(), &enrollment_token);
+ FetchEnrollmentToken(token_fetcher.get(), &fetch_status, &enrollment_token);
+
+ EXPECT_EQ(arc::ArcAuthInfoFetchStatus::SUCCESS, fetch_status);
EXPECT_EQ(kFakeEnrollmentToken, enrollment_token);
}
@@ -210,10 +219,13 @@ 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::ArcAuthInfoFetchStatus fetch_status = arc::ArcAuthInfoFetchStatus::SIZE;
+
auto token_fetcher =
base::MakeUnique<arc::ArcActiveDirectoryEnrollmentTokenFetcher>();
- FetchEnrollmentToken(token_fetcher.get(), &enrollment_token);
+ FetchEnrollmentToken(token_fetcher.get(), &fetch_status, &enrollment_token);
+ EXPECT_EQ(arc::ArcAuthInfoFetchStatus::FAILURE, fetch_status);
EXPECT_EQ(std::string(), enrollment_token);
}
@@ -228,9 +240,33 @@ 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::ArcAuthInfoFetchStatus fetch_status = arc::ArcAuthInfoFetchStatus::SIZE;
+
+ auto token_fetcher =
+ base::MakeUnique<arc::ArcActiveDirectoryEnrollmentTokenFetcher>();
+ FetchEnrollmentToken(token_fetcher.get(), &fetch_status, &enrollment_token);
+
+ EXPECT_EQ(arc::ArcAuthInfoFetchStatus::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::ArcAuthInfoFetchStatus fetch_status = arc::ArcAuthInfoFetchStatus::SIZE;
+
auto token_fetcher =
base::MakeUnique<arc::ArcActiveDirectoryEnrollmentTokenFetcher>();
- FetchEnrollmentToken(token_fetcher.get(), &enrollment_token);
+ FetchEnrollmentToken(token_fetcher.get(), &fetch_status, &enrollment_token);
+ EXPECT_EQ(arc::ArcAuthInfoFetchStatus::ARC_DISABLED, fetch_status);
EXPECT_EQ(std::string(), enrollment_token);
}

Powered by Google App Engine
This is Rietveld 408576698