OLD | NEW |
---|---|
(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 { | |
21 | |
22 class FakeSessionManagerClient; | |
23 | |
24 namespace affiliation_test_helper { | |
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. | |
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.
| |
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( | |
47 // &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.
| |
48 // | |
49 // 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.
| |
50 // case) |fake_session_manager_client| must point to the same object as in | |
51 // 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
| |
52 // In browser tests one can call this function from | |
53 // SetUpInProcessBrowserTestFixture(). | |
54 void SetDeviceAffiliationID( | |
55 policy::DevicePolicyCrosTestHelper* test_helper, | |
56 FakeSessionManagerClient* fake_session_manager_client, | |
57 const std::set<std::string>& device_affiliation_ids); | |
58 | |
59 // Sets user affiliation ID for |user_name| to |fake_session_manager| from | |
60 // |user_affiliation_ids| and modifies |user_policy| so that it contains | |
61 // correct values of user affiliation IDs for future use. To add user policies | |
62 // and have user affiliation IDs valid please use |user_policy| modified by this | |
63 // function. Example: | |
64 // | |
65 // FakeSessionManagerClient* fake_session_manager_client = | |
66 // new chromeos::FakeSessionManagerClient; | |
67 // DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( | |
68 // scoped_ptr<SessionManagerClient>(fake_session_manager_client)); | |
69 // | |
70 // policy::UserPolicyBuilder user_policy; | |
71 // std::set<std::string> user_affiliation_ids; | |
72 // user_affiliation_ids.insert("some-affiliation-id"); | |
73 // | |
74 // affiliation_test_helper::SetUserAffiliationIDs( | |
75 // &user_policy, fake_session_manager_client, "user@example.com", | |
76 // user_affiliation_ids); | |
77 // | |
78 // If it is used together SetDeviceAffiliationID() (which is the most common | |
79 // case) |fake_session_manager_client| must point to the same object as in | |
80 // SetDeviceAffiliationID() call. | |
81 // In browser tests one can call this function from | |
82 // SetUpInProcessBrowserTestFixture(). | |
83 void SetUserAffiliationIDs( | |
84 policy::UserPolicyBuilder* user_policy, | |
85 FakeSessionManagerClient* fake_session_manager_client, | |
86 const std::string& user_email, | |
87 const std::set<std::string>& user_affiliation_ids); | |
88 | |
89 // Registers the user with the given |user_id| on the device and marks OOBE | |
90 // as completed. This method should be called in PRE_* test. | |
91 void PreLoginUser(const std::string& user_id); | |
92 | |
93 // Log in user with |user_id|. User should be registered using PreLoginUser(). | |
94 void LoginUser(const std::string& user_id); | |
95 | |
96 // Set necessary for login command line switches. Execute it in | |
97 // SetUpCommandLine(). | |
98 void AppendCommandLineSwitchesForLoginManager(base::CommandLine* command_line); | |
99 | |
100 extern const char kFakeRefreshToken[]; | |
101 extern const char kEnterpriseUser[]; | |
102 | |
103 } // namespace affiliation_test_helper | |
104 | |
105 } // namespace chromeos | |
106 | |
107 #endif // CHROME_BROWSER_CHROMEOS_POLICY_AFFILIATION_TEST_HELPER_H_ | |
OLD | NEW |