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

Side by Side Diff: chrome/browser/chromeos/login/login_utils_browsertest.cc

Issue 330843002: Make the policy fetch for first time login blocking (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adds comment in LoginUtilTest Created 6 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/login/login_utils.h" 5 #include "chrome/browser/chromeos/login/login_utils.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 std::string device_policy_; 525 std::string device_policy_;
526 std::string user_policy_; 526 std::string user_policy_;
527 527
528 DISALLOW_COPY_AND_ASSIGN(LoginUtilsTest); 528 DISALLOW_COPY_AND_ASSIGN(LoginUtilsTest);
529 }; 529 };
530 530
531 class LoginUtilsBlockingLoginTest 531 class LoginUtilsBlockingLoginTest
532 : public LoginUtilsTest, 532 : public LoginUtilsTest,
533 public testing::WithParamInterface<int> {}; 533 public testing::WithParamInterface<int> {};
534 534
535 TEST_F(LoginUtilsTest, NormalLoginDoesntBlock) { 535 TEST_F(LoginUtilsTest, NormalLoginDoesBlock) {
536 UserManager* user_manager = UserManager::Get(); 536 UserManager* user_manager = UserManager::Get();
537 EXPECT_FALSE(user_manager->IsUserLoggedIn()); 537 EXPECT_FALSE(user_manager->IsUserLoggedIn());
538 EXPECT_FALSE(connector_->IsEnterpriseManaged()); 538 EXPECT_FALSE(connector_->IsEnterpriseManaged());
539 EXPECT_FALSE(prepared_profile_); 539 EXPECT_FALSE(prepared_profile_);
540 EXPECT_EQ(policy::USER_AFFILIATION_NONE, 540 EXPECT_EQ(policy::USER_AFFILIATION_NONE,
541 connector_->GetUserAffiliation(kUsername)); 541 connector_->GetUserAffiliation(kUsername));
542 542
543 // The profile will be created without waiting for a policy response. 543 // First login in a unmanaged device would still block to verify if there is
bartfab (slow) 2014/07/08 17:40:33 Nit: Use indicative, not subjunctive.
kaliamoorthi 2014/07/11 10:05:19 Removed the whole test
544 // a user cloud policy for the user.
544 PrepareProfile(kUsername); 545 PrepareProfile(kUsername);
545 546
546 EXPECT_TRUE(prepared_profile_); 547 EXPECT_FALSE(prepared_profile_);
547 ASSERT_TRUE(user_manager->IsUserLoggedIn());
548 EXPECT_EQ(kUsername, user_manager->GetLoggedInUser()->email());
549 } 548 }
550 549
551 TEST_F(LoginUtilsTest, EnterpriseLoginDoesntBlockForNormalUser) { 550 TEST_F(LoginUtilsTest, EnterpriseLoginDoesBlockForNormalUser) {
552 UserManager* user_manager = UserManager::Get(); 551 UserManager* user_manager = UserManager::Get();
553 EXPECT_FALSE(user_manager->IsUserLoggedIn()); 552 EXPECT_FALSE(user_manager->IsUserLoggedIn());
554 EXPECT_FALSE(connector_->IsEnterpriseManaged()); 553 EXPECT_FALSE(connector_->IsEnterpriseManaged());
555 EXPECT_FALSE(prepared_profile_); 554 EXPECT_FALSE(prepared_profile_);
556 555
557 // Enroll the device. 556 // Enroll the device.
558 EnrollDevice(kUsername); 557 EnrollDevice(kUsername);
559 558
560 EXPECT_FALSE(user_manager->IsUserLoggedIn()); 559 EXPECT_FALSE(user_manager->IsUserLoggedIn());
561 EXPECT_TRUE(connector_->IsEnterpriseManaged()); 560 EXPECT_TRUE(connector_->IsEnterpriseManaged());
562 EXPECT_EQ(kDomain, connector_->GetEnterpriseDomain()); 561 EXPECT_EQ(kDomain, connector_->GetEnterpriseDomain());
563 EXPECT_FALSE(prepared_profile_); 562 EXPECT_FALSE(prepared_profile_);
564 EXPECT_EQ(policy::USER_AFFILIATION_NONE, 563 EXPECT_EQ(policy::USER_AFFILIATION_NONE,
565 connector_->GetUserAffiliation(kUsernameOtherDomain)); 564 connector_->GetUserAffiliation(kUsernameOtherDomain));
566 565
567 // Login with a non-enterprise user shouldn't block. 566 // First login with a non-enterprise user would still block to verify if
567 // there is a user cloud policy for it.
568 PrepareProfile(kUsernameOtherDomain); 568 PrepareProfile(kUsernameOtherDomain);
bartfab (slow) 2014/07/08 17:40:33 This is not necessarily a non-enterprise user. The
kaliamoorthi 2014/07/11 10:05:19 Removed these and folded them into the existing pa
569 569
570 EXPECT_TRUE(prepared_profile_); 570 EXPECT_FALSE(prepared_profile_);
571 ASSERT_TRUE(user_manager->IsUserLoggedIn());
572 EXPECT_EQ(kUsernameOtherDomain, user_manager->GetLoggedInUser()->email());
573 } 571 }
574 572
575 #if defined(ENABLE_RLZ) 573 #if defined(ENABLE_RLZ)
576 TEST_F(LoginUtilsTest, RlzInitialized) { 574 TEST_F(LoginUtilsTest, RlzInitialized) {
577 // No RLZ brand code set initially. 575 // No RLZ brand code set initially.
578 EXPECT_FALSE(local_state_.Get()->HasPrefPath(prefs::kRLZBrand)); 576 EXPECT_FALSE(local_state_.Get()->HasPrefPath(prefs::kRLZBrand));
579 577
580 base::RunLoop wait_for_rlz_init; 578 base::RunLoop wait_for_rlz_init;
581 rlz_initialized_cb_ = wait_for_rlz_init.QuitClosure(); 579 rlz_initialized_cb_ = wait_for_rlz_init.QuitClosure();
582 580
(...skipping 28 matching lines...) Expand all
611 EXPECT_TRUE(connector_->IsEnterpriseManaged()); 609 EXPECT_TRUE(connector_->IsEnterpriseManaged());
612 EXPECT_EQ(kDomain, connector_->GetEnterpriseDomain()); 610 EXPECT_EQ(kDomain, connector_->GetEnterpriseDomain());
613 EXPECT_FALSE(prepared_profile_); 611 EXPECT_FALSE(prepared_profile_);
614 EXPECT_EQ(policy::USER_AFFILIATION_MANAGED, 612 EXPECT_EQ(policy::USER_AFFILIATION_MANAGED,
615 connector_->GetUserAffiliation(kUsername)); 613 connector_->GetUserAffiliation(kUsername));
616 EXPECT_FALSE(user_manager->IsKnownUser(kUsername)); 614 EXPECT_FALSE(user_manager->IsKnownUser(kUsername));
617 615
618 // Login with a user of the enterprise domain waits for policy. 616 // Login with a user of the enterprise domain waits for policy.
619 PrepareProfile(kUsername); 617 PrepareProfile(kUsername);
620 618
621 EXPECT_FALSE(prepared_profile_); 619 EXPECT_FALSE(prepared_profile_);
bartfab (slow) 2014/07/08 17:40:33 This test actually verifies that the blocking poli
kaliamoorthi 2014/07/11 10:05:19 Done.
622 ASSERT_TRUE(user_manager->IsUserLoggedIn()); 620 ASSERT_TRUE(user_manager->IsUserLoggedIn());
623 EXPECT_TRUE(user_manager->IsCurrentUserNew()); 621 EXPECT_TRUE(user_manager->IsCurrentUserNew());
624 622
625 GaiaUrls* gaia_urls = GaiaUrls::GetInstance(); 623 GaiaUrls* gaia_urls = GaiaUrls::GetInstance();
626 net::TestURLFetcher* fetcher; 624 net::TestURLFetcher* fetcher;
627 625
628 // |steps| is the test parameter, and is the number of successful fetches. 626 // |steps| is the test parameter, and is the number of successful fetches.
629 // The first incomplete fetch will fail. In any case, the profile creation 627 // The first incomplete fetch will fail. In any case, the profile creation
630 // should resume. 628 // should resume.
631 int steps = GetParam(); 629 int steps = GetParam();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 } 702 }
705 703
706 INSTANTIATE_TEST_CASE_P( 704 INSTANTIATE_TEST_CASE_P(
707 LoginUtilsBlockingLoginTestInstance, 705 LoginUtilsBlockingLoginTestInstance,
708 LoginUtilsBlockingLoginTest, 706 LoginUtilsBlockingLoginTest,
709 testing::Values(0, 1, 2, 3, 4, 5)); 707 testing::Values(0, 1, 2, 3, 4, 5));
710 708
711 } // namespace 709 } // namespace
712 710
713 } // namespace chromeos 711 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698