OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/login/users/affiliation.h" | 5 #include "chrome/browser/chromeos/login/users/affiliation.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 set2.insert("j"); | 71 set2.insert("j"); |
72 | 72 |
73 EXPECT_TRUE(HaveCommonElement(set1, set2)); | 73 EXPECT_TRUE(HaveCommonElement(set1, set2)); |
74 EXPECT_TRUE(HaveCommonElement(set2, set1)); | 74 EXPECT_TRUE(HaveCommonElement(set2, set1)); |
75 } | 75 } |
76 | 76 |
77 TEST(AffiliationTest, Generic) { | 77 TEST(AffiliationTest, Generic) { |
78 AffiliationIDSet user_ids; // User affiliation IDs. | 78 AffiliationIDSet user_ids; // User affiliation IDs. |
79 AffiliationIDSet device_ids; // Device affiliation IDs. | 79 AffiliationIDSet device_ids; // Device affiliation IDs. |
80 | 80 |
81 EXPECT_FALSE(IsUserAffiliated(user_ids, device_ids, "", "")); | 81 // Empty affiliation IDs. |
peletskyi
2016/09/28 14:08:53
I'd leave this test case of the not valid email.
Thiemo Nagel
2016/09/28 14:13:45
I've just moved them to the bottom to also check t
| |
82 EXPECT_FALSE(IsUserAffiliated(user_ids, device_ids, "user@managed.com")); | |
82 | 83 |
83 EXPECT_FALSE(IsUserAffiliated(user_ids, device_ids, "user", "")); | 84 user_ids.insert("aaaa"); // Only user affiliation IDs present. |
peletskyi
2016/09/28 14:08:53
And this
Thiemo Nagel
2016/09/28 14:13:45
see above
| |
84 | 85 EXPECT_FALSE(IsUserAffiliated(user_ids, device_ids, "user@managed.com")); |
85 // Not valid email. | |
86 EXPECT_FALSE(IsUserAffiliated(user_ids, device_ids, "user", "user")); | |
87 | |
88 EXPECT_FALSE(IsUserAffiliated(user_ids, device_ids, "user@notmanaged.com", | |
89 "managed.com")); | |
90 | |
91 EXPECT_TRUE(IsUserAffiliated(user_ids, device_ids, "user@managed.com", | |
92 "managed.com")); | |
93 | |
94 user_ids.insert("aaaa"); // Only user affiliation IDs present. Compare email. | |
95 EXPECT_TRUE(IsUserAffiliated(user_ids, device_ids, "user@managed.com", | |
96 "managed.com")); | |
97 | 86 |
98 device_ids.insert("bbbb"); // Device and user IDs do not overlap. | 87 device_ids.insert("bbbb"); // Device and user IDs do not overlap. |
99 EXPECT_FALSE(IsUserAffiliated(user_ids, device_ids, "user@managed.com", | 88 EXPECT_FALSE(IsUserAffiliated(user_ids, device_ids, "user@managed.com")); |
100 "managed.com")); | |
101 | 89 |
102 user_ids.insert("cccc"); // Device and user IDs do overlap. | 90 user_ids.insert("cccc"); // Device and user IDs do overlap. |
103 device_ids.insert("cccc"); | 91 device_ids.insert("cccc"); |
104 EXPECT_TRUE(IsUserAffiliated(user_ids, device_ids, "user@notmanaged.com", | 92 EXPECT_TRUE(IsUserAffiliated(user_ids, device_ids, "user@managed.com")); |
105 "managed.com")); | 93 |
94 // Invalid email overrides match of affiliation IDs. | |
95 EXPECT_FALSE(IsUserAffiliated(user_ids, device_ids, "")); | |
96 EXPECT_FALSE(IsUserAffiliated(user_ids, device_ids, "user")); | |
106 } | 97 } |
107 | 98 |
108 } // namespace chromeos | 99 } // namespace chromeos |
OLD | NEW |