Commit 642f75b2 authored by rajendrant's avatar rajendrant Committed by Chromium LUCI CQ

LoginDetection: Do not consider redirects for max navigations limit

Currently redirects are also counted for applying the maximum number of
navigations limit between OAuth start and complete. This CL changes it
to only consider the navigations and not the redirects.

Bug: 1162327
Change-Id: I44d11f4c04256bebeeb743513f605720092ae2c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2604946
Commit-Queue: rajendrant <rajendrant@chromium.org>
Reviewed-by: default avatarMichael Crouse <mcrouse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#839714}
parent c9883028
...@@ -84,6 +84,8 @@ base::Optional<GURL> OAuthLoginDetector::GetSuccessfulLoginFlowSite( ...@@ -84,6 +84,8 @@ base::Optional<GURL> OAuthLoginDetector::GetSuccessfulLoginFlowSite(
} }
} }
} }
if (login_flow_info_)
login_flow_info_->count_navigations_since_login_flow_start++;
return base::nullopt; return base::nullopt;
} }
...@@ -125,7 +127,6 @@ bool OAuthLoginDetector::CheckSuccessfulLoginCompletion( ...@@ -125,7 +127,6 @@ bool OAuthLoginDetector::CheckSuccessfulLoginCompletion(
// site. // site.
if (GetSiteNameForURL(navigation_url) == if (GetSiteNameForURL(navigation_url) ==
GetSiteNameForURL(login_flow_info_->oauth_provider_site)) { GetSiteNameForURL(login_flow_info_->oauth_provider_site)) {
login_flow_info_->count_navigations_since_login_flow_start++;
return false; return false;
} }
...@@ -139,12 +140,9 @@ bool OAuthLoginDetector::CheckSuccessfulLoginCompletion( ...@@ -139,12 +140,9 @@ bool OAuthLoginDetector::CheckSuccessfulLoginCompletion(
// PopUp based login completion flow should only navigate within the OAuth // PopUp based login completion flow should only navigate within the OAuth
// provider site. // provider site.
if (popup_opener_navigation_site_) { if (popup_opener_navigation_site_)
login_flow_info_.reset(); login_flow_info_.reset();
return false;
}
login_flow_info_->count_navigations_since_login_flow_start++;
return false; return false;
} }
......
...@@ -86,12 +86,29 @@ TEST_F(OAuthLoginDetectorTest, LoginNotDetectedForHTTP) { ...@@ -86,12 +86,29 @@ TEST_F(OAuthLoginDetectorTest, LoginNotDetectedForHTTP) {
// Test that small number of intermediate navigations within OAuth start and // Test that small number of intermediate navigations within OAuth start and
// completion are allowed. // completion are allowed.
TEST_F(OAuthLoginDetectorTest, IntermediateNavigationsAfterOAuthStart) { TEST_F(OAuthLoginDetectorTest, IntermediateNavigationsAfterOAuthStart) {
EXPECT_EQ(GURL("https://foo.com/"), EXPECT_FALSE(oauth_login_detector_->GetSuccessfulLoginFlowSite(
*oauth_login_detector_->GetSuccessfulLoginFlowSite( GURL("https://foo.com/login.html"),
GURL("https://foo.com/login.html"), {
{GURL("https://oauth.com/authenticate?client_id=123"), GURL("https://oauth.com/authenticate?client_id=123"),
GURL("https://oauth.com/login"), GURL("https://oauth.com/login"),
GURL("https://foo.com/redirect?code=secret")})); }));
EXPECT_FALSE(oauth_login_detector_->GetSuccessfulLoginFlowSite(
GURL("https://oauth.com/login"),
{
GURL("https://oauth.com/login?username=123&password=123"),
GURL("https://oauth.com/relogin"),
}));
EXPECT_FALSE(oauth_login_detector_->GetSuccessfulLoginFlowSite(
GURL("https://oauth.com/relogin"),
{
GURL("https://oauth.com/login?username=123&password=123"),
GURL("https://oauth.com/relogin"),
}));
EXPECT_TRUE(oauth_login_detector_->GetSuccessfulLoginFlowSite(
GURL("https://oauth.com/relogin"),
{GURL("https://oauth.com/login?username=123&password=123"),
GURL("https://oauth.com/loginsuccess"),
GURL("https://foo.com/redirect?code=secret")}));
EXPECT_FALSE(oauth_login_detector_->GetPopUpLoginFlowSite()); EXPECT_FALSE(oauth_login_detector_->GetPopUpLoginFlowSite());
} }
...@@ -100,13 +117,50 @@ TEST_F(OAuthLoginDetectorTest, IntermediateNavigationsAfterOAuthStart) { ...@@ -100,13 +117,50 @@ TEST_F(OAuthLoginDetectorTest, IntermediateNavigationsAfterOAuthStart) {
TEST_F(OAuthLoginDetectorTest, TooManyIntermediateNavigationsAfterOAuthStart) { TEST_F(OAuthLoginDetectorTest, TooManyIntermediateNavigationsAfterOAuthStart) {
EXPECT_FALSE(oauth_login_detector_->GetSuccessfulLoginFlowSite( EXPECT_FALSE(oauth_login_detector_->GetSuccessfulLoginFlowSite(
GURL("https://foo.com/login.html"), GURL("https://foo.com/login.html"),
{GURL("https://oauth.com/authenticate?client_id=123"), {
GURL("https://oauth.com/login"), GURL("https://oauth.com/login"), GURL("https://oauth.com/authenticate?client_id=123"),
GURL("https://oauth.com/login"), GURL("https://oauth.com/login"), GURL("https://oauth.com/login"),
}));
EXPECT_FALSE(oauth_login_detector_->GetSuccessfulLoginFlowSite(
GURL("https://oauth.com/login"),
{
GURL("https://oauth.com/login?username=123&password=123"),
GURL("https://oauth.com/relogin"),
}));
EXPECT_FALSE(oauth_login_detector_->GetSuccessfulLoginFlowSite(
GURL("https://oauth.com/relogin"),
{
GURL("https://oauth.com/login?username=123&password=123"),
GURL("https://oauth.com/relogin"),
}));
EXPECT_FALSE(oauth_login_detector_->GetSuccessfulLoginFlowSite(
GURL("https://oauth.com/relogin"),
{
GURL("https://oauth.com/login?username=123&password=123"),
GURL("https://oauth.com/relogin"),
}));
EXPECT_FALSE(oauth_login_detector_->GetSuccessfulLoginFlowSite(
GURL("https://oauth.com/relogin"),
{GURL("https://oauth.com/login?username=123&password=123"),
GURL("https://oauth.com/loginsuccess"),
GURL("https://foo.com/redirect?code=secret")})); GURL("https://foo.com/redirect?code=secret")}));
EXPECT_FALSE(oauth_login_detector_->GetPopUpLoginFlowSite()); EXPECT_FALSE(oauth_login_detector_->GetPopUpLoginFlowSite());
} }
// Test that too many redirects are allowed within the same navigation.
TEST_F(OAuthLoginDetectorTest, RedirectNavigationsAfterOAuthStart) {
EXPECT_EQ(GURL("https://foo.com/"),
*oauth_login_detector_->GetSuccessfulLoginFlowSite(
GURL("https://foo.com/login.html"),
{GURL("https://oauth.com/authenticate?client_id=123"),
GURL("https://oauth.com/login"),
GURL("https://oauth.com/loginfailed"),
GURL("https://oauth.com/relogin"),
GURL("https://oauth.com/loginsuccess"),
GURL("https://foo.com/redirect?code=secret")}));
EXPECT_FALSE(oauth_login_detector_->GetPopUpLoginFlowSite());
}
// Test that OAuth login is detected when there are intermediate navigations to // Test that OAuth login is detected when there are intermediate navigations to
// other sites. // other sites.
TEST_F(OAuthLoginDetectorTest, IntermediateNavigationsToOtherSites) { TEST_F(OAuthLoginDetectorTest, IntermediateNavigationsToOtherSites) {
......
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