diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-07 04:26:37 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-07 04:26:37 +0000 |
commit | 6386cf58a85361fa20bba6ecfc23502e922b9a90 (patch) | |
tree | 06f9a9aa7e6bb8db149b53bc7489e69fa87c07fb /google_apis/gaia/gaia_auth_util_unittest.cc | |
parent | f2857ecf6c8da488feeca9b05cf2c046ea43e02f (diff) | |
download | chromium_src-6386cf58a85361fa20bba6ecfc23502e922b9a90.zip chromium_src-6386cf58a85361fa20bba6ecfc23502e922b9a90.tar.gz chromium_src-6386cf58a85361fa20bba6ecfc23502e922b9a90.tar.bz2 |
Moving google_apis and GaiaClient to src/google_apis.
TBR=mechanicalowners@chromium.org
BUG=145584
Review URL: https://chromiumcodereview.appspot.com/10928017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155312 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis/gaia/gaia_auth_util_unittest.cc')
-rw-r--r-- | google_apis/gaia/gaia_auth_util_unittest.cc | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/google_apis/gaia/gaia_auth_util_unittest.cc b/google_apis/gaia/gaia_auth_util_unittest.cc new file mode 100644 index 0000000..352c032 --- /dev/null +++ b/google_apis/gaia/gaia_auth_util_unittest.cc @@ -0,0 +1,87 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "google_apis/gaia/gaia_auth_util.h" + +#include "testing/gtest/include/gtest/gtest.h" + +namespace gaia { + +TEST(GaiaAuthUtilTest, EmailAddressNoOp) { + const char lower_case[] = "user@what.com"; + EXPECT_EQ(lower_case, CanonicalizeEmail(lower_case)); +} + +TEST(GaiaAuthUtilTest, EmailAddressIgnoreCaps) { + EXPECT_EQ(CanonicalizeEmail("user@what.com"), + CanonicalizeEmail("UsEr@what.com")); +} + +TEST(GaiaAuthUtilTest, EmailAddressIgnoreDomainCaps) { + EXPECT_EQ(CanonicalizeEmail("user@what.com"), + CanonicalizeEmail("UsEr@what.COM")); +} + +TEST(GaiaAuthUtilTest, EmailAddressRejectOneUsernameDot) { + EXPECT_NE(CanonicalizeEmail("u.ser@what.com"), + CanonicalizeEmail("UsEr@what.com")); +} + +TEST(GaiaAuthUtilTest, EmailAddressMatchWithOneUsernameDot) { + EXPECT_EQ(CanonicalizeEmail("u.ser@what.com"), + CanonicalizeEmail("U.sEr@what.com")); +} + +TEST(GaiaAuthUtilTest, EmailAddressIgnoreOneUsernameDot) { + EXPECT_EQ(CanonicalizeEmail("us.er@gmail.com"), + CanonicalizeEmail("UsEr@gmail.com")); +} + +TEST(GaiaAuthUtilTest, EmailAddressIgnoreManyUsernameDots) { + EXPECT_EQ(CanonicalizeEmail("u.ser@gmail.com"), + CanonicalizeEmail("Us.E.r@gmail.com")); +} + +TEST(GaiaAuthUtilTest, EmailAddressIgnoreConsecutiveUsernameDots) { + EXPECT_EQ(CanonicalizeEmail("use.r@gmail.com"), + CanonicalizeEmail("Us....E.r@gmail.com")); +} + +TEST(GaiaAuthUtilTest, EmailAddressDifferentOnesRejected) { + EXPECT_NE(CanonicalizeEmail("who@what.com"), + CanonicalizeEmail("Us....E.r@what.com")); +} + +TEST(GaiaAuthUtilTest, EmailAddressIgnorePlusSuffix) { + const char with_plus[] = "user+cc@what.com"; + EXPECT_EQ(with_plus, CanonicalizeEmail(with_plus)); +} + +TEST(GaiaAuthUtilTest, EmailAddressIgnoreMultiPlusSuffix) { + const char multi_plus[] = "user+cc+bcc@what.com"; + EXPECT_EQ(multi_plus, CanonicalizeEmail(multi_plus)); +} + +TEST(GaiaAuthUtilTest, CanonicalizeDomain) { + const char domain[] = "example.com"; + EXPECT_EQ(domain, CanonicalizeDomain("example.com")); + EXPECT_EQ(domain, CanonicalizeDomain("EXAMPLE.cOm")); +} + +TEST(GaiaAuthUtilTest, ExtractDomainName) { + const char domain[] = "example.com"; + EXPECT_EQ(domain, ExtractDomainName("who@example.com")); + EXPECT_EQ(domain, ExtractDomainName("who@EXAMPLE.cOm")); +} + +TEST(GaiaAuthUtilTest, SanitizeMissingDomain) { + EXPECT_EQ("nodomain@gmail.com", SanitizeEmail("nodomain")); +} + +TEST(GaiaAuthUtilTest, SanitizeExistingDomain) { + const char existing[] = "test@example.com"; + EXPECT_EQ(existing, SanitizeEmail(existing)); +} + +} // namespace gaia |