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

Side by Side Diff: chrome/browser/chromeos/login/authenticator_unittest.cc

Issue 6089004: [Chrome OS] Respect periods in google apps account names (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ws fix Created 9 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/authenticator.h" 5 #include "chrome/browser/chromeos/login/authenticator.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace chromeos { 9 namespace chromeos {
10 10
11 TEST(AuthenticatorTest, EmailAddressNoOp) { 11 TEST(AuthenticatorTest, EmailAddressNoOp) {
12 const char lower_case[] = "user@what.com"; 12 const char lower_case[] = "user@what.com";
13 EXPECT_EQ(lower_case, Authenticator::Canonicalize(lower_case)); 13 EXPECT_EQ(lower_case, Authenticator::Canonicalize(lower_case));
14 } 14 }
15 15
16 TEST(AuthenticatorTest, EmailAddressIgnoreCaps) { 16 TEST(AuthenticatorTest, EmailAddressIgnoreCaps) {
17 EXPECT_EQ(Authenticator::Canonicalize("user@what.com"), 17 EXPECT_EQ(Authenticator::Canonicalize("user@what.com"),
18 Authenticator::Canonicalize("UsEr@what.com")); 18 Authenticator::Canonicalize("UsEr@what.com"));
19 } 19 }
20 20
21 TEST(AuthenticatorTest, EmailAddressIgnoreDomainCaps) { 21 TEST(AuthenticatorTest, EmailAddressIgnoreDomainCaps) {
22 EXPECT_EQ(Authenticator::Canonicalize("user@what.com"), 22 EXPECT_EQ(Authenticator::Canonicalize("user@what.com"),
23 Authenticator::Canonicalize("UsEr@what.COM")); 23 Authenticator::Canonicalize("UsEr@what.COM"));
24 } 24 }
25 25
26 TEST(AuthenticatorTest, EmailAddressIgnoreOneUsernameDot) { 26 TEST(AuthenticatorTest, EmailAddressRejectOneUsernameDot) {
27 EXPECT_EQ(Authenticator::Canonicalize("us.er@what.com"), 27 EXPECT_NE(Authenticator::Canonicalize("u.ser@what.com"),
28 Authenticator::Canonicalize("UsEr@what.com")); 28 Authenticator::Canonicalize("UsEr@what.com"));
29 } 29 }
30 30
31 TEST(AuthenticatorTest, EmailAddressMatchWithOneUsernameDot) {
32 EXPECT_EQ(Authenticator::Canonicalize("u.ser@what.com"),
33 Authenticator::Canonicalize("U.sEr@what.com"));
34 }
35
36 TEST(AuthenticatorTest, EmailAddressIgnoreOneUsernameDot) {
37 std::string first("us.er@");
38 first.append(Authenticator::kSpecialCase);
whywhat 2010/12/30 17:37:39 I'd just use "gmail.com" here to improve readabili
Chris Masone 2010/12/30 18:52:50 ok.
39 std::string second("UsEr@");
40 second.append(Authenticator::kSpecialCase);
41 EXPECT_EQ(Authenticator::Canonicalize(first),
42 Authenticator::Canonicalize(second));
43 }
44
31 TEST(AuthenticatorTest, EmailAddressIgnoreManyUsernameDots) { 45 TEST(AuthenticatorTest, EmailAddressIgnoreManyUsernameDots) {
32 EXPECT_EQ(Authenticator::Canonicalize("u.ser@what.com"), 46 std::string first("u.ser@");
33 Authenticator::Canonicalize("Us.E.r@what.com")); 47 first.append(Authenticator::kSpecialCase);
48 std::string second("Us.E.r@");
49 second.append(Authenticator::kSpecialCase);
50 EXPECT_EQ(Authenticator::Canonicalize(first),
51 Authenticator::Canonicalize(second));
34 } 52 }
35 53
36 TEST(AuthenticatorTest, EmailAddressIgnoreConsecutiveUsernameDots) { 54 TEST(AuthenticatorTest, EmailAddressIgnoreConsecutiveUsernameDots) {
37 EXPECT_EQ(Authenticator::Canonicalize("use.r@what.com"), 55 std::string first("use.r@");
38 Authenticator::Canonicalize("Us....E.r@what.com")); 56 first.append(Authenticator::kSpecialCase);
57 std::string second("Us....E.r@");
58 second.append(Authenticator::kSpecialCase);
59 EXPECT_EQ(Authenticator::Canonicalize(first),
60 Authenticator::Canonicalize(second));
39 } 61 }
40 62
41 TEST(AuthenticatorTest, EmailAddressDifferentOnesRejected) { 63 TEST(AuthenticatorTest, EmailAddressDifferentOnesRejected) {
42 EXPECT_NE(Authenticator::Canonicalize("who@what.com"), 64 EXPECT_NE(Authenticator::Canonicalize("who@what.com"),
43 Authenticator::Canonicalize("Us....E.r@what.com")); 65 Authenticator::Canonicalize("Us....E.r@what.com"));
44 } 66 }
45 67
46 TEST(AuthenticatorTest, EmailAddressIgnorePlusSuffix) { 68 TEST(AuthenticatorTest, EmailAddressIgnorePlusSuffix) {
47 EXPECT_EQ(Authenticator::Canonicalize("user+cc@what.com"), 69 EXPECT_EQ(Authenticator::Canonicalize("user+cc@what.com"),
48 Authenticator::Canonicalize("user@what.com")); 70 Authenticator::Canonicalize("user@what.com"));
49 } 71 }
50 72
51 TEST(AuthenticatorTest, EmailAddressIgnoreMultiPlusSuffix) { 73 TEST(AuthenticatorTest, EmailAddressIgnoreMultiPlusSuffix) {
52 EXPECT_EQ(Authenticator::Canonicalize("user+cc+bcc@what.com"), 74 EXPECT_EQ(Authenticator::Canonicalize("user+cc+bcc@what.com"),
53 Authenticator::Canonicalize("user@what.com")); 75 Authenticator::Canonicalize("user@what.com"));
54 } 76 }
55 77
56 } // namespace chromeos 78 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698