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

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

Issue 418133012: Add button to page info to revoke user certificate decisions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase on ToT Created 6 years, 4 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 77d766785de8d5a0d6bfff18c0303966a89a22f0..6cc0df938b9394ec6dcba929ea84c81f8f419ceb 100644
--- a/chrome/browser/ssl/chrome_ssl_host_state_delegate_test.cc
+++ b/chrome/browser/ssl/chrome_ssl_host_state_delegate_test.cc
@@ -132,8 +132,8 @@ IN_PROC_BROWSER_TEST_F(ChromeSSLHostStateDelegateTest, QueryPolicy) {
}
// HasPolicyAndRevoke unit tests the expected behavior of calling
-// HasAllowedOrDeniedCert before and after calling RevokeAllowAndDenyPreferences
-// on the SSLHostStateDelegate class.
+// HasUserDecision before and after calling RevokeUserDecisions on the
+// SSLHostStateDelegate class.
IN_PROC_BROWSER_TEST_F(ChromeSSLHostStateDelegateTest, HasPolicyAndRevoke) {
scoped_refptr<net::X509Certificate> google_cert = GetGoogleCert();
content::WebContents* tab =
@@ -148,13 +148,12 @@ IN_PROC_BROWSER_TEST_F(ChromeSSLHostStateDelegateTest, HasPolicyAndRevoke) {
state->AllowCert(
kExampleHost, google_cert.get(), net::CERT_STATUS_DATE_INVALID);
- // Verify that HasAllowedOrDeniedCert correctly acknowledges that a user
- // decision has been made about kWWWGoogleHost. Then verify that
- // HasAllowedOrDeniedCert correctly identifies that the decision has been
- // revoked.
- EXPECT_TRUE(state->HasAllowedOrDeniedCert(kWWWGoogleHost));
- state->RevokeAllowAndDenyPreferences(kWWWGoogleHost);
- EXPECT_FALSE(state->HasAllowedOrDeniedCert(kWWWGoogleHost));
+ // Verify that HasUserDecision correctly acknowledges that a user decision has
+ // been made about kWWWGoogleHost. Then verify that HasUserDecision correctly
+ // identifies that the decision has been revoked.
+ EXPECT_TRUE(state->HasUserDecision(kWWWGoogleHost));
+ state->RevokeUserDecisions(kWWWGoogleHost);
+ EXPECT_FALSE(state->HasUserDecision(kWWWGoogleHost));
EXPECT_EQ(
net::CertPolicy::UNKNOWN,
state->QueryPolicy(
@@ -162,14 +161,14 @@ IN_PROC_BROWSER_TEST_F(ChromeSSLHostStateDelegateTest, HasPolicyAndRevoke) {
// Verify that the revocation of the kWWWGoogleHost decision does not affect
// the Allow for kExampleHost.
- EXPECT_TRUE(state->HasAllowedOrDeniedCert(kExampleHost));
+ EXPECT_TRUE(state->HasUserDecision(kExampleHost));
// Verify the revocation of the kWWWGoogleHost decision does not affect the
// non-decision for kGoogleHost. Then verify that a revocation of a URL with
// no decision has no effect.
- EXPECT_FALSE(state->HasAllowedOrDeniedCert(kGoogleHost));
- state->RevokeAllowAndDenyPreferences(kGoogleHost);
- EXPECT_FALSE(state->HasAllowedOrDeniedCert(kGoogleHost));
+ EXPECT_FALSE(state->HasUserDecision(kGoogleHost));
+ state->RevokeUserDecisions(kGoogleHost);
+ EXPECT_FALSE(state->HasUserDecision(kGoogleHost));
}
// Clear unit tests the expected behavior of calling Clear to forget all cert
@@ -190,18 +189,45 @@ IN_PROC_BROWSER_TEST_F(ChromeSSLHostStateDelegateTest, Clear) {
// decision made, and kExampleHost, which was untouched, are now in a
// non-decision state.
state->Clear();
- EXPECT_FALSE(state->HasAllowedOrDeniedCert(kWWWGoogleHost));
+ EXPECT_FALSE(state->HasUserDecision(kWWWGoogleHost));
EXPECT_EQ(
net::CertPolicy::UNKNOWN,
state->QueryPolicy(
kWWWGoogleHost, google_cert.get(), net::CERT_STATUS_DATE_INVALID));
- EXPECT_FALSE(state->HasAllowedOrDeniedCert(kExampleHost));
+ EXPECT_FALSE(state->HasUserDecision(kExampleHost));
EXPECT_EQ(
net::CertPolicy::UNKNOWN,
state->QueryPolicy(
kExampleHost, google_cert.get(), net::CERT_STATUS_DATE_INVALID));
}
+// DidHostRunInsecureContent unit tests the expected behavior of calling
+// DidHostRunInsecureContent as well as HostRanInsecureContent to check if
+// insecure content has been run and to mark it as such.
+IN_PROC_BROWSER_TEST_F(ChromeSSLHostStateDelegateTest,
+ DidHostRunInsecureContent) {
+ content::WebContents* tab =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext());
+ content::SSLHostStateDelegate* state = profile->GetSSLHostStateDelegate();
+
+ EXPECT_FALSE(state->DidHostRunInsecureContent("www.google.com", 42));
+ EXPECT_FALSE(state->DidHostRunInsecureContent("www.google.com", 191));
+ EXPECT_FALSE(state->DidHostRunInsecureContent("example.com", 42));
+
+ state->HostRanInsecureContent("www.google.com", 42);
+
+ EXPECT_TRUE(state->DidHostRunInsecureContent("www.google.com", 42));
+ EXPECT_FALSE(state->DidHostRunInsecureContent("www.google.com", 191));
+ EXPECT_FALSE(state->DidHostRunInsecureContent("example.com", 42));
+
+ state->HostRanInsecureContent("example.com", 42);
+
+ EXPECT_TRUE(state->DidHostRunInsecureContent("www.google.com", 42));
+ EXPECT_FALSE(state->DidHostRunInsecureContent("www.google.com", 191));
+ EXPECT_TRUE(state->DidHostRunInsecureContent("example.com", 42));
+}
+
// Tests the basic behavior of cert memory in incognito.
class IncognitoSSLHostStateDelegateTest
: public ChromeSSLHostStateDelegateTest {

Powered by Google App Engine
This is Rietveld 408576698