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

Side by Side 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: Rebase Created 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_AFFILIATION_TEST_HELPER_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_AFFILIATION_TEST_HELPER_H_
7
8 #include <set>
9 #include <string>
10 #include "components/policy/core/common/cloud/policy_builder.h"
11
12 namespace policy {
13 class DevicePolicyCrosTestHelper;
14 } // namespace policy
15
16 namespace base {
17 class CommandLine;
18 } // namespace base
19
20 namespace chromeos {
oshima 2015/11/13 19:53:04 let's not add chromeos namespace under chrome/brow
peletskyi 2015/11/16 14:33:15 Done.
21
22 class FakeSessionManagerClient;
23
24 namespace affiliation_test_helper {
oshima 2015/11/13 19:53:04 this one is okay as this namespace is for a bag of
peletskyi 2015/11/16 14:33:15 Done.
25
26 // Creates policy key file for the user specified in |user_policy|.
27 // TODO(peletskyi): Replace pointer with const reference and replace this
28 // boilerplate in other places (http://crbug.com/549111).
29 void SetUserKeys(policy::UserPolicyBuilder* user_policy);
30
31 // Sets device affiliation ID to |fake_session_manager| from
32 // |device_affiliation_ids| and modifies |test_helper| so that it contains
33 // correct values of device affiliation IDs for future use. To add some device
34 // policies and have device affiliation ID valid please use |test_helper|
35 // modified by this function. Example:
36 //
37 // FakeSessionManagerClient* fake_session_manager_client =
38 // new chromeos::FakeSessionManagerClient;
39 // DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient(
40 // scoped_ptr<SessionManagerClient>(fake_session_manager_client));
41 //
42 // policy::DevicePolicyCrosTestHelper test_helper;
43 // std::set<std::string> device_affiliation_ids;
44 // device_affiliation_ids.insert(some-affiliation-id);
45 //
46 // affiliation_test_helper::SetDeviceAffiliationID(&test_helper,
47 // fake_session_manager_client,
48 // device_affiliation_ids);
49 //
50 // If it is used together with SetUserAffiliationIDs() (which is the most common
51 // case) |fake_session_manager_client| must point to the same object as in
52 // SetUserAffiliationIDs() call.
53 // In browser tests one can call this function from
54 // SetUpInProcessBrowserTestFixture().
55 void SetDeviceAffiliationID(
56 policy::DevicePolicyCrosTestHelper* test_helper,
57 FakeSessionManagerClient* fake_session_manager_client,
58 const std::set<std::string>& device_affiliation_ids);
59
60 // Sets user affiliation ID for |user_name| to |fake_session_manager| from
61 // |user_affiliation_ids| and modifies |user_policy| so that it contains
62 // correct values of user affiliation IDs for future use. To add user policies
63 // and have user affiliation IDs valid please use |user_policy| modified by this
64 // function. Example:
65 //
66 // FakeSessionManagerClient* fake_session_manager_client =
67 // new chromeos::FakeSessionManagerClient;
68 // DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient(
69 // scoped_ptr<SessionManagerClient>(fake_session_manager_client));
70 //
71 // policy::UserPolicyBuilder user_policy;
72 // std::set<std::string> user_affiliation_ids;
73 // user_affiliation_ids.insert("some-affiliation-id");
74 //
75 // affiliation_test_helper::SetUserAffiliationIDs(
76 // &user_policy, fake_session_manager_client, "user@example.com",
77 // user_affiliation_ids);
78 //
79 // If it is used together SetDeviceAffiliationID() (which is the most common
80 // case) |fake_session_manager_client| must point to the same object as in
81 // SetDeviceAffiliationID() call.
82 // In browser tests one can call this function from
83 // SetUpInProcessBrowserTestFixture().
84 void SetUserAffiliationIDs(
85 policy::UserPolicyBuilder* user_policy,
86 FakeSessionManagerClient* fake_session_manager_client,
87 const std::string& user_email,
88 const std::set<std::string>& user_affiliation_ids);
89
90 // Registers the user with the given |user_id| on the device and marks OOBE
91 // as completed. This method should be called in PRE_* test.
92 void PreLoginUser(const std::string& user_id);
93
94 // Log in user with |user_id|. User should be registered using PreLoginUser().
95 void LoginUser(const std::string& user_id);
96
97 // Set necessary for login command line switches. Execute it in
98 // SetUpCommandLine().
99 void AppendCommandLineSwitchesForLoginManager(base::CommandLine* command_line);
100
101 extern const char kFakeRefreshToken[];
102 extern const char kEnterpriseUser[];
103
104 } // namespace affiliation_test_helper
105
106 } // namespace chromeos
107
108 #endif // CHROME_BROWSER_CHROMEOS_POLICY_AFFILIATION_TEST_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698