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

Unified Diff: trunk/src/chrome/browser/chromeos/policy/device_local_account_browsertest.cc

Issue 60683002: Revert 233048 "Support policies referencing external data for de..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 1 month 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: trunk/src/chrome/browser/chromeos/policy/device_local_account_browsertest.cc
===================================================================
--- trunk/src/chrome/browser/chromeos/policy/device_local_account_browsertest.cc (revision 233050)
+++ trunk/src/chrome/browser/chromeos/policy/device_local_account_browsertest.cc (working copy)
@@ -14,14 +14,10 @@
#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
#include "base/json/json_reader.h"
-#include "base/location.h"
-#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
-#include "base/message_loop/message_loop_proxy.h"
#include "base/path_service.h"
#include "base/run_loop.h"
-#include "base/sequenced_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
@@ -39,25 +35,15 @@
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/login/webui_login_view.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
-#include "chrome/browser/chromeos/policy/cloud_external_data_manager_base.h"
-#include "chrome/browser/chromeos/policy/cloud_external_data_manager_base_test_util.h"
#include "chrome/browser/chromeos/policy/device_local_account.h"
-#include "chrome/browser/chromeos/policy/device_local_account_policy_service.h"
#include "chrome/browser/chromeos/policy/device_policy_builder.h"
#include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/lifetime/application_lifetime.h"
-#include "chrome/browser/policy/browser_policy_connector.h"
#include "chrome/browser/policy/cloud/cloud_policy_constants.h"
-#include "chrome/browser/policy/cloud/cloud_policy_core.h"
-#include "chrome/browser/policy/cloud/cloud_policy_store.h"
#include "chrome/browser/policy/cloud/policy_builder.h"
-#include "chrome/browser/policy/external_data_fetcher.h"
-#include "chrome/browser/policy/policy_map.h"
#include "chrome/browser/policy/policy_service.h"
-#include "chrome/browser/policy/profile_policy_connector.h"
-#include "chrome/browser/policy/profile_policy_connector_factory.h"
#include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h"
#include "chrome/browser/policy/test/local_policy_test_server.h"
#include "chrome/browser/prefs/session_startup_pref.h"
@@ -80,7 +66,6 @@
#include "chromeos/dbus/dbus_method_call_status.h"
#include "chromeos/dbus/fake_session_manager_client.h"
#include "chromeos/dbus/session_manager_client.h"
-#include "components/policy/core/common/policy_namespace.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/web_contents.h"
@@ -95,9 +80,6 @@
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
-#include "net/url_request/test_url_fetcher_factory.h"
-#include "net/url_request/url_fetcher_delegate.h"
-#include "policy/policy_constants.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
#include "ui/base/l10n/l10n_util.h"
@@ -140,9 +122,6 @@
const char kGoodExtensionCRXPath[] = "extensions/good.crx";
const char kGoodExtensionVersion[] = "1.0";
-const char kExternalData[] = "External data";
-const char kExternalDataURL[] = "http://localhost/external_data";
-
// Helper that serves extension update manifests to Chrome.
class TestingUpdateManifestProvider {
public:
@@ -250,18 +229,6 @@
string16::npos;
}
-scoped_ptr<net::FakeURLFetcher> RunCallbackAndReturnFakeURLFetcher(
- scoped_refptr<base::SequencedTaskRunner> task_runner,
- const base::Closure& callback,
- const GURL& url,
- net::URLFetcherDelegate* delegate,
- const std::string& response_data,
- bool success) {
- task_runner->PostTask(FROM_HERE, callback);
- return make_scoped_ptr(new net::FakeURLFetcher(
- url, delegate, response_data, success));
-}
-
} // namespace
class DeviceLocalAccountTest : public DevicePolicyCrosBrowserTest {
@@ -286,12 +253,8 @@
ASSERT_TRUE(extension_cache_root_dir_.CreateUniqueTempDir());
extension_cache_root_dir_override_.reset(new base::ScopedPathOverride(
- chromeos::DIR_DEVICE_LOCAL_ACCOUNT_EXTENSIONS,
+ chromeos::DIR_DEVICE_LOCAL_ACCOUNT_CACHE,
extension_cache_root_dir_.path()));
- ASSERT_TRUE(external_data_cache_dir_.CreateUniqueTempDir());
- external_data_cache_dir_override_.reset(new base::ScopedPathOverride(
- chromeos::DIR_DEVICE_LOCAL_ACCOUNT_EXTERNAL_DATA,
- external_data_cache_dir_.path()));
DevicePolicyCrosBrowserTest::SetUp();
}
@@ -398,9 +361,7 @@
const std::string user_id_2_;
base::ScopedTempDir extension_cache_root_dir_;
- base::ScopedTempDir external_data_cache_dir_;
scoped_ptr<base::ScopedPathOverride> extension_cache_root_dir_override_;
- scoped_ptr<base::ScopedPathOverride> external_data_cache_dir_override_;
UserPolicyBuilder device_local_account_policy_;
LocalPolicyTestServer test_server_;
@@ -808,125 +769,6 @@
EXPECT_FALSE(PathExists(cached_extension));
}
-IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, ExternalData) {
- CloudExternalDataManagerBase::SetMaxExternalDataSizeForTesting(1000);
-
- UploadAndInstallDeviceLocalAccountPolicy();
- AddPublicSessionToDevicePolicy(kAccountId1);
-
- // This observes the display name becoming available as this indicates
- // device-local account policy is fully loaded.
- content::WindowedNotificationObserver(
- chrome::NOTIFICATION_USER_LIST_CHANGED,
- base::Bind(&DisplayNameMatches, user_id_1_, kDisplayName)).Wait();
-
- scoped_ptr<base::DictionaryValue> metadata =
- test::ConstructExternalDataReference(kExternalDataURL, kExternalData);
- DeviceLocalAccountPolicyBroker* broker =
- g_browser_process->browser_policy_connector()->
- GetDeviceLocalAccountPolicyService()->GetBrokerForUser(user_id_1_);
- ASSERT_TRUE(broker);
-
- // Start serving external data at |kExternalDataURL|.
- scoped_ptr<base::RunLoop> run_loop(new base::RunLoop);
- scoped_ptr<net::FakeURLFetcherFactory> fetcher_factory(
- new net::FakeURLFetcherFactory(
- NULL,
- base::Bind(&RunCallbackAndReturnFakeURLFetcher,
- base::MessageLoopProxy::current(),
- run_loop->QuitClosure())));
- fetcher_factory->SetFakeResponse(GURL(kExternalDataURL),
- kExternalData,
- true);
-
- // TODO(bartfab): The test injects an ExternalDataFetcher for an arbitrary
- // policy. This is only done because there are no policies that reference
- // external data yet. Once the first such policy is added, switch the test to
- // that policy and stop injecting a manually instantiated ExternalDataFetcher.
- test::SetExternalDataReference(broker->core(),
- key::kHomepageLocation,
- make_scoped_ptr(metadata->DeepCopy()));
-
- // The external data should be fetched and cached automatically. Wait for this
- // fetch.
- run_loop->Run();
-
- // Stop serving external data at |kExternalDataURL|.
- fetcher_factory.reset();
-
- const PolicyMap::Entry* policy_entry =
- broker->core()->store()->policy_map().Get(key::kHomepageLocation);
- ASSERT_TRUE(policy_entry);
- ASSERT_TRUE(policy_entry->external_data_fetcher);
-
- // Retrieve the external data. Although the data is no longer being served at
- // |kExternalDataURL|, the retrieval should succeed because the data has been
- // cached.
- run_loop.reset(new base::RunLoop);
- scoped_ptr<std::string> fetched_external_data;
- policy_entry->external_data_fetcher->Fetch(base::Bind(
- &test::ExternalDataFetchCallback,
- &fetched_external_data,
- run_loop->QuitClosure()));
- run_loop->Run();
-
- ASSERT_TRUE(fetched_external_data);
- EXPECT_EQ(kExternalData, *fetched_external_data);
-
- // Wait for the login UI to be ready.
- chromeos::LoginDisplayHostImpl* host =
- reinterpret_cast<chromeos::LoginDisplayHostImpl*>(
- chromeos::LoginDisplayHostImpl::default_host());
- ASSERT_TRUE(host);
- chromeos::OobeUI* oobe_ui = host->GetOobeUI();
- ASSERT_TRUE(oobe_ui);
- run_loop.reset(new base::RunLoop);
- const bool oobe_ui_ready = oobe_ui->IsJSReady(run_loop->QuitClosure());
- if (!oobe_ui_ready)
- run_loop->Run();
-
- // Ensure that the browser stays alive, even though no windows are opened
- // during session start.
- chrome::StartKeepAlive();
-
- // Start login into the device-local account.
- host->StartSignInScreen();
- chromeos::ExistingUserController* controller =
- chromeos::ExistingUserController::current_controller();
- ASSERT_TRUE(controller);
- controller->LoginAsPublicAccount(user_id_1_);
-
- // Wait for the session to start.
- content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED,
- base::Bind(IsSessionStarted)).Wait();
-
- // Verify that the external data reference has propagated to the device-local
- // account's ProfilePolicyConnector.
- ProfilePolicyConnector* policy_connector =
- ProfilePolicyConnectorFactory::GetForProfile(
- ProfileManager::GetDefaultProfile());
- ASSERT_TRUE(policy_connector);
- const PolicyMap& policies = policy_connector->policy_service()->GetPolicies(
- PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()));
- policy_entry = policies.Get(key::kHomepageLocation);
- ASSERT_TRUE(policy_entry);
- EXPECT_TRUE(base::Value::Equals(metadata.get(), policy_entry->value));
- ASSERT_TRUE(policy_entry->external_data_fetcher);
-
- // Retrieve the external data via the ProfilePolicyConnector. The retrieval
- // should succeed because the data has been cached.
- run_loop.reset(new base::RunLoop);
- fetched_external_data.reset();
- policy_entry->external_data_fetcher->Fetch(base::Bind(
- &test::ExternalDataFetchCallback,
- &fetched_external_data,
- run_loop->QuitClosure()));
- run_loop->Run();
-
- ASSERT_TRUE(fetched_external_data);
- EXPECT_EQ(kExternalData, *fetched_external_data);
-}
-
class TermsOfServiceTest : public DeviceLocalAccountTest,
public testing::WithParamInterface<bool> {
};

Powered by Google App Engine
This is Rietveld 408576698