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

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

Issue 2292443003: Support host-based deletion for SSLHostStateDelegate (Closed)
Patch Set: Rebase. Created 4 years, 3 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 568dd94345bd961bbcc7690d061bc223ea6a91dc..33ba30c5b21bb5f8a72e44747b4f564fa3df8dd7 100644
--- a/chrome/browser/ssl/chrome_ssl_host_state_delegate_test.cc
+++ b/chrome/browser/ssl/chrome_ssl_host_state_delegate_test.cc
@@ -7,6 +7,7 @@
#include <stdint.h>
#include <utility>
+#include "base/callback.h"
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/simple_test_clock.h"
@@ -52,6 +53,10 @@ void SetFinchConfig(base::CommandLine* command_line, const std::string& group) {
"RevertCertificateErrorDecisions/" + group);
}
+bool CStrStringMatcher(const char* a, const std::string& b) {
+ return a == b;
+}
+
} // namespace
class ChromeSSLHostStateDelegateTest : public InProcessBrowserTest {};
@@ -171,11 +176,22 @@ IN_PROC_BROWSER_TEST_F(ChromeSSLHostStateDelegateTest, Clear) {
// Simulate a user decision to allow an invalid certificate exception for
// kWWWGoogleHost and for kExampleHost.
state->AllowCert(kWWWGoogleHost, *cert, net::CERT_STATUS_DATE_INVALID);
+ state->AllowCert(kExampleHost, *cert, net::CERT_STATUS_DATE_INVALID);
+
+ EXPECT_TRUE(state->HasAllowException(kWWWGoogleHost));
+ EXPECT_TRUE(state->HasAllowException(kExampleHost));
+
+ // Clear data for kWWWGoogleHost. kExampleHost will not be modified.
+ state->Clear(
+ base::Bind(&CStrStringMatcher, base::Unretained(kWWWGoogleHost)));
- // Do a full clear, then make sure that both kWWWGoogleHost, which had a
- // decision made, and kExampleHost, which was untouched, are now in a denied
- // state.
- state->Clear();
+ EXPECT_FALSE(state->HasAllowException(kWWWGoogleHost));
+ EXPECT_TRUE(state->HasAllowException(kExampleHost));
+
+ // Do a full clear, then make sure that both kWWWGoogleHost and kExampleHost,
+ // which had a decision made, and kGoogleHost, which was untouched, are now
+ // in a denied state.
+ state->Clear(base::Callback<bool(const std::string&)>());
EXPECT_FALSE(state->HasAllowException(kWWWGoogleHost));
EXPECT_EQ(content::SSLHostStateDelegate::DENIED,
state->QueryPolicy(kWWWGoogleHost, *cert,
@@ -184,6 +200,10 @@ IN_PROC_BROWSER_TEST_F(ChromeSSLHostStateDelegateTest, Clear) {
EXPECT_EQ(content::SSLHostStateDelegate::DENIED,
state->QueryPolicy(kExampleHost, *cert,
net::CERT_STATUS_DATE_INVALID, &unused_value));
+ EXPECT_FALSE(state->HasAllowException(kGoogleHost));
+ EXPECT_EQ(content::SSLHostStateDelegate::DENIED,
+ state->QueryPolicy(kGoogleHost, *cert,
+ net::CERT_STATUS_DATE_INVALID, &unused_value));
}
// DidHostRunInsecureContent unit tests the expected behavior of calling

Powered by Google App Engine
This is Rietveld 408576698