| Index: net/cert/ct_objects_extractor_unittest.cc
|
| diff --git a/net/cert/ct_objects_extractor_unittest.cc b/net/cert/ct_objects_extractor_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..2e04a327556e3eeedb93535a44b5919cef1c61cf
|
| --- /dev/null
|
| +++ b/net/cert/ct_objects_extractor_unittest.cc
|
| @@ -0,0 +1,67 @@
|
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "net/cert/ct_objects_extractor.h"
|
| +
|
| +#include "base/files/file_path.h"
|
| +#include "net/base/test_data_directory.h"
|
| +#include "net/cert/ct_serialization.h"
|
| +#include "net/cert/signed_certificate_timestamp.h"
|
| +#include "net/cert/x509_certificate.h"
|
| +#include "net/test/cert_test_util.h"
|
| +#include "net/test/ct_test_util.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace net {
|
| +
|
| +namespace ct {
|
| +
|
| +class CTObjectsExtractorTest : public ::testing::Test {
|
| + public:
|
| + virtual void SetUp() OVERRIDE {
|
| + certs_ = CreateCertificateListFromFile(
|
| + GetTestCertsDirectory(), "ct-test-embedded-cert.pem",
|
| + X509Certificate::FORMAT_AUTO);
|
| + ASSERT_EQ(2u, certs_.size());
|
| + }
|
| +
|
| + protected:
|
| + CertificateList certs_;
|
| + int blah_;
|
| +};
|
| +
|
| +TEST_F(CTObjectsExtractorTest, ExtractEmbeddedSCT) {
|
| + std::string sct_list;
|
| + EXPECT_TRUE(ExtractEmbeddedSCTs(certs_[0]->os_cert_handle(), &sct_list));
|
| +
|
| + std::vector<base::StringPiece> parsed_scts;
|
| + base::StringPiece sct_list_sp(sct_list);
|
| + // Make sure the SCTs list can be decoded properly
|
| + EXPECT_TRUE(DecodeSCTList(&sct_list_sp, &parsed_scts));
|
| +
|
| + // And the signature data is the expected value.
|
| + ct::SignedCertificateTimestamp sct;
|
| + EXPECT_TRUE(DecodeSignedCertificateTimestamp(&(parsed_scts[0]), &sct));
|
| +
|
| + EXPECT_EQ(sct.version, SignedCertificateTimestamp::SCT_VERSION_1);
|
| + EXPECT_EQ(ct::GetTestPublicKeyId(), sct.log_id);
|
| +}
|
| +
|
| +TEST_F(CTObjectsExtractorTest, ExtractPrecert) {
|
| + LogEntry entry;
|
| + ASSERT_TRUE(GetPrecertLogEntry(certs_[0]->os_cert_handle(),
|
| + certs_[1]->os_cert_handle(),
|
| + &entry));
|
| +
|
| + // XXX(rsleevi): Add KAT for the Precert data.
|
| +}
|
| +
|
| +// XXX(eranm): Test that the extracted SCT is the expected one
|
| +// XXX(eranm): Test that the embedded SCT verifies
|
| +// XXX(eranm): Test that an externally-provided SCT verifies over the LogEntry
|
| +// of a regular X.509 Certificate
|
| +
|
| +} // namespace ct
|
| +
|
| +} // namespace net
|
|
|