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

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

Issue 473643002: Add button to page info to revoke user certificate decisions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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..4daef7ec4ba438c61099bf351310a3754d5b767c 100644
--- a/chrome/browser/ssl/chrome_ssl_host_state_delegate_test.cc
+++ b/chrome/browser/ssl/chrome_ssl_host_state_delegate_test.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/browsing_data/browsing_data_remover_test_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
+#include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
@@ -132,14 +133,15 @@ 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 =
browser()->tab_strip_model()->GetActiveWebContents();
Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext());
- content::SSLHostStateDelegate* state = profile->GetSSLHostStateDelegate();
+ ChromeSSLHostStateDelegate* state =
+ ChromeSSLHostStateDelegateFactory::GetForProfile(profile);
// Simulate a user decision to allow an invalid certificate exception for
// kWWWGoogleHost and for kExampleHost.
@@ -148,13 +150,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 +163,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
@@ -179,7 +180,8 @@ IN_PROC_BROWSER_TEST_F(ChromeSSLHostStateDelegateTest, Clear) {
content::WebContents* tab =
browser()->tab_strip_model()->GetActiveWebContents();
Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext());
- content::SSLHostStateDelegate* state = profile->GetSSLHostStateDelegate();
+ ChromeSSLHostStateDelegate* state =
+ ChromeSSLHostStateDelegateFactory::GetForProfile(profile);
// Simulate a user decision to allow an invalid certificate exception for
// kWWWGoogleHost and for kExampleHost.
@@ -190,18 +192,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 {
« no previous file with comments | « chrome/browser/ssl/chrome_ssl_host_state_delegate.cc ('k') | chrome/browser/ui/android/website_settings_popup_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698