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

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

Issue 27033: Implement X509Certificate::Persist. This fixes gmail on linux. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 10 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 | « net/base/x509_certificate_nss.cc ('k') | no next file » | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/port.h" 5 #include "base/pickle.h"
6 #include "net/base/cert_status_flags.h" 6 #include "net/base/cert_status_flags.h"
7 #include "net/base/x509_certificate.h" 7 #include "net/base/x509_certificate.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 // Unit tests aren't allowed to access external resources. Unfortunately, to 10 // Unit tests aren't allowed to access external resources. Unfortunately, to
11 // properly verify the EV-ness of a cert, we need to check for its revocation 11 // properly verify the EV-ness of a cert, we need to check for its revocation
12 // through online servers. If you're manually running unit tests, feel free to 12 // through online servers. If you're manually running unit tests, feel free to
13 // turn this on to test EV certs. But leave it turned off for the automated 13 // turn this on to test EV certs. But leave it turned off for the automated
14 // testing. 14 // testing.
15 #define ALLOW_EXTERNAL_ACCESS 0 15 #define ALLOW_EXTERNAL_ACCESS 0
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 EXPECT_EQ(cert3, cert4); 533 EXPECT_EQ(cert3, cert4);
534 534
535 google_cert_handle = X509Certificate::CreateOSCertHandleFromBytes( 535 google_cert_handle = X509Certificate::CreateOSCertHandleFromBytes(
536 reinterpret_cast<const char*>(google_der), sizeof(google_der)); 536 reinterpret_cast<const char*>(google_der), sizeof(google_der));
537 scoped_refptr<X509Certificate> cert5 = X509Certificate::CreateFromHandle( 537 scoped_refptr<X509Certificate> cert5 = X509Certificate::CreateFromHandle(
538 google_cert_handle, X509Certificate::SOURCE_FROM_NETWORK); 538 google_cert_handle, X509Certificate::SOURCE_FROM_NETWORK);
539 539
540 EXPECT_EQ(cert3, cert5); 540 EXPECT_EQ(cert3, cert5);
541 } 541 }
542 542
543 TEST(X509CertificateTest, Pickle) {
544 scoped_refptr<X509Certificate> cert1 = X509Certificate::CreateFromBytes(
545 reinterpret_cast<const char*>(google_der), sizeof(google_der));
546
547 Pickle pickle;
548 cert1->Persist(&pickle);
549
550 void* iter = NULL;
551 scoped_refptr<X509Certificate> cert2 =
552 X509Certificate::CreateFromPickle(pickle, &iter);
553
554 EXPECT_EQ(cert1, cert2);
555 }
556
543 } // namespace net 557 } // namespace net
OLDNEW
« no previous file with comments | « net/base/x509_certificate_nss.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698