| Index: chrome/browser/chromeos/policy/login_policy_test_base.cc
|
| diff --git a/chrome/browser/chromeos/policy/login_policy_test_base.cc b/chrome/browser/chromeos/policy/login_policy_test_base.cc
|
| index 7fb6adac12b75160a4d9b39c8850ab8da2bf540b..386f37c33da3952471c2e4e3250ec6bc44020d30 100644
|
| --- a/chrome/browser/chromeos/policy/login_policy_test_base.cc
|
| +++ b/chrome/browser/chromeos/policy/login_policy_test_base.cc
|
| @@ -2,26 +2,20 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "base/command_line.h"
|
| -#include "base/files/file_path.h"
|
| -#include "base/files/file_util.h"
|
| -#include "base/json/json_writer.h"
|
| +#include "chrome/browser/chromeos/policy/login_policy_test_base.h"
|
| +
|
| #include "base/values.h"
|
| #include "chrome/browser/chrome_notification_types.h"
|
| #include "chrome/browser/chromeos/login/ui/webui_login_display.h"
|
| #include "chrome/browser/chromeos/login/wizard_controller.h"
|
| -#include "chrome/browser/chromeos/policy/login_policy_test_base.h"
|
| -#include "chrome/browser/policy/test/local_policy_test_server.h"
|
| +#include "chrome/browser/chromeos/policy/user_policy_test_helper.h"
|
| #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
|
| -#include "components/policy/core/common/cloud/cloud_policy_constants.h"
|
| -#include "components/policy/core/common/policy_switches.h"
|
| #include "content/public/browser/notification_service.h"
|
| #include "content/public/test/test_utils.h"
|
| #include "google_apis/gaia/fake_gaia.h"
|
| #include "google_apis/gaia/gaia_constants.h"
|
| #include "google_apis/gaia/gaia_urls.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| -#include "url/gurl.h"
|
|
|
| namespace policy {
|
|
|
| @@ -37,29 +31,6 @@ const char kTestSessionSIDCookie[] = "fake-session-SID-cookie";
|
| const char kTestSessionLSIDCookie[] = "fake-session-LSID-cookie";
|
| const char kTestUserinfoToken[] = "fake-userinfo-token";
|
|
|
| -std::string GetPolicy(scoped_ptr<base::DictionaryValue> mandatory,
|
| - scoped_ptr<base::DictionaryValue> recommended,
|
| - const std::string& policyType,
|
| - const std::string& account) {
|
| - scoped_ptr<base::DictionaryValue> policy_type_dict(new base::DictionaryValue);
|
| - policy_type_dict->Set("mandatory", mandatory.Pass());
|
| - policy_type_dict->Set("recommended", recommended.Pass());
|
| -
|
| - scoped_ptr<base::ListValue> managed_users_list(new base::ListValue);
|
| - managed_users_list->AppendString("*");
|
| -
|
| - base::DictionaryValue root_dict;
|
| - root_dict.Set(policyType, policy_type_dict.Pass());
|
| - root_dict.Set("managed_users", managed_users_list.Pass());
|
| - root_dict.SetString("policy_user", account);
|
| - root_dict.SetInteger("current_key_index", 0);
|
| -
|
| - std::string json_policy;
|
| - base::JSONWriter::WriteWithOptions(
|
| - root_dict, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json_policy);
|
| - return json_policy;
|
| -}
|
| -
|
| } // namespace
|
|
|
| const char LoginPolicyTestBase::kAccountPassword[] = "letmein";
|
| @@ -75,35 +46,32 @@ LoginPolicyTestBase::~LoginPolicyTestBase() {
|
| }
|
|
|
| void LoginPolicyTestBase::SetUp() {
|
| - ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
|
| - SetServerPolicy();
|
| -
|
| - test_server_.reset(new LocalPolicyTestServer(PolicyFilePath()));
|
| - ASSERT_TRUE(test_server_->Start());
|
| -
|
| + base::DictionaryValue mandatory;
|
| + GetMandatoryPoliciesValue(&mandatory);
|
| + base::DictionaryValue recommended;
|
| + GetRecommendedPoliciesValue(&recommended);
|
| + user_policy_helper_.reset(new UserPolicyTestHelper(kAccountId));
|
| + user_policy_helper_->Init(mandatory, recommended);
|
| OobeBaseTest::SetUp();
|
| }
|
|
|
| void LoginPolicyTestBase::SetUpCommandLine(base::CommandLine* command_line) {
|
| - command_line->AppendSwitchASCII(policy::switches::kDeviceManagementUrl,
|
| - test_server_->GetServiceURL().spec());
|
| + user_policy_helper_->UpdateCommandLine(command_line);
|
| OobeBaseTest::SetUpCommandLine(command_line);
|
| }
|
|
|
| void LoginPolicyTestBase::SetUpOnMainThread() {
|
| - SetMergeSessionParams(kAccountId);
|
| + SetMergeSessionParams();
|
| SetUpGaiaServerWithAccessTokens();
|
| OobeBaseTest::SetUpOnMainThread();
|
| }
|
|
|
| -scoped_ptr<base::DictionaryValue>
|
| -LoginPolicyTestBase::GetMandatoryPoliciesValue() const {
|
| - return make_scoped_ptr(new base::DictionaryValue);
|
| +void LoginPolicyTestBase::GetMandatoryPoliciesValue(
|
| + base::DictionaryValue* policy) const {
|
| }
|
|
|
| -scoped_ptr<base::DictionaryValue>
|
| -LoginPolicyTestBase::GetRecommendedPoliciesValue() const {
|
| - return make_scoped_ptr(new base::DictionaryValue);
|
| +void LoginPolicyTestBase::GetRecommendedPoliciesValue(
|
| + base::DictionaryValue* policy) const {
|
| }
|
|
|
| void LoginPolicyTestBase::SetUpGaiaServerWithAccessTokens() {
|
| @@ -116,7 +84,7 @@ void LoginPolicyTestBase::SetUpGaiaServerWithAccessTokens() {
|
| fake_gaia_->IssueOAuthToken(kTestRefreshToken, token_info);
|
| }
|
|
|
| -void LoginPolicyTestBase::SetMergeSessionParams(const std::string& email) {
|
| +void LoginPolicyTestBase::SetMergeSessionParams() {
|
| FakeGaia::MergeSessionParams params;
|
| params.auth_sid_cookie = kTestAuthSIDCookie;
|
| params.auth_lsid_cookie = kTestAuthLSIDCookie;
|
| @@ -126,7 +94,7 @@ void LoginPolicyTestBase::SetMergeSessionParams(const std::string& email) {
|
| params.gaia_uber_token = kTestGaiaUberToken;
|
| params.session_sid_cookie = kTestSessionSIDCookie;
|
| params.session_lsid_cookie = kTestSessionLSIDCookie;
|
| - params.email = email;
|
| + params.email = kAccountId;
|
| fake_gaia_->SetMergeSessionParams(params);
|
| }
|
|
|
| @@ -151,18 +119,4 @@ void LoginPolicyTestBase::LogIn(const std::string& user_id,
|
| content::NotificationService::AllSources()).Wait();
|
| }
|
|
|
| -void LoginPolicyTestBase::SetServerPolicy() {
|
| - const std::string policy =
|
| - GetPolicy(GetMandatoryPoliciesValue(), GetRecommendedPoliciesValue(),
|
| - dm_protocol::kChromeUserPolicyType, kAccountId);
|
| -
|
| - const int bytes_written =
|
| - base::WriteFile(PolicyFilePath(), policy.data(), policy.size());
|
| - ASSERT_EQ(static_cast<int>(policy.size()), bytes_written);
|
| -}
|
| -
|
| -base::FilePath LoginPolicyTestBase::PolicyFilePath() const {
|
| - return temp_dir_.path().AppendASCII("policy.json");
|
| -}
|
| -
|
| } // namespace policy
|
|
|