Remove linux_chromium_gn_dbg from the chromium CQ.
[chromium-blink-merge.git] / net / cert / signed_certificate_timestamp_unittest.cc
blob90b4ab740e3851897982429d45015a61a65d9bc9
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/cert/signed_certificate_timestamp.h"
7 #include <string>
9 #include "base/pickle.h"
10 #include "net/test/ct_test_util.h"
11 #include "testing/gtest/include/gtest/gtest.h"
13 namespace net {
15 namespace ct {
17 namespace {
19 const char kLogDescription[] = "somelog";
21 class SignedCertificateTimestampTest : public ::testing::Test {
22 public:
23 void SetUp() override {
24 GetX509CertSCT(&sample_sct_);
25 sample_sct_->origin = SignedCertificateTimestamp::SCT_FROM_OCSP_RESPONSE;
26 sample_sct_->log_description = kLogDescription;
29 protected:
30 scoped_refptr<SignedCertificateTimestamp> sample_sct_;
33 TEST_F(SignedCertificateTimestampTest, PicklesAndUnpickles) {
34 base::Pickle pickle;
36 sample_sct_->Persist(&pickle);
37 base::PickleIterator iter(pickle);
39 scoped_refptr<SignedCertificateTimestamp> unpickled_sct(
40 SignedCertificateTimestamp::CreateFromPickle(&iter));
42 SignedCertificateTimestamp::LessThan less_than;
44 ASSERT_FALSE(less_than(sample_sct_, unpickled_sct));
45 ASSERT_FALSE(less_than(unpickled_sct, sample_sct_));
46 ASSERT_EQ(sample_sct_->origin, unpickled_sct->origin);
47 ASSERT_EQ(sample_sct_->log_description, unpickled_sct->log_description);
50 TEST_F(SignedCertificateTimestampTest, SCTsWithDifferentOriginsNotEqual) {
51 scoped_refptr<SignedCertificateTimestamp> another_sct;
52 GetX509CertSCT(&another_sct);
53 another_sct->origin = SignedCertificateTimestamp::SCT_FROM_TLS_EXTENSION;
55 SignedCertificateTimestamp::LessThan less_than;
57 ASSERT_TRUE(less_than(sample_sct_, another_sct) ||
58 less_than(another_sct, sample_sct_));
61 } // namespace
63 } // namespace ct
65 } // namespace net