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

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

Issue 887223005: Skip interstitials and don't block requests for localhost SSL errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added warning in console on localhost SSL errors Created 5 years, 11 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_ssl_host_state_delegate_test.cc
diff --git a/chrome/browser/ssl/chrome_ssl_host_state_delegate_test.cc b/chrome/browser/ssl/chrome_ssl_host_state_delegate_test.cc
index 35c84fab198e18b600570aa6a769c96ffbeb6786..d65c702f749979c5e646daab000a23c4a533d61e 100644
--- a/chrome/browser/ssl/chrome_ssl_host_state_delegate_test.cc
+++ b/chrome/browser/ssl/chrome_ssl_host_state_delegate_test.cc
@@ -625,3 +625,54 @@ IN_PROC_BROWSER_TEST_F(RemoveBrowsingHistorySSLHostStateDelegateTest,
net::CERT_STATUS_DATE_INVALID,
&unused_value));
}
+
+// Tests to make sure that localhost certificate errors are ignored or
+// treated as normal errors, depending on whether the
+// kAllowInsecureLocalhost flag is set.
+
+// When the flag isn't set, requests to localhost with invalid
+// certificates should be denied.
+IN_PROC_BROWSER_TEST_F(ChromeSSLHostStateDelegateTest,
+ LocalhostErrorWithoutFlag) {
+ // Serve the Google cert for localhost to generate an error.
+ scoped_refptr<net::X509Certificate> google_cert = GetGoogleCert();
Ryan Sleevi 2015/02/04 19:34:41 Not your fault, other than I never noticed until t
estark 2015/02/05 03:02:38 Done. Just to make sure I understand: * The pain o
+ content::WebContents* tab =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext());
+ content::SSLHostStateDelegate* state = profile->GetSSLHostStateDelegate();
+ bool unused_value;
+
+ EXPECT_EQ(content::SSLHostStateDelegate::DENIED,
+ state->QueryPolicy("localhost",
+ *google_cert.get(),
+ net::CERT_STATUS_COMMON_NAME_INVALID,
+ &unused_value));
+}
+
+// When the flag is set, requests to localhost with invalid certificates
+// should be allowed.
+class AllowLocalhostErrorsSSLHostStateDelegateTest
+ : public ChromeSSLHostStateDelegateTest {
+ protected:
+ void SetUpCommandLine(base::CommandLine* command_line) override {
+ ChromeSSLHostStateDelegateTest::SetUpCommandLine(command_line);
+ command_line->AppendSwitch(switches::kAllowInsecureLocalhost);
+ }
+};
+
+IN_PROC_BROWSER_TEST_F(AllowLocalhostErrorsSSLHostStateDelegateTest,
+ LocalhostErrorWithFlag) {
+ // Serve the Google cert for localhost to generate an error.
+ scoped_refptr<net::X509Certificate> google_cert = GetGoogleCert();
+ content::WebContents* tab =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext());
+ content::SSLHostStateDelegate* state = profile->GetSSLHostStateDelegate();
+ bool unused_value;
+
+ EXPECT_EQ(content::SSLHostStateDelegate::ALLOWED,
+ state->QueryPolicy("localhost",
+ *google_cert.get(),
+ net::CERT_STATUS_COMMON_NAME_INVALID,
+ &unused_value));
+}

Powered by Google App Engine
This is Rietveld 408576698