• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #include "chrome/browser/chromeos/login/authenticator.h"
6 
7 #include "testing/gtest/include/gtest/gtest.h"
8 
9 namespace chromeos {
10 
TEST(AuthenticatorTest,EmailAddressNoOp)11 TEST(AuthenticatorTest, EmailAddressNoOp) {
12   const char lower_case[] = "user@what.com";
13   EXPECT_EQ(lower_case, Authenticator::Canonicalize(lower_case));
14 }
15 
TEST(AuthenticatorTest,EmailAddressIgnoreCaps)16 TEST(AuthenticatorTest, EmailAddressIgnoreCaps) {
17   EXPECT_EQ(Authenticator::Canonicalize("user@what.com"),
18             Authenticator::Canonicalize("UsEr@what.com"));
19 }
20 
TEST(AuthenticatorTest,EmailAddressIgnoreDomainCaps)21 TEST(AuthenticatorTest, EmailAddressIgnoreDomainCaps) {
22   EXPECT_EQ(Authenticator::Canonicalize("user@what.com"),
23             Authenticator::Canonicalize("UsEr@what.COM"));
24 }
25 
TEST(AuthenticatorTest,EmailAddressRejectOneUsernameDot)26 TEST(AuthenticatorTest, EmailAddressRejectOneUsernameDot) {
27   EXPECT_NE(Authenticator::Canonicalize("u.ser@what.com"),
28             Authenticator::Canonicalize("UsEr@what.com"));
29 }
30 
TEST(AuthenticatorTest,EmailAddressMatchWithOneUsernameDot)31 TEST(AuthenticatorTest, EmailAddressMatchWithOneUsernameDot) {
32   EXPECT_EQ(Authenticator::Canonicalize("u.ser@what.com"),
33             Authenticator::Canonicalize("U.sEr@what.com"));
34 }
35 
TEST(AuthenticatorTest,EmailAddressIgnoreOneUsernameDot)36 TEST(AuthenticatorTest, EmailAddressIgnoreOneUsernameDot) {
37   EXPECT_EQ(Authenticator::Canonicalize("us.er@gmail.com"),
38             Authenticator::Canonicalize("UsEr@gmail.com"));
39 }
40 
TEST(AuthenticatorTest,EmailAddressIgnoreManyUsernameDots)41 TEST(AuthenticatorTest, EmailAddressIgnoreManyUsernameDots) {
42   EXPECT_EQ(Authenticator::Canonicalize("u.ser@gmail.com"),
43             Authenticator::Canonicalize("Us.E.r@gmail.com"));
44 }
45 
TEST(AuthenticatorTest,EmailAddressIgnoreConsecutiveUsernameDots)46 TEST(AuthenticatorTest, EmailAddressIgnoreConsecutiveUsernameDots) {
47   EXPECT_EQ(Authenticator::Canonicalize("use.r@gmail.com"),
48             Authenticator::Canonicalize("Us....E.r@gmail.com"));
49 }
50 
TEST(AuthenticatorTest,EmailAddressDifferentOnesRejected)51 TEST(AuthenticatorTest, EmailAddressDifferentOnesRejected) {
52   EXPECT_NE(Authenticator::Canonicalize("who@what.com"),
53             Authenticator::Canonicalize("Us....E.r@what.com"));
54 }
55 
TEST(AuthenticatorTest,EmailAddressIgnorePlusSuffix)56 TEST(AuthenticatorTest, EmailAddressIgnorePlusSuffix) {
57   const char with_plus[] = "user+cc@what.com";
58   EXPECT_EQ(with_plus, Authenticator::Canonicalize(with_plus));
59 }
60 
TEST(AuthenticatorTest,EmailAddressIgnoreMultiPlusSuffix)61 TEST(AuthenticatorTest, EmailAddressIgnoreMultiPlusSuffix) {
62   const char multi_plus[] = "user+cc+bcc@what.com";
63   EXPECT_EQ(multi_plus, Authenticator::Canonicalize(multi_plus));
64 }
65 
66 }  // namespace chromeos
67