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

Side by Side Diff: chrome/browser/chromeos/cros/network_library_unittest.cc

Issue 11174006: Implement ScopedTestNSSDB instead of OpenTestNSSDB() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reland with suppression Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/chromeos/cros/onc_network_parser_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <cert.h> 5 #include <cert.h>
6 #include <pk11pub.h> 6 #include <pk11pub.h>
7 7
8 #include <vector> 8 #include <vector>
9 #include <string> 9 #include <string>
10 10
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // NetworkLibraryStubImpl. 131 // NetworkLibraryStubImpl.
132 // NOTE: It would be of little value to test stub functions that simply return 132 // NOTE: It would be of little value to test stub functions that simply return
133 // predefined values, e.g. ethernet_available(). However, many other functions 133 // predefined values, e.g. ethernet_available(). However, many other functions
134 // such as connected_network() return values which are set indirectly and thus 134 // such as connected_network() return values which are set indirectly and thus
135 // we can test the logic of those setters. 135 // we can test the logic of those setters.
136 136
137 class NetworkLibraryStubTest : public testing::Test { 137 class NetworkLibraryStubTest : public testing::Test {
138 public: 138 public:
139 NetworkLibraryStubTest() : cros_(NULL) {} 139 NetworkLibraryStubTest() : cros_(NULL) {}
140 140
141 static void SetUpTestCase() {
142 // Ideally, we'd open a test DB for each test case, and close it
143 // again, removing the temp dir, but unfortunately, there's a
144 // bug in NSS that prevents this from working, so we just open
145 // it once, and empty it for each test case. Here's the bug:
146 // https://bugzilla.mozilla.org/show_bug.cgi?id=588269
147 ASSERT_TRUE(crypto::OpenTestNSSDB());
148 // There is no matching TearDownTestCase call to close the test NSS DB
149 // because that would leave NSS in a potentially broken state for further
150 // tests, due to https://bugzilla.mozilla.org/show_bug.cgi?id=588269
151 }
152
153 protected: 141 protected:
154 virtual void SetUp() { 142 virtual void SetUp() {
143 ASSERT_TRUE(test_nssdb_.is_open());
144
155 slot_ = net::NSSCertDatabase::GetInstance()->GetPublicModule(); 145 slot_ = net::NSSCertDatabase::GetInstance()->GetPublicModule();
156 cros_ = CrosLibrary::Get()->GetNetworkLibrary(); 146 cros_ = CrosLibrary::Get()->GetNetworkLibrary();
157 ASSERT_TRUE(cros_) << "GetNetworkLibrary() Failed!"; 147 ASSERT_TRUE(cros_) << "GetNetworkLibrary() Failed!";
158 148
159 // Test db should be empty at start of test. 149 // Test db should be empty at start of test.
160 EXPECT_EQ(0U, ListCertsInSlot(slot_->os_module_handle()).size()); 150 EXPECT_EQ(0U, ListCertsInSlot(slot_->os_module_handle()).size());
161 } 151 }
162 virtual void TearDown() { 152 virtual void TearDown() {
163 cros_ = NULL; 153 cros_ = NULL;
164 EXPECT_TRUE(CleanupSlotContents(slot_->os_module_handle())); 154 EXPECT_TRUE(CleanupSlotContents(slot_->os_module_handle()));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 bool ok = true; 190 bool ok = true;
201 net::CertificateList certs = ListCertsInSlot(slot); 191 net::CertificateList certs = ListCertsInSlot(slot);
202 for (size_t i = 0; i < certs.size(); ++i) { 192 for (size_t i = 0; i < certs.size(); ++i) {
203 if (!net::NSSCertDatabase::GetInstance()->DeleteCertAndKey(certs[i])) 193 if (!net::NSSCertDatabase::GetInstance()->DeleteCertAndKey(certs[i]))
204 ok = false; 194 ok = false;
205 } 195 }
206 return ok; 196 return ok;
207 } 197 }
208 198
209 scoped_refptr<net::CryptoModule> slot_; 199 scoped_refptr<net::CryptoModule> slot_;
200 crypto::ScopedTestNSSDB test_nssdb_;
210 }; 201 };
211 202
212 // Default stub state: 203 // Default stub state:
213 // vpn1: disconnected, L2TP/IPsec + PSK 204 // vpn1: disconnected, L2TP/IPsec + PSK
214 // vpn2: disconnected, L2TP/IPsec + user cert 205 // vpn2: disconnected, L2TP/IPsec + user cert
215 // vpn3: disconnected, OpenVpn 206 // vpn3: disconnected, OpenVpn
216 // eth1: connected (active network) 207 // eth1: connected (active network)
217 // wifi1: connected 208 // wifi1: connected
218 // wifi2: disconnected 209 // wifi2: disconnected
219 // wifi3: disconnected, WEP 210 // wifi3: disconnected, WEP
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 361
371 // TODO(stevenjb): Test network profiles. 362 // TODO(stevenjb): Test network profiles.
372 363
373 // TODO(stevenjb): Test network devices. 364 // TODO(stevenjb): Test network devices.
374 365
375 // TODO(stevenjb): Test data plans. 366 // TODO(stevenjb): Test data plans.
376 367
377 // TODO(stevenjb): Test monitor network / device. 368 // TODO(stevenjb): Test monitor network / device.
378 369
379 } // namespace chromeos 370 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/cros/onc_network_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698