Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5922)

Unified Diff: chrome/browser/ssl/chrome_security_state_model_client_browser_tests.cc

Issue 2448943002: Refactor SecurityStateModel/Clients for simplicity and reusability. (Closed)
Patch Set: Refactor -> WebContentsSecurityStateModel. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ssl/chrome_security_state_model_client_browser_tests.cc
diff --git a/chrome/browser/ssl/chrome_security_state_model_client_browser_tests.cc b/chrome/browser/ssl/chrome_security_state_model_client_browser_tests.cc
index 19032113412e117a9f2506360a6fcd63ce93c759..e7a2ea081abb37e005fbdaed31ae51130c2851b3 100644
--- a/chrome/browser/ssl/chrome_security_state_model_client_browser_tests.cc
+++ b/chrome/browser/ssl/chrome_security_state_model_client_browser_tests.cc
@@ -20,11 +20,11 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
-#include "chrome/grit/generated_resources.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/prefs/pref_service.h"
-#include "components/security_state/switches.h"
+#include "components/security_state/core/switches.h"
+#include "components/strings/grit/components_strings.h"
#include "content/public/browser/interstitial_page.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
@@ -355,6 +355,8 @@ class SecurityStyleChangedTest : public InProcessBrowserTest {
DISALLOW_COPY_AND_ASSIGN(SecurityStyleChangedTest);
};
+} // namespace
+
IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, HttpPage) {
ASSERT_TRUE(embedded_test_server()->Start());
ui_test_utils::NavigateToURL(
@@ -733,6 +735,8 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, BrokenHTTPS) {
true /* expect cert status error */);
}
+namespace {
+
const char kReportURI[] = "https://report-hpkp.test";
class PKPModelClientTest : public ChromeSecurityStateModelClientTest {
@@ -768,6 +772,8 @@ class PKPModelClientTest : public ChromeSecurityStateModelClientTest {
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
};
+} // namespace
+
IN_PROC_BROWSER_TEST_F(PKPModelClientTest, PKPBypass) {
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
@@ -820,6 +826,8 @@ IN_PROC_BROWSER_TEST_F(PKPModelClientTest, PKPEnforced) {
browser(), cert.get());
}
+namespace {
+
// Fails requests with ERR_IO_PENDING. Can be used to simulate a navigation
// that never stops loading.
class PendingJobInterceptor : public net::URLRequestInterceptor {
@@ -865,6 +873,8 @@ class SecurityStateModelLoadingTest
DISALLOW_COPY_AND_ASSIGN(SecurityStateModelLoadingTest);
};
+} // namespace
+
// Tests that navigation state changes cause the security state to be
// updated.
IN_PROC_BROWSER_TEST_F(SecurityStateModelLoadingTest, NavigationStateChanges) {
@@ -915,7 +925,7 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
content::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP);
SecurityStateModel::VisibleSecurityState
visible_security_state_no_sensitive_inputs;
- model_client->GetVisibleSecurityState(
+ model_client->security_state_model_->GetVisibleSecurityState(
&visible_security_state_no_sensitive_inputs);
EXPECT_FALSE(visible_security_state_no_sensitive_inputs
.displayed_password_field_on_http);
@@ -930,7 +940,7 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
content::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP;
SecurityStateModel::VisibleSecurityState
visible_security_state_sensitive_inputs;
- model_client->GetVisibleSecurityState(
+ model_client->security_state_model_->GetVisibleSecurityState(
&visible_security_state_sensitive_inputs);
EXPECT_TRUE(
visible_security_state_sensitive_inputs.displayed_password_field_on_http);
@@ -1119,6 +1129,8 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP);
}
+namespace {
+
// A Browser subclass that keeps track of messages that have been
// added to the console. Messages can be retrieved or cleared with
// console_messages() and ClearConsoleMessages(). The user of this class
@@ -1184,6 +1196,8 @@ void CheckForOneFutureHttpWarningConsoleMessage(
messages[0].find(base::ASCIIToUTF16("warning will be added")));
}
+} // namespace
+
// Tests that console messages are printed upon a call to
// GetSecurityInfo() on an HTTP_SHOW_WARNING page, exactly once per
// main-frame navigation.
@@ -1750,6 +1764,8 @@ IN_PROC_BROWSER_TEST_F(SecurityStyleChangedTest,
EXPECT_FALSE(observer.latest_explanations().ran_mixed_content);
}
+namespace {
+
// After AddNonsecureUrlHandler() is called, requests to this hostname
// will use obsolete TLS settings.
const char kMockNonsecureHostname[] = "example-nonsecure.test";
@@ -1864,6 +1880,8 @@ class BrowserTestNonsecureURLRequest : public InProcessBrowserTest {
DISALLOW_COPY_AND_ASSIGN(BrowserTestNonsecureURLRequest);
};
+} // namespace
+
// Tests that a connection with obsolete TLS settings does not get a
// secure connection explanation.
IN_PROC_BROWSER_TEST_F(BrowserTestNonsecureURLRequest,
@@ -1911,6 +1929,8 @@ IN_PROC_BROWSER_TEST_F(BrowserTestNonsecureURLRequest,
observer.latest_explanations().info_explanations[0].description));
}
+namespace {
+
// After AddSCTUrlHandler() is called, requests to this hostname
// will be served with Signed Certificate Timestamps.
const char kMockHostnameWithSCTs[] = "example-scts.test";
@@ -2028,6 +2048,8 @@ class BrowserTestURLRequestWithSCTs : public InProcessBrowserTest {
DISALLOW_COPY_AND_ASSIGN(BrowserTestURLRequestWithSCTs);
};
+} // namespace
+
// Tests that, when Signed Certificate Timestamps (SCTs) are served on a
// connection, the SCTs verification statuses are exposed on the
// SecurityInfo.
@@ -2047,5 +2069,3 @@ IN_PROC_BROWSER_TEST_F(BrowserTestURLRequestWithSCTs,
EXPECT_EQ(SecurityStateModel::SECURE, security_info.security_level);
EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses);
}
-
-} // namespace

Powered by Google App Engine
This is Rietveld 408576698