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

Unified Diff: chrome/browser/chromeos/policy/affiliation_test_helper.h

Issue 1306183007: Switch to id-based affiliation determination (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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/policy/affiliation_test_helper.h
diff --git a/chrome/browser/chromeos/policy/affiliation_test_helper.h b/chrome/browser/chromeos/policy/affiliation_test_helper.h
new file mode 100644
index 0000000000000000000000000000000000000000..8b19bfb7aadff8ff17028a792f1eb24415f7934c
--- /dev/null
+++ b/chrome/browser/chromeos/policy/affiliation_test_helper.h
@@ -0,0 +1,107 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_POLICY_AFFILIATION_TEST_HELPER_H_
+#define CHROME_BROWSER_CHROMEOS_POLICY_AFFILIATION_TEST_HELPER_H_
+
+#include <set>
+#include <string>
+#include "components/policy/core/common/cloud/policy_builder.h"
+
+namespace policy {
+class DevicePolicyCrosTestHelper;
+} // namespace policy
+
+namespace base {
+class CommandLine;
+} // namespace base
+
+namespace chromeos {
+
+class FakeSessionManagerClient;
+
+namespace affiliation_test_helper {
+
+// Creates policy key file for the user specified in |user_policy|.
+// TODO(peletskyi): Replace pointer with const reference and replace this
+// boilerplate in other places.
Andrew T Wilson (Slow) 2015/10/09 12:35:46 Log a bug to track this and put bug number here.
peletskyi 2015/10/29 15:27:37 Done.
+void SetUserKeys(policy::UserPolicyBuilder* user_policy);
+
+// Sets device affiliation ID to |fake_session_manager| from
+// |device_affiliation_ids| and modifies |test_helper| so that it contains
+// correct values of device affiliation IDs for future use. To add some device
+// policies and have device affiliation ID valid please use |test_helper|
+// modified by this function. Example:
+//
+// FakeSessionManagerClient* fake_session_manager_client =
+// new chromeos::FakeSessionManagerClient;
+// DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient(
+// scoped_ptr<SessionManagerClient>(fake_session_manager_client));
+//
+// policy::DevicePolicyCrosTestHelper test_helper;
+// std::set<std::string> device_affiliation_ids;
+// device_affiliation_ids.insert(some-affiliation-id);
+//
+// affiliation_test_helper::SetDeviceAffiliationID(
+// &test_helper, fake_session_manager_client, device_affiliation_ids);
Andrew T Wilson (Slow) 2015/10/09 12:35:46 Properly indent your sample code.
peletskyi 2015/10/29 15:27:37 Done.
+//
+// If it is used together SetUserAffiliationIDs() (which is the most common
Andrew T Wilson (Slow) 2015/10/09 12:35:46 nit: "used together with"
peletskyi 2015/10/29 15:27:37 Done.
+// case) |fake_session_manager_client| must point to the same object as in
+// SetUserAffiliationIDs() call.
Andrew T Wilson (Slow) 2015/10/09 12:35:46 Is this easy to enforce?
peletskyi 2015/10/29 15:27:37 One should just provide the same |fake_session_man
+// In browser tests one can call this function from
+// SetUpInProcessBrowserTestFixture().
+void SetDeviceAffiliationID(
+ policy::DevicePolicyCrosTestHelper* test_helper,
+ FakeSessionManagerClient* fake_session_manager_client,
+ const std::set<std::string>& device_affiliation_ids);
+
+// Sets user affiliation ID for |user_name| to |fake_session_manager| from
+// |user_affiliation_ids| and modifies |user_policy| so that it contains
+// correct values of user affiliation IDs for future use. To add user policies
+// and have user affiliation IDs valid please use |user_policy| modified by this
+// function. Example:
+//
+// FakeSessionManagerClient* fake_session_manager_client =
+// new chromeos::FakeSessionManagerClient;
+// DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient(
+// scoped_ptr<SessionManagerClient>(fake_session_manager_client));
+//
+// policy::UserPolicyBuilder user_policy;
+// std::set<std::string> user_affiliation_ids;
+// user_affiliation_ids.insert("some-affiliation-id");
+//
+// affiliation_test_helper::SetUserAffiliationIDs(
+// &user_policy, fake_session_manager_client, "user@example.com",
+// user_affiliation_ids);
+//
+// If it is used together SetDeviceAffiliationID() (which is the most common
+// case) |fake_session_manager_client| must point to the same object as in
+// SetDeviceAffiliationID() call.
+// In browser tests one can call this function from
+// SetUpInProcessBrowserTestFixture().
+void SetUserAffiliationIDs(
+ policy::UserPolicyBuilder* user_policy,
+ FakeSessionManagerClient* fake_session_manager_client,
+ const std::string& user_email,
+ const std::set<std::string>& user_affiliation_ids);
+
+// Registers the user with the given |user_id| on the device and marks OOBE
+// as completed. This method should be called in PRE_* test.
+void PreLoginUser(const std::string& user_id);
+
+// Log in user with |user_id|. User should be registered using PreLoginUser().
+void LoginUser(const std::string& user_id);
+
+// Set necessary for login command line switches. Execute it in
+// SetUpCommandLine().
+void AppendCommandLineSwitchesForLoginManager(base::CommandLine* command_line);
+
+extern const char kFakeRefreshToken[];
+extern const char kEnterpriseUser[];
+
+} // namespace affiliation_test_helper
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_POLICY_AFFILIATION_TEST_HELPER_H_

Powered by Google App Engine
This is Rietveld 408576698