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

Unified Diff: chrome/browser/net/sqlite_server_bound_cert_store_unittest.cc

Issue 10407124: Don't force non-session only cookies to be session only cookies, instead delete on shutdown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix tests Created 8 years, 7 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/net/sqlite_server_bound_cert_store_unittest.cc
diff --git a/chrome/browser/net/sqlite_server_bound_cert_store_unittest.cc b/chrome/browser/net/sqlite_server_bound_cert_store_unittest.cc
index b119252d0023520b80cb8fdfa368df9042033031..a0fc85a1d240ec0483ea197fe7a45c2d30aa3c2f 100644
--- a/chrome/browser/net/sqlite_server_bound_cert_store_unittest.cc
+++ b/chrome/browser/net/sqlite_server_bound_cert_store_unittest.cc
@@ -10,12 +10,14 @@
#include "base/scoped_temp_dir.h"
#include "base/stl_util.h"
#include "base/test/thread_test_helper.h"
+#include "chrome/browser/net/clear_on_exit_policy.h"
#include "chrome/browser/net/sqlite_server_bound_cert_store.h"
#include "chrome/common/chrome_constants.h"
#include "content/test/test_browser_thread.h"
#include "net/base/cert_test_util.h"
#include "sql/statement.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "webkit/quota/mock_special_storage_policy.h"
using content::BrowserThread;
@@ -61,7 +63,7 @@ class SQLiteServerBoundCertStoreTest : public testing::Test {
db_thread_.Start();
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
store_ = new SQLiteServerBoundCertStore(
- temp_dir_.path().Append(chrome::kOBCertFilename));
+ temp_dir_.path().Append(chrome::kOBCertFilename), NULL);
ScopedVector<net::DefaultServerBoundCertStore::ServerBoundCert> certs;
ASSERT_TRUE(store_->Load(&certs.get()));
ASSERT_EQ(0u, certs.size());
@@ -132,7 +134,7 @@ TEST_F(SQLiteServerBoundCertStoreTest, TestPersistence) {
// Make sure we wait until the destructor has run.
ASSERT_TRUE(helper->Run());
store_ = new SQLiteServerBoundCertStore(
- temp_dir_.path().Append(chrome::kOBCertFilename));
+ temp_dir_.path().Append(chrome::kOBCertFilename), NULL);
// Reload and test for persistence
ASSERT_TRUE(store_->Load(&certs.get()));
@@ -167,7 +169,7 @@ TEST_F(SQLiteServerBoundCertStoreTest, TestPersistence) {
ASSERT_TRUE(helper->Run());
certs.reset();
store_ = new SQLiteServerBoundCertStore(
- temp_dir_.path().Append(chrome::kOBCertFilename));
+ temp_dir_.path().Append(chrome::kOBCertFilename), NULL);
// Reload and check if the cert has been removed.
ASSERT_TRUE(store_->Load(&certs.get()));
@@ -218,7 +220,7 @@ TEST_F(SQLiteServerBoundCertStoreTest, TestUpgradeV1) {
SCOPED_TRACE(i);
ScopedVector<net::DefaultServerBoundCertStore::ServerBoundCert> certs;
- store_ = new SQLiteServerBoundCertStore(v1_db_path);
+ store_ = new SQLiteServerBoundCertStore(v1_db_path, NULL);
// Load the database and ensure the certs can be read and are marked as RSA.
ASSERT_TRUE(store_->Load(&certs.get()));
@@ -306,7 +308,7 @@ TEST_F(SQLiteServerBoundCertStoreTest, TestUpgradeV2) {
SCOPED_TRACE(i);
ScopedVector<net::DefaultServerBoundCertStore::ServerBoundCert> certs;
- store_ = new SQLiteServerBoundCertStore(v2_db_path);
+ store_ = new SQLiteServerBoundCertStore(v2_db_path, NULL);
// Load the database and ensure the certs can be read and are marked as RSA.
ASSERT_TRUE(store_->Load(&certs.get()));
@@ -396,7 +398,7 @@ TEST_F(SQLiteServerBoundCertStoreTest, TestUpgradeV3) {
SCOPED_TRACE(i);
ScopedVector<net::DefaultServerBoundCertStore::ServerBoundCert> certs;
- store_ = new SQLiteServerBoundCertStore(v3_db_path);
+ store_ = new SQLiteServerBoundCertStore(v3_db_path, NULL);
// Load the database and ensure the certs can be read and are marked as RSA.
ASSERT_TRUE(store_->Load(&certs.get()));
@@ -510,3 +512,49 @@ TEST_F(SQLiteServerBoundCertStoreTest, TestFlushCompletionCallback) {
ASSERT_EQ(1, counter->callback_count());
}
+
+// Tests the interaction with the clear on exit policy.
+TEST_F(SQLiteServerBoundCertStoreTest, TestClearOnExitPolicy) {
+ store_->SetClearLocalStateOnExit(true);
+ // Replace the store effectively destroying the current one and forcing it
+ // to write its data to disk. Then we can see if after loading it again it
+ // is still there.
+ store_ = NULL;
+ // Make sure we wait until the destructor has run.
+ scoped_refptr<base::ThreadTestHelper> helper(
+ new base::ThreadTestHelper(
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)));
+ ASSERT_TRUE(helper->Run());
+
+ scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy =
+ new quota::MockSpecialStoragePolicy;
+ scoped_refptr<ClearOnExitPolicy> clear_policy =
+ new ClearOnExitPolicy(storage_policy.get());
+ storage_policy->AddSessionOnly(GURL("https://google.com"));
+
+ store_ = new SQLiteServerBoundCertStore(
+ temp_dir_.path().Append(chrome::kOBCertFilename), clear_policy.get());
+ ScopedVector<net::DefaultServerBoundCertStore::ServerBoundCert> certs;
+ ASSERT_TRUE(store_->Load(&certs.get()));
+ ASSERT_EQ(0u, certs.size());
+ // Make sure the store gets written at least once.
erikwright (departed) 2012/05/29 13:09:03 It's not evident to me that this has ensured a wri
jochen (gone - plz use gerrit) 2012/05/30 11:28:42 Done.
+ store_->AddServerBoundCert(
+ net::DefaultServerBoundCertStore::ServerBoundCert(
+ "google.com",
+ net::CLIENT_CERT_RSA_SIGN,
+ base::Time::FromInternalValue(1),
+ base::Time::FromInternalValue(2),
+ "a", "b"));
+
+ store_ = NULL;
+
+ // Make sure we wait until the destructor has run.
+ ASSERT_TRUE(helper->Run());
+
+ store_ = new SQLiteServerBoundCertStore(
+ temp_dir_.path().Append(chrome::kOBCertFilename), clear_policy.get());
+
+ // Reload and test for persistence
+ ASSERT_TRUE(store_->Load(&certs.get()));
+ ASSERT_EQ(0U, certs.size());
+}

Powered by Google App Engine
This is Rietveld 408576698