Commit ef326b6a authored by Rakesh Soma's avatar Rakesh Soma Committed by Commit Bot

Add show_tos param to gaia endpoint URL instead of command_line switch

to support TOS acceptance feature in previous versions of chrome as well.

Bug: 1045536
Change-Id: I7ba5fd35549acf10d5335960bb77c61a7470d484
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2082111
Commit-Queue: Yusuf Sengul <yusufsn@google.com>
Reviewed-by: default avatarYusuf Sengul <yusufsn@google.com>
Auto-Submit: Rakesh Soma <rakeshsoma@google.com>
Cr-Commit-Position: refs/heads/master@{#746118}
parent 895ffd05
...@@ -31,15 +31,11 @@ void CGaiaCredential::FinalRelease() { ...@@ -31,15 +31,11 @@ void CGaiaCredential::FinalRelease() {
HRESULT CGaiaCredential::GetUserGlsCommandline( HRESULT CGaiaCredential::GetUserGlsCommandline(
base::CommandLine* command_line) { base::CommandLine* command_line) {
// Don't show tos when GEM isn't enabled. // In default add user flow, the user has to accept tos
if (IsGemEnabled()) { // every time. So we need to set the show_tos switch to 1.
// In default add user flow, the user has to accept tos bool show_tos = IsGemEnabled();
// every time. So we need to set the show_tos switch to 1.
command_line->AppendSwitchASCII(kShowTosSwitch, "1");
}
HRESULT hr = SetGaiaEndpointCommandLineIfNeeded( HRESULT hr = SetGaiaEndpointCommandLineIfNeeded(
L"ep_setup_url", kGaiaSetupPath, IsGemEnabled(), command_line); L"ep_setup_url", kGaiaSetupPath, IsGemEnabled(), show_tos, command_line);
if (FAILED(hr)) { if (FAILED(hr)) {
LOGFN(ERROR) << "Setting gaia url for gaia credential failed"; LOGFN(ERROR) << "Setting gaia url for gaia credential failed";
return E_FAIL; return E_FAIL;
......
...@@ -187,13 +187,9 @@ TEST_P(GcpGaiaCredentialGetSerializationBaseTest, Finish) { ...@@ -187,13 +187,9 @@ TEST_P(GcpGaiaCredentialGetSerializationBaseTest, Finish) {
if (is_gem_features_enabled) { if (is_gem_features_enabled) {
ASSERT_EQ(S_OK, hr); ASSERT_EQ(S_OK, hr);
ASSERT_EQ(1u, accept_tos); ASSERT_EQ(1u, accept_tos);
// Verify command line switch for show_tos.
ASSERT_EQ("1", test->GetShowTosFromCmdLine());
} else { } else {
ASSERT_TRUE(FAILED(hr)); ASSERT_TRUE(FAILED(hr));
ASSERT_EQ(0u, accept_tos); ASSERT_EQ(0u, accept_tos);
// Verify command line switch for show_tos.
ASSERT_EQ("0", test->GetShowTosFromCmdLine());
} }
} }
......
...@@ -27,19 +27,16 @@ void COtherUserGaiaCredential::FinalRelease() { ...@@ -27,19 +27,16 @@ void COtherUserGaiaCredential::FinalRelease() {
HRESULT COtherUserGaiaCredential::GetUserGlsCommandline( HRESULT COtherUserGaiaCredential::GetUserGlsCommandline(
base::CommandLine* command_line) { base::CommandLine* command_line) {
// Don't show tos when GEM isn't enabled.
if (IsGemEnabled()) {
// In default other user flow, the user has to accept tos // In default other user flow, the user has to accept tos
// every time. So we need to set the show_tos switch to 1. // every time. So we need to set the show_tos switch to 1.
command_line->AppendSwitchASCII(kShowTosSwitch, "1"); bool show_tos = IsGemEnabled();
} HRESULT hr = SetGaiaEndpointCommandLineIfNeeded(
L"ep_setup_url", kGaiaSetupPath, IsGemEnabled(), show_tos,
HRESULT hr = SetGaiaEndpointCommandLineIfNeeded( command_line);
L"ep_setup_url", kGaiaSetupPath, IsGemEnabled(), command_line); if (FAILED(hr)) {
if (FAILED(hr)) { LOGFN(ERROR) << "Setting gaia url for gaia credential failed";
LOGFN(ERROR) << "Setting gaia url for gaia credential failed"; return E_FAIL;
return E_FAIL; }
}
return S_OK; return S_OK;
} }
} // namespace credential_provider } // namespace credential_provider
...@@ -197,17 +197,15 @@ TEST_P(GcpOtherUserCredentialGlsTest, GetUserGlsCommandLine) { ...@@ -197,17 +197,15 @@ TEST_P(GcpOtherUserCredentialGlsTest, GetUserGlsCommandLine) {
EXPECT_TRUE(command_line.HasSwitch(kGcpwSigninSwitch)); EXPECT_TRUE(command_line.HasSwitch(kGcpwSigninSwitch));
EXPECT_TRUE(command_line.HasSwitch(switches::kDisableExtensions)); EXPECT_TRUE(command_line.HasSwitch(switches::kDisableExtensions));
ASSERT_EQ(is_gem_features_enabled ? "1" : "",
command_line.GetSwitchValueASCII(kShowTosSwitch));
if (is_ep_url_set) { if (is_ep_url_set) {
ASSERT_EQ("http://login.com/", ASSERT_EQ("http://login.com/",
command_line.GetSwitchValueASCII(switches::kGaiaUrl)); command_line.GetSwitchValueASCII(switches::kGaiaUrl));
ASSERT_TRUE(gcpw_path.empty()); ASSERT_TRUE(gcpw_path.empty());
} else if (is_gem_features_enabled) { } else if (is_gem_features_enabled) {
ASSERT_EQ(gcpw_path, ASSERT_EQ(gcpw_path, base::StringPrintf(
base::StringPrintf("embedded/setup/windows?device_id=%s", "embedded/setup/windows?device_id=%s&show_tos=1",
device_id.c_str())); device_id.c_str()));
ASSERT_TRUE(command_line.GetSwitchValueASCII(switches::kGaiaUrl).empty()); ASSERT_TRUE(command_line.GetSwitchValueASCII(switches::kGaiaUrl).empty());
} else { } else {
ASSERT_TRUE(command_line.GetSwitchValueASCII(switches::kGaiaUrl).empty()); ASSERT_TRUE(command_line.GetSwitchValueASCII(switches::kGaiaUrl).empty());
......
...@@ -199,9 +199,9 @@ TEST_P(GcpGaiaCredentialGlsTest, GetUserGlsCommandLine) { ...@@ -199,9 +199,9 @@ TEST_P(GcpGaiaCredentialGlsTest, GetUserGlsCommandLine) {
command_line.GetSwitchValueASCII(switches::kGaiaUrl)); command_line.GetSwitchValueASCII(switches::kGaiaUrl));
ASSERT_TRUE(gcpw_path.empty()); ASSERT_TRUE(gcpw_path.empty());
} else if (is_gem_features_enabled) { } else if (is_gem_features_enabled) {
ASSERT_EQ(gcpw_path, ASSERT_EQ(gcpw_path, base::StringPrintf(
base::StringPrintf("embedded/setup/windows?device_id=%s", "embedded/setup/windows?device_id=%s&show_tos=1",
device_id.c_str())); device_id.c_str()));
ASSERT_TRUE(command_line.GetSwitchValueASCII(switches::kGaiaUrl).empty()); ASSERT_TRUE(command_line.GetSwitchValueASCII(switches::kGaiaUrl).empty());
} else { } else {
ASSERT_TRUE(command_line.GetSwitchValueASCII(switches::kGaiaUrl).empty()); ASSERT_TRUE(command_line.GetSwitchValueASCII(switches::kGaiaUrl).empty());
......
...@@ -952,13 +952,14 @@ HRESULT GenerateDeviceId(std::string* device_id) { ...@@ -952,13 +952,14 @@ HRESULT GenerateDeviceId(std::string* device_id) {
HRESULT SetGaiaEndpointCommandLineIfNeeded(const wchar_t* override_registry_key, HRESULT SetGaiaEndpointCommandLineIfNeeded(const wchar_t* override_registry_key,
const std::string& default_endpoint, const std::string& default_endpoint,
bool provide_deviceid, bool provide_deviceid,
bool show_tos,
base::CommandLine* command_line) { base::CommandLine* command_line) {
// Registry specified endpoint. // Registry specified endpoint.
wchar_t endpoint_url_setting[256]; wchar_t endpoint_url_setting[256];
ULONG endpoint_url_length = base::size(endpoint_url_setting); ULONG endpoint_url_length = base::size(endpoint_url_setting);
if (SUCCEEDED(GetGlobalFlag(override_registry_key, endpoint_url_setting, HRESULT hr = GetGlobalFlag(override_registry_key, endpoint_url_setting,
&endpoint_url_length)) && &endpoint_url_length);
endpoint_url_setting[0]) { if (SUCCEEDED(hr) && endpoint_url_setting[0]) {
GURL endpoint_url(endpoint_url_setting); GURL endpoint_url(endpoint_url_setting);
if (endpoint_url.is_valid()) { if (endpoint_url.is_valid()) {
command_line->AppendSwitchASCII(switches::kGaiaUrl, command_line->AppendSwitchASCII(switches::kGaiaUrl,
...@@ -966,15 +967,22 @@ HRESULT SetGaiaEndpointCommandLineIfNeeded(const wchar_t* override_registry_key, ...@@ -966,15 +967,22 @@ HRESULT SetGaiaEndpointCommandLineIfNeeded(const wchar_t* override_registry_key,
command_line->AppendSwitchASCII(kGcpwEndpointPathSwitch, command_line->AppendSwitchASCII(kGcpwEndpointPathSwitch,
endpoint_url.path().substr(1)); endpoint_url.path().substr(1));
} }
} else if (provide_deviceid) { return S_OK;
}
if (provide_deviceid || show_tos) {
std::string device_id; std::string device_id;
HRESULT hr = GenerateDeviceId(&device_id); hr = GenerateDeviceId(&device_id);
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
command_line->AppendSwitchASCII( command_line->AppendSwitchASCII(
kGcpwEndpointPathSwitch, kGcpwEndpointPathSwitch,
base::StringPrintf("%s?device_id=%s", default_endpoint.c_str(), base::StringPrintf("%s?device_id=%s&show_tos=%d",
device_id.c_str())); default_endpoint.c_str(), device_id.c_str(),
return S_OK; show_tos ? 1 : 0));
} else if (show_tos) {
command_line->AppendSwitchASCII(
kGcpwEndpointPathSwitch,
base::StringPrintf("%s?show_tos=1", default_endpoint.c_str()));
} }
} }
return S_OK; return S_OK;
......
...@@ -341,6 +341,7 @@ HRESULT GenerateDeviceId(std::string* device_id); ...@@ -341,6 +341,7 @@ HRESULT GenerateDeviceId(std::string* device_id);
HRESULT SetGaiaEndpointCommandLineIfNeeded(const wchar_t* override_registry_key, HRESULT SetGaiaEndpointCommandLineIfNeeded(const wchar_t* override_registry_key,
const std::string& default_endpoint, const std::string& default_endpoint,
bool provide_deviceid, bool provide_deviceid,
bool show_tos,
base::CommandLine* command_line); base::CommandLine* command_line);
// Returns the file path to installed chrome.exe. // Returns the file path to installed chrome.exe.
......
...@@ -57,8 +57,9 @@ HRESULT CReauthCredential::GetUserGlsCommandline( ...@@ -57,8 +57,9 @@ HRESULT CReauthCredential::GetUserGlsCommandline(
// 1. We need to append this switch irrespective of whether its a // 1. We need to append this switch irrespective of whether its a
// reauth flow vs add user flow. // reauth flow vs add user flow.
// 2. We only show tos for GEM usecases. // 2. We only show tos for GEM usecases.
bool show_tos = false;
if (!CheckIfTosAccepted() && IsGemEnabled()) if (!CheckIfTosAccepted() && IsGemEnabled())
command_line->AppendSwitchASCII(kShowTosSwitch, "1"); show_tos = true;
// If this is an existing user with an SID, try to get its gaia id and pass // If this is an existing user with an SID, try to get its gaia id and pass
// it to the GLS for verification. // it to the GLS for verification.
...@@ -83,11 +84,13 @@ HRESULT CReauthCredential::GetUserGlsCommandline( ...@@ -83,11 +84,13 @@ HRESULT CReauthCredential::GetUserGlsCommandline(
OLE2CW(email_for_reauth_)); OLE2CW(email_for_reauth_));
// Use kGaiaReauthPath when there is no email_for_reauth_ field set. // Use kGaiaReauthPath when there is no email_for_reauth_ field set.
hr = SetGaiaEndpointCommandLineIfNeeded(L"ep_reauth_url", kGaiaReauthPath, hr = SetGaiaEndpointCommandLineIfNeeded(L"ep_reauth_url", kGaiaReauthPath,
IsGemEnabled(), command_line); IsGemEnabled(), show_tos,
command_line);
} else { } else {
// Use kGaiaSetupPath when there is no email_for_reauth_ field set. // Use kGaiaSetupPath when there is no email_for_reauth_ field set.
hr = SetGaiaEndpointCommandLineIfNeeded(L"ep_reauth_url", kGaiaSetupPath, hr = SetGaiaEndpointCommandLineIfNeeded(L"ep_reauth_url", kGaiaSetupPath,
IsGemEnabled(), command_line); IsGemEnabled(), show_tos,
command_line);
} }
if (FAILED(hr)) { if (FAILED(hr)) {
......
...@@ -292,9 +292,11 @@ class GcpReauthCredentialGlsRunnerTest : public GlsRunnerTestBase {}; ...@@ -292,9 +292,11 @@ class GcpReauthCredentialGlsRunnerTest : public GlsRunnerTestBase {};
// 1. Is gem features enabled / disabled. // 1. Is gem features enabled / disabled.
// 2. Is ep_url already set via registry. // 2. Is ep_url already set via registry.
// 3. Does reauth email exist. // 3. Does reauth email exist.
// 4. Did user already accept TOS.
class GcpReauthCredentialGlsTest class GcpReauthCredentialGlsTest
: public GcpReauthCredentialGlsRunnerTest, : public GcpReauthCredentialGlsRunnerTest,
public ::testing::WithParamInterface<std::tuple<bool, bool, bool>> {}; public ::testing::WithParamInterface<std::tuple<bool, bool, bool, bool>> {
};
TEST_P(GcpReauthCredentialGlsTest, GetUserGlsCommandLine) { TEST_P(GcpReauthCredentialGlsTest, GetUserGlsCommandLine) {
USES_CONVERSION; USES_CONVERSION;
...@@ -339,6 +341,10 @@ TEST_P(GcpReauthCredentialGlsTest, GetUserGlsCommandLine) { ...@@ -339,6 +341,10 @@ TEST_P(GcpReauthCredentialGlsTest, GetUserGlsCommandLine) {
A2COLE(test_data_storage.GetSuccessEmail().c_str())))); A2COLE(test_data_storage.GetSuccessEmail().c_str()))));
} }
const bool is_tos_accepted = std::get<3>(GetParam());
if (is_tos_accepted)
ASSERT_EQ(S_OK, SetUserProperty(OLE2CW(kSid), kKeyAcceptTos, 1));
// Get user gls command line and extract the kGaiaUrl & // Get user gls command line and extract the kGaiaUrl &
// kGcpwEndpointPathSwitch switch from it. // kGcpwEndpointPathSwitch switch from it.
Microsoft::WRL::ComPtr<ITestCredential> test_cred; Microsoft::WRL::ComPtr<ITestCredential> test_cred;
...@@ -367,13 +373,15 @@ TEST_P(GcpReauthCredentialGlsTest, GetUserGlsCommandLine) { ...@@ -367,13 +373,15 @@ TEST_P(GcpReauthCredentialGlsTest, GetUserGlsCommandLine) {
ASSERT_TRUE(gcpw_path.empty()); ASSERT_TRUE(gcpw_path.empty());
} else if (is_gem_features_enabled) { } else if (is_gem_features_enabled) {
if (set_email_for_reauth) { if (set_email_for_reauth) {
ASSERT_EQ(gcpw_path, ASSERT_EQ(
base::StringPrintf("embedded/reauth/windows?device_id=%s", gcpw_path,
device_id.c_str())); base::StringPrintf("embedded/reauth/windows?device_id=%s&show_tos=%d",
device_id.c_str(), is_tos_accepted ? 0 : 1));
} else { } else {
ASSERT_EQ(gcpw_path, ASSERT_EQ(
base::StringPrintf("embedded/setup/windows?device_id=%s", gcpw_path,
device_id.c_str())); base::StringPrintf("embedded/setup/windows?device_id=%s&show_tos=%d",
device_id.c_str(), is_tos_accepted ? 0 : 1));
} }
ASSERT_TRUE(command_line.GetSwitchValueASCII(switches::kGaiaUrl).empty()); ASSERT_TRUE(command_line.GetSwitchValueASCII(switches::kGaiaUrl).empty());
} else { } else {
...@@ -385,6 +393,7 @@ TEST_P(GcpReauthCredentialGlsTest, GetUserGlsCommandLine) { ...@@ -385,6 +393,7 @@ TEST_P(GcpReauthCredentialGlsTest, GetUserGlsCommandLine) {
INSTANTIATE_TEST_SUITE_P(All, INSTANTIATE_TEST_SUITE_P(All,
GcpReauthCredentialGlsTest, GcpReauthCredentialGlsTest,
::testing::Combine(::testing::Bool(), ::testing::Combine(::testing::Bool(),
::testing::Bool(),
::testing::Bool(), ::testing::Bool(),
::testing::Bool())); ::testing::Bool()));
...@@ -622,18 +631,18 @@ INSTANTIATE_TEST_SUITE_P(All, ...@@ -622,18 +631,18 @@ INSTANTIATE_TEST_SUITE_P(All,
::testing::Values(true, false)); ::testing::Values(true, false));
// Tests the normal reauth scenario. // Tests the normal reauth scenario.
// 1. Is gem features enabled. If enabled, tos should be tested out. // 1. Is gem features enabled.
// Otherwise, ToS shouldn't be set irrespective of the |kAcceptTos| // 2. Is tos already accepted.
// registry entry.
class GcpNormalReauthCredentialGlsRunnerTest class GcpNormalReauthCredentialGlsRunnerTest
: public GcpReauthCredentialGlsRunnerTest, : public GcpReauthCredentialGlsRunnerTest,
public ::testing::WithParamInterface<bool> {}; public ::testing::WithParamInterface<std::tuple<bool, bool>> {};
TEST_P(GcpNormalReauthCredentialGlsRunnerTest, WithGemFeatures) { TEST_P(GcpNormalReauthCredentialGlsRunnerTest, WithGemFeatures) {
USES_CONVERSION; USES_CONVERSION;
CredentialProviderSigninDialogTestDataStorage test_data_storage; CredentialProviderSigninDialogTestDataStorage test_data_storage;
bool is_gem_features_enabled = GetParam(); bool is_gem_features_enabled = std::get<0>(GetParam());
bool is_tos_already_accepted = std::get<1>(GetParam());
CComBSTR username = L"foo_bar"; CComBSTR username = L"foo_bar";
CComBSTR full_name = A2COLE(test_data_storage.GetSuccessFullName().c_str()); CComBSTR full_name = A2COLE(test_data_storage.GetSuccessFullName().c_str());
...@@ -651,13 +660,14 @@ TEST_P(GcpNormalReauthCredentialGlsRunnerTest, WithGemFeatures) { ...@@ -651,13 +660,14 @@ TEST_P(GcpNormalReauthCredentialGlsRunnerTest, WithGemFeatures) {
if (is_gem_features_enabled) { if (is_gem_features_enabled) {
// Set |kKeyEnableGemFeatures| registry entry to 1. // Set |kKeyEnableGemFeatures| registry entry to 1.
ASSERT_EQ(S_OK, SetGlobalFlagForTesting(kKeyEnableGemFeatures, 1u)); ASSERT_EQ(S_OK, SetGlobalFlagForTesting(kKeyEnableGemFeatures, 1u));
// Set that ToS was already accepted by the user.
ASSERT_EQ(S_OK, SetUserProperty(OLE2CW(sid), kKeyAcceptTos, 1u));
} else { } else {
// Set |kKeyEnableGemFeatures| registry entry to 0. // Set |kKeyEnableGemFeatures| registry entry to 0.
ASSERT_EQ(S_OK, SetGlobalFlagForTesting(kKeyEnableGemFeatures, 0u)); ASSERT_EQ(S_OK, SetGlobalFlagForTesting(kKeyEnableGemFeatures, 0u));
} }
if (is_tos_already_accepted)
ASSERT_EQ(S_OK, SetUserProperty(OLE2CW(sid), kKeyAcceptTos, 1u));
// Create provider and start logon. // Create provider and start logon.
Microsoft::WRL::ComPtr<ICredentialProviderCredential> cred; Microsoft::WRL::ComPtr<ICredentialProviderCredential> cred;
...@@ -673,12 +683,16 @@ TEST_P(GcpNormalReauthCredentialGlsRunnerTest, WithGemFeatures) { ...@@ -673,12 +683,16 @@ TEST_P(GcpNormalReauthCredentialGlsRunnerTest, WithGemFeatures) {
ASSERT_EQ(S_OK, StartLogonProcessAndWait()); ASSERT_EQ(S_OK, StartLogonProcessAndWait());
// Verify command line switch for show_tos. // Verify command line switch for show_tos.
ASSERT_EQ("0", test->GetShowTosFromCmdLine()); if (is_gem_features_enabled && !is_tos_already_accepted)
ASSERT_EQ("1", test->GetShowTosFromCmdLine());
else
ASSERT_EQ("0", test->GetShowTosFromCmdLine());
} }
INSTANTIATE_TEST_SUITE_P(All, INSTANTIATE_TEST_SUITE_P(All,
GcpNormalReauthCredentialGlsRunnerTest, GcpNormalReauthCredentialGlsRunnerTest,
::testing::Values(true, false)); ::testing::Combine(::testing::Bool(),
::testing::Bool()));
TEST_F(GcpReauthCredentialGlsRunnerTest, NormalReauthWithoutEmail) { TEST_F(GcpReauthCredentialGlsRunnerTest, NormalReauthWithoutEmail) {
USES_CONVERSION; USES_CONVERSION;
......
...@@ -338,10 +338,10 @@ HRESULT CTestCredentialBase<T>::ForkGaiaLogonStub( ...@@ -338,10 +338,10 @@ HRESULT CTestCredentialBase<T>::ForkGaiaLogonStub(
const base::CommandLine& command_line, const base::CommandLine& command_line,
CGaiaCredentialBase::UIProcessInfo* uiprocinfo) { CGaiaCredentialBase::UIProcessInfo* uiprocinfo) {
// Record command_line parameter "show_tos" into global variable. // Record command_line parameter "show_tos" into global variable.
std::string gcpw_path =
command_line.GetSwitchValueASCII(kGcpwEndpointPathSwitch);
show_tos_command_line_ = show_tos_command_line_ =
command_line.HasSwitch(kShowTosSwitch) (gcpw_path.find("show_tos=1") != std::string::npos) ? "1" : "0";
? command_line.GetSwitchValueASCII(kShowTosSwitch)
: "0";
if (fail_loading_gaia_logon_stub_) if (fail_loading_gaia_logon_stub_)
return E_FAIL; return E_FAIL;
......
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