Commit 3fc057c5 authored by droger's avatar droger Committed by Commit Bot

[Signin] Rename obfuscated_gaia_id into gaia_id

BUG=730589

Review-Url: https://codereview.chromium.org/2944383006
Cr-Commit-Position: refs/heads/master@{#481935}
parent af058bef
......@@ -156,7 +156,7 @@ void DiceResponseHandler::ProcessDiceHeader(
switch (dice_params.user_intention) {
case signin::DiceAction::SIGNIN:
ProcessDiceSigninHeader(dice_params.obfuscated_gaia_id, dice_params.email,
ProcessDiceSigninHeader(dice_params.gaia_id, dice_params.email,
dice_params.authorization_code);
return;
case signin::DiceAction::SIGNOUT:
......
......@@ -30,7 +30,7 @@ namespace {
const char kAuthorizationCode[] = "authorization_code";
const char kEmail[] = "email";
const char kObfuscatedGaiaID[] = "obfuscated_gaia_id";
const char kGaiaID[] = "gaia_id";
const int kSessionIndex = 42;
// TestSigninClient implementation that intercepts the GaiaAuthConsumer and
......@@ -85,7 +85,7 @@ class DiceResponseHandlerTest : public testing::Test {
DiceResponseParams MakeDiceParams(DiceAction action) {
DiceResponseParams dice_params;
dice_params.user_intention = action;
dice_params.obfuscated_gaia_id = kObfuscatedGaiaID;
dice_params.gaia_id = kGaiaID;
dice_params.email = kEmail;
dice_params.session_index = kSessionIndex;
dice_params.authorization_code = kAuthorizationCode;
......@@ -105,8 +105,7 @@ class DiceResponseHandlerTest : public testing::Test {
// Checks that a SIGNIN action triggers a token exchange request.
TEST_F(DiceResponseHandlerTest, Signin) {
DiceResponseParams dice_params = MakeDiceParams(DiceAction::SIGNIN);
ASSERT_FALSE(
token_service_.RefreshTokenIsAvailable(dice_params.obfuscated_gaia_id));
ASSERT_FALSE(token_service_.RefreshTokenIsAvailable(dice_params.gaia_id));
dice_response_handler_.ProcessDiceHeader(dice_params);
// Check that a GaiaAuthFetcher has been created.
ASSERT_THAT(signin_client_.consumer_, testing::NotNull());
......@@ -114,16 +113,14 @@ TEST_F(DiceResponseHandlerTest, Signin) {
signin_client_.consumer_->OnClientOAuthSuccess(
GaiaAuthConsumer::ClientOAuthResult("refresh_token", "access_token", 10));
// Check that the token has been inserted in the token service.
EXPECT_TRUE(
token_service_.RefreshTokenIsAvailable(dice_params.obfuscated_gaia_id));
EXPECT_TRUE(token_service_.RefreshTokenIsAvailable(dice_params.gaia_id));
}
// Checks that a second token for the same account is not requested when a
// request is already in flight.
TEST_F(DiceResponseHandlerTest, SigninRepeatedWithSameAccount) {
DiceResponseParams dice_params = MakeDiceParams(DiceAction::SIGNIN);
ASSERT_FALSE(
token_service_.RefreshTokenIsAvailable(dice_params.obfuscated_gaia_id));
ASSERT_FALSE(token_service_.RefreshTokenIsAvailable(dice_params.gaia_id));
dice_response_handler_.ProcessDiceHeader(dice_params);
// Check that a GaiaAuthFetcher has been created.
GaiaAuthConsumer* consumer = signin_client_.consumer_;
......@@ -137,8 +134,7 @@ TEST_F(DiceResponseHandlerTest, SigninRepeatedWithSameAccount) {
consumer->OnClientOAuthSuccess(
GaiaAuthConsumer::ClientOAuthResult("refresh_token", "access_token", 10));
// Check that the token has been inserted in the token service.
EXPECT_TRUE(
token_service_.RefreshTokenIsAvailable(dice_params.obfuscated_gaia_id));
EXPECT_TRUE(token_service_.RefreshTokenIsAvailable(dice_params.gaia_id));
}
// Checks that two SIGNIN requests can happen concurrently.
......@@ -146,11 +142,9 @@ TEST_F(DiceResponseHandlerTest, SigninWithTwoAccounts) {
DiceResponseParams dice_params_1 = MakeDiceParams(DiceAction::SIGNIN);
DiceResponseParams dice_params_2 = MakeDiceParams(DiceAction::SIGNIN);
dice_params_2.email = "other_email";
dice_params_2.obfuscated_gaia_id = "other_gaia_id";
ASSERT_FALSE(
token_service_.RefreshTokenIsAvailable(dice_params_1.obfuscated_gaia_id));
ASSERT_FALSE(
token_service_.RefreshTokenIsAvailable(dice_params_2.obfuscated_gaia_id));
dice_params_2.gaia_id = "other_gaia_id";
ASSERT_FALSE(token_service_.RefreshTokenIsAvailable(dice_params_1.gaia_id));
ASSERT_FALSE(token_service_.RefreshTokenIsAvailable(dice_params_2.gaia_id));
// Start first request.
dice_response_handler_.ProcessDiceHeader(dice_params_1);
// Check that a GaiaAuthFetcher has been created.
......@@ -165,20 +159,17 @@ TEST_F(DiceResponseHandlerTest, SigninWithTwoAccounts) {
consumer_1->OnClientOAuthSuccess(
GaiaAuthConsumer::ClientOAuthResult("refresh_token", "access_token", 10));
// Check that the token has been inserted in the token service.
EXPECT_TRUE(
token_service_.RefreshTokenIsAvailable(dice_params_1.obfuscated_gaia_id));
EXPECT_TRUE(token_service_.RefreshTokenIsAvailable(dice_params_1.gaia_id));
// Simulate GaiaAuthFetcher success for the second request.
consumer_2->OnClientOAuthSuccess(
GaiaAuthConsumer::ClientOAuthResult("refresh_token", "access_token", 10));
// Check that the token has been inserted in the token service.
EXPECT_TRUE(
token_service_.RefreshTokenIsAvailable(dice_params_2.obfuscated_gaia_id));
EXPECT_TRUE(token_service_.RefreshTokenIsAvailable(dice_params_2.gaia_id));
}
TEST_F(DiceResponseHandlerTest, Timeout) {
DiceResponseParams dice_params = MakeDiceParams(DiceAction::SIGNIN);
ASSERT_FALSE(
token_service_.RefreshTokenIsAvailable(dice_params.obfuscated_gaia_id));
ASSERT_FALSE(token_service_.RefreshTokenIsAvailable(dice_params.gaia_id));
dice_response_handler_.ProcessDiceHeader(dice_params);
// Check that a GaiaAuthFetcher has been created.
ASSERT_THAT(signin_client_.consumer_, testing::NotNull());
......
......@@ -50,7 +50,7 @@ DiceResponseParams DiceHeaderHelper::BuildDiceResponseParams(
if (key_name == kActionAttrName) {
params.user_intention = GetDiceActionFromHeader(value);
} else if (key_name == kIdAttrName) {
params.obfuscated_gaia_id = value;
params.gaia_id = value;
} else if (key_name == kEmailAttrName) {
params.email = value;
} else if (key_name == kAuthUserAttrName) {
......@@ -64,7 +64,7 @@ DiceResponseParams DiceHeaderHelper::BuildDiceResponseParams(
}
}
if (params.obfuscated_gaia_id.empty() || params.email.empty() ||
if (params.gaia_id.empty() || params.email.empty() ||
params.session_index == -1) {
DLOG(WARNING) << "Missing parameters for Dice header.";
params.user_intention = DiceAction::NONE;
......
......@@ -82,7 +82,7 @@ struct DiceResponseParams {
// Gaia ID of the account signed in or signed out (which may be a secondary
// account). When |user_intention| is SIGNOUT, this is the ID of the primary
// account.
std::string obfuscated_gaia_id;
std::string gaia_id;
// Email of the account signed in or signed out. When |user_intention| is
// SIGNOUT, this is the email of the primary account.
......
......@@ -243,16 +243,16 @@ TEST_F(SigninHeaderHelperTest, TestDiceInvalidResponseParams) {
TEST_F(SigninHeaderHelperTest, TestBuildDiceResponseParams) {
const char kAuthorizationCode[] = "authorization_code";
const char kEmail[] = "foo@example.com";
const char kObfuscatedGaiaID[] = "obfuscated_gaia_id";
const char kGaiaID[] = "gaia_id";
const int kSessionIndex = 42;
{
// Signin response.
DiceResponseParams params = BuildDiceResponseParams(base::StringPrintf(
"action=SIGNIN,id=%s,email=%s,authuser=%i,authorization_code=%s",
kObfuscatedGaiaID, kEmail, kSessionIndex, kAuthorizationCode));
kGaiaID, kEmail, kSessionIndex, kAuthorizationCode));
EXPECT_EQ(DiceAction::SIGNIN, params.user_intention);
EXPECT_EQ(kObfuscatedGaiaID, params.obfuscated_gaia_id);
EXPECT_EQ(kGaiaID, params.gaia_id);
EXPECT_EQ(kEmail, params.email);
EXPECT_EQ(kSessionIndex, params.session_index);
EXPECT_EQ(kAuthorizationCode, params.authorization_code);
......@@ -261,10 +261,10 @@ TEST_F(SigninHeaderHelperTest, TestBuildDiceResponseParams) {
{
// Signout response.
DiceResponseParams params = BuildDiceResponseParams(
base::StringPrintf("action=SIGNOUT,id=%s,email=%s,authuser=%i",
kObfuscatedGaiaID, kEmail, kSessionIndex));
base::StringPrintf("action=SIGNOUT,id=%s,email=%s,authuser=%i", kGaiaID,
kEmail, kSessionIndex));
EXPECT_EQ(DiceAction::SIGNOUT, params.user_intention);
EXPECT_EQ(kObfuscatedGaiaID, params.obfuscated_gaia_id);
EXPECT_EQ(kGaiaID, params.gaia_id);
EXPECT_EQ(kEmail, params.email);
EXPECT_EQ(kSessionIndex, params.session_index);
EXPECT_EQ("", params.authorization_code);
......@@ -273,16 +273,16 @@ TEST_F(SigninHeaderHelperTest, TestBuildDiceResponseParams) {
{
// Missing authorization code.
DiceResponseParams params = BuildDiceResponseParams(
base::StringPrintf("action=SIGNIN,id=%s,email=%s,authuser=%i",
kObfuscatedGaiaID, kEmail, kSessionIndex));
base::StringPrintf("action=SIGNIN,id=%s,email=%s,authuser=%i", kGaiaID,
kEmail, kSessionIndex));
EXPECT_EQ(DiceAction::NONE, params.user_intention);
}
{
// Missing non-optional field (email).
DiceResponseParams params = BuildDiceResponseParams(base::StringPrintf(
"action=SIGNIN,id=%s,authuser=%i,authorization_code=%s",
kObfuscatedGaiaID, kSessionIndex, kAuthorizationCode));
"action=SIGNIN,id=%s,authuser=%i,authorization_code=%s", kGaiaID,
kSessionIndex, kAuthorizationCode));
EXPECT_EQ(DiceAction::NONE, params.user_intention);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment