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

Side by Side Diff: net/base/cert_database_nss_unittest.cc

Issue 6805019: Move crypto files out of base, to a top level directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 8 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <algorithm> 8 #include <algorithm>
9 9
10 #include "base/crypto/scoped_nss_types.h"
11 #include "base/file_path.h" 10 #include "base/file_path.h"
12 #include "base/file_util.h" 11 #include "base/file_util.h"
13 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
14 #include "base/memory/scoped_temp_dir.h" 13 #include "base/memory/scoped_temp_dir.h"
15 #include "base/nss_util.h"
16 #include "base/nss_util_internal.h"
17 #include "base/path_service.h" 14 #include "base/path_service.h"
18 #include "base/string_util.h" 15 #include "base/string_util.h"
19 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "crypto/nss_util.h"
18 #include "crypto/nss_util_internal.h"
19 #include "crypto/scoped_nss_types.h"
20 #include "net/base/cert_database.h" 20 #include "net/base/cert_database.h"
21 #include "net/base/cert_status_flags.h" 21 #include "net/base/cert_status_flags.h"
22 #include "net/base/cert_verify_result.h" 22 #include "net/base/cert_verify_result.h"
23 #include "net/base/crypto_module.h" 23 #include "net/base/crypto_module.h"
24 #include "net/base/net_errors.h" 24 #include "net/base/net_errors.h"
25 #include "net/base/x509_certificate.h" 25 #include "net/base/x509_certificate.h"
26 #include "net/third_party/mozilla_security_manager/nsNSSCertificateDB.h" 26 #include "net/third_party/mozilla_security_manager/nsNSSCertificateDB.h"
27 #include "net/third_party/mozilla_security_manager/nsNSSCertTrust.h" 27 #include "net/third_party/mozilla_security_manager/nsNSSCertTrust.h"
28 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
29 29
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // TODO(mattm): when https://bugzilla.mozilla.org/show_bug.cgi?id=588269 is 101 // TODO(mattm): when https://bugzilla.mozilla.org/show_bug.cgi?id=588269 is
102 // fixed, switch back to using a separate userdb for each test. 102 // fixed, switch back to using a separate userdb for each test.
103 // (When doing so, remember to add some standalone tests of DeleteCert since it 103 // (When doing so, remember to add some standalone tests of DeleteCert since it
104 // won't be tested by TearDown anymore.) 104 // won't be tested by TearDown anymore.)
105 class CertDatabaseNSSTest : public testing::Test { 105 class CertDatabaseNSSTest : public testing::Test {
106 public: 106 public:
107 virtual void SetUp() { 107 virtual void SetUp() {
108 if (!temp_db_initialized_) { 108 if (!temp_db_initialized_) {
109 ASSERT_TRUE(temp_db_dir_.Get().CreateUniqueTempDir()); 109 ASSERT_TRUE(temp_db_dir_.Get().CreateUniqueTempDir());
110 ASSERT_TRUE( 110 ASSERT_TRUE(
111 base::OpenTestNSSDB(temp_db_dir_.Get().path(), 111 crypto::OpenTestNSSDB(temp_db_dir_.Get().path(),
112 "CertDatabaseNSSTest db")); 112 "CertDatabaseNSSTest db"));
113 temp_db_initialized_ = true; 113 temp_db_initialized_ = true;
114 } 114 }
115 slot_ = cert_db_.GetDefaultModule(); 115 slot_ = cert_db_.GetDefaultModule();
116 116
117 // Test db should be empty at start of test. 117 // Test db should be empty at start of test.
118 EXPECT_EQ(0U, ListCertsInSlot(slot_->os_module_handle()).size()); 118 EXPECT_EQ(0U, ListCertsInSlot(slot_->os_module_handle()).size());
119 } 119 }
120 virtual void TearDown() { 120 virtual void TearDown() {
121 // Don't try to cleanup if the setup failed. 121 // Don't try to cleanup if the setup failed.
122 ASSERT_TRUE(slot_->os_module_handle()); 122 ASSERT_TRUE(slot_->os_module_handle());
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 puny_cert.get(), CA_CERT, 496 puny_cert.get(), CA_CERT,
497 CertDatabase::TRUSTED_SSL | CertDatabase::TRUSTED_EMAIL)); 497 CertDatabase::TRUSTED_SSL | CertDatabase::TRUSTED_EMAIL));
498 498
499 verify_result.Reset(); 499 verify_result.Reset();
500 error = puny_cert->Verify("xn--wgv71a119e.com", flags, &verify_result); 500 error = puny_cert->Verify("xn--wgv71a119e.com", flags, &verify_result);
501 EXPECT_EQ(OK, error); 501 EXPECT_EQ(OK, error);
502 EXPECT_EQ(0, verify_result.cert_status); 502 EXPECT_EQ(0, verify_result.cert_status);
503 } 503 }
504 504
505 } // namespace net 505 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698