// Copyright 2015 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include <algorithm> #include <gtest/gtest.h> #include "extended_key_usage.h" #include "input.h" BSSL_NAMESPACE_BEGIN namespace { // Helper method to check if an EKU is present in a std::vector of EKUs. bool HasEKU(const std::vector<der::Input> &list, der::Input eku) { … } // Check that we can read multiple EKUs from an extension. TEST(ExtendedKeyUsageTest, ParseEKUExtension) { … } // Check that an extension with the same OID present multiple times doesn't // cause an error. TEST(ExtendedKeyUsageTest, RepeatedOid) { … } // Check that parsing an EKU extension which contains a private OID doesn't // cause an error. TEST(ExtendedKeyUsageTest, ParseEKUExtensionGracefullyHandlesPrivateOids) { … } // Test a variety of bad inputs. // If the extension value has data following the sequence of oids, parsing it // should fail. TEST(ExtendedKeyUsageTest, ExtraData) { … } // Check that ParseEKUExtension only accepts a sequence containing only oids. // This test case has an integer in the sequence (which should fail). A key // difference between this test case and ExtendedKeyUsageTest.ExtraData is where // the sequence ends - in this test case the integer is still part of the // sequence, while in ExtendedKeyUsageTest.ExtraData the integer is after the // sequence. TEST(ExtendedKeyUsageTest, NotAnOid) { … } // Checks that the list of oids passed to ParseEKUExtension are in a sequence, // instead of one or more oid tag-length-values concatenated together. TEST(ExtendedKeyUsageTest, NotASequence) { … } // A sequence passed into ParseEKUExtension must have at least one oid in it. TEST(ExtendedKeyUsageTest, EmptySequence) { … } // The extension value must not be empty. TEST(ExtendedKeyUsageTest, EmptyExtension) { … } } // namespace BSSL_NAMESPACE_END