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