Skip to content
Snippets Groups Projects
Commit 7b37cab5 authored by cmasone@chromium.org's avatar cmasone@chromium.org
Browse files

[Chrome OS] Respect periods in google apps account names

When logging in to @gmail.com accounts via the web, . characters are
ignored -- which we do on chrome OS.  When logging into google apps
accounts for OTHER domains, . characters should NOT be ignored.  We
were canonicalizing them out on Chrome OS, breaking login for apps
users who have . embedded in their usernames.

BUG=chromium-os:10397
TEST=unit tests, install on device and try cmasone@gmail.com, c.masone@gmail.com, why.you@mydomain.org and whyyou@mydomain.org.  The first three work, the last one does not, as expected.

Review URL: http://codereview.chromium.org/6089004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70318 0039d316-1c4b-4281-b951-d872f2087c98
parent ad382911
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,9 @@
namespace chromeos {
class LoginStatusConsumer;
// static
const char Authenticator::kSpecialCaseDomain[] = "gmail.com";
Authenticator::Authenticator(LoginStatusConsumer* consumer)
: consumer_(consumer) {
}
......@@ -26,7 +29,11 @@ std::string Authenticator::Canonicalize(const std::string& email_address) {
char at = '@';
base::SplitString(email_address, at, &parts);
DCHECK_EQ(parts.size(), 2U) << "email_address should have only one @";
RemoveChars(parts[0], ".", &parts[0]);
if (parts[1] == kSpecialCaseDomain) // only strip '.' for gmail accounts.
RemoveChars(parts[0], ".", &parts[0]);
// Technically the '+' handling here could be removed, as the google
// account servers do not tolerate them, so we don't need to either.
// TODO(cmasone): remove this, unless this code becomes obsolete altogether.
if (parts[0].find('+') != std::string::npos)
parts[0].erase(parts[0].find('+'));
std::string new_email = StringToLowerASCII(JoinString(parts, at));
......
......@@ -23,6 +23,9 @@ namespace chromeos {
// consumer_->OnPasswordChangeDetected() on the UI thread.
class Authenticator : public base::RefCountedThreadSafe<Authenticator> {
public:
// A domain which requires special-case parsing in canonicalization.
static const char kSpecialCaseDomain[];
explicit Authenticator(LoginStatusConsumer* consumer);
virtual ~Authenticator();
......
......@@ -23,19 +23,29 @@ TEST(AuthenticatorTest, EmailAddressIgnoreDomainCaps) {
Authenticator::Canonicalize("UsEr@what.COM"));
}
TEST(AuthenticatorTest, EmailAddressIgnoreOneUsernameDot) {
EXPECT_EQ(Authenticator::Canonicalize("us.er@what.com"),
TEST(AuthenticatorTest, EmailAddressRejectOneUsernameDot) {
EXPECT_NE(Authenticator::Canonicalize("u.ser@what.com"),
Authenticator::Canonicalize("UsEr@what.com"));
}
TEST(AuthenticatorTest, EmailAddressIgnoreManyUsernameDots) {
TEST(AuthenticatorTest, EmailAddressMatchWithOneUsernameDot) {
EXPECT_EQ(Authenticator::Canonicalize("u.ser@what.com"),
Authenticator::Canonicalize("Us.E.r@what.com"));
Authenticator::Canonicalize("U.sEr@what.com"));
}
TEST(AuthenticatorTest, EmailAddressIgnoreOneUsernameDot) {
EXPECT_EQ(Authenticator::Canonicalize("us.er@gmail.com"),
Authenticator::Canonicalize("UsEr@gmail.com"));
}
TEST(AuthenticatorTest, EmailAddressIgnoreManyUsernameDots) {
EXPECT_EQ(Authenticator::Canonicalize("u.ser@gmail.com"),
Authenticator::Canonicalize("Us.E.r@gmail.com"));
}
TEST(AuthenticatorTest, EmailAddressIgnoreConsecutiveUsernameDots) {
EXPECT_EQ(Authenticator::Canonicalize("use.r@what.com"),
Authenticator::Canonicalize("Us....E.r@what.com"));
EXPECT_EQ(Authenticator::Canonicalize("use.r@gmail.com"),
Authenticator::Canonicalize("Us....E.r@gmail.com"));
}
TEST(AuthenticatorTest, EmailAddressDifferentOnesRejected) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment