chromium/third_party/boringssl/src/pki/verify_name_match_unittest.cc

// 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 "verify_name_match.h"

#include <gtest/gtest.h>
#include "string_util.h"
#include "test_helpers.h"

BSSL_NAMESPACE_BEGIN
namespace {

// Loads test data from file. The filename is constructed from the parameters:
// |prefix| describes the type of data being tested, e.g. "ascii",
// "unicode_bmp", "unicode_supplementary", and "invalid".
// |value_type| indicates what ASN.1 type is used to encode the data.
// |suffix| indicates any additional modifications, such as caseswapping,
// whitespace adding, etc.
::testing::AssertionResult LoadTestData(const std::string &prefix,
                                        const std::string &value_type,
                                        const std::string &suffix,
                                        std::string *result) {}

bool TypesAreComparable(const std::string &type_1, const std::string &type_2) {}

// All string types.
static const char *kValueTypes[] =;
// String types that can encode the Unicode Basic Multilingual Plane.
static const char *kUnicodeBMPValueTypes[] =;
// String types that can encode the Unicode Supplementary Planes.
static const char *kUnicodeSupplementaryValueTypes[] =;

static const char *kMangleTypes[] =;

}  // namespace

class VerifyNameMatchSimpleTest
    : public ::testing::TestWithParam<
          ::testing::tuple<const char *, const char *>> {};

// Compare each input against itself, verifies that all input data is parsed
// successfully.
TEST_P(VerifyNameMatchSimpleTest, ExactEquality) {}

// Ensure that a Name does not match another Name which is exactly the same but
// with an extra attribute in one Relative Distinguished Name.
TEST_P(VerifyNameMatchSimpleTest, ExtraAttrDoesNotMatch) {}

// Ensure that a Name does not match another Name which has the same number of
// RDNs and attributes, but where one of the attributes is duplicated in one of
// the names but not in the other.
TEST_P(VerifyNameMatchSimpleTest, DupeAttrDoesNotMatch) {}

// Ensure that a Name does not match another Name which is exactly the same but
// with an extra Relative Distinguished Name.
TEST_P(VerifyNameMatchSimpleTest, ExtraRdnDoesNotMatch) {}

// Runs VerifyNameMatchSimpleTest for all combinations of value_type and and
// suffix.
INSTANTIATE_TEST_SUITE_P();

class VerifyNameMatchNormalizationTest
    : public ::testing::TestWithParam<::testing::tuple<bool, const char *>> {};

// Verify matching is case insensitive (for the types which currently support
// normalization).
TEST_P(VerifyNameMatchNormalizationTest, CaseInsensitivity) {}

// Verify matching folds whitespace (for the types which currently support
// normalization).
TEST_P(VerifyNameMatchNormalizationTest, CollapseWhitespace) {}

// Runs VerifyNameMatchNormalizationTest for each (expected_result, value_type)
// tuple.
INSTANTIATE_TEST_SUITE_P();

class VerifyNameMatchDifferingTypesTest
    : public ::testing::TestWithParam<
          ::testing::tuple<const char *, const char *>> {};

TEST_P(VerifyNameMatchDifferingTypesTest, NormalizableTypesAreEqual) {}

TEST_P(VerifyNameMatchDifferingTypesTest, NormalizableTypesInSubtrees) {}

// Runs VerifyNameMatchDifferingTypesTest for all combinations of value types in
// value_type1 and value_type_2.
INSTANTIATE_TEST_SUITE_P();

class VerifyNameMatchUnicodeConversionTest
    : public ::testing::TestWithParam<::testing::tuple<
          const char *, ::testing::tuple<const char *, const char *>>> {};

TEST_P(VerifyNameMatchUnicodeConversionTest, UnicodeConversionsAreEqual) {}

// Runs VerifyNameMatchUnicodeConversionTest with prefix="unicode_bmp" for all
// combinations of Basic Multilingual Plane-capable value types in value_type1
// and value_type_2.
INSTANTIATE_TEST_SUITE_P();

// Runs VerifyNameMatchUnicodeConversionTest with prefix="unicode_supplementary"
// for all combinations of Unicode Supplementary Plane-capable value types in
// value_type1 and value_type_2.
INSTANTIATE_TEST_SUITE_P();

// Matching should fail if a PrintableString contains invalid characters.
TEST(VerifyNameMatchInvalidDataTest, FailOnInvalidPrintableStringChars) {}

// Matching should fail if an IA5String contains invalid characters.
TEST(VerifyNameMatchInvalidDataTest, FailOnInvalidIA5StringChars) {}

TEST(VerifyNameMatchInvalidDataTest, FailOnAttributeTypeAndValueExtraData) {}

TEST(VerifyNameMatchInvalidDataTest, FailOnAttributeTypeAndValueShort) {}

TEST(VerifyNameMatchInvalidDataTest, FailOnAttributeTypeAndValueEmpty) {}

TEST(VerifyNameMatchInvalidDataTest, FailOnBadAttributeType) {}

TEST(VerifyNameMatchInvalidDataTest, FailOnAttributeTypeAndValueNotSequence) {}

TEST(VerifyNameMatchInvalidDataTest, FailOnRdnNotSet) {}

TEST(VerifyNameMatchInvalidDataTest, FailOnEmptyRdn) {}

// Matching should fail if a BMPString contains surrogates.
TEST(VerifyNameMatchInvalidDataTest, FailOnBmpStringSurrogates) {}

TEST(VerifyNameMatchTest, EmptyNameMatching) {}

// Matching should succeed when the RDNs are sorted differently but are still
// equal after normalizing.
TEST(VerifyNameMatchRDNSorting, Simple) {}

// Matching should succeed when the RDNs are sorted differently but are still
// equal after normalizing, even in malformed RDNs that contain multiple
// elements with the same type.
TEST(VerifyNameMatchRDNSorting, DuplicateTypes) {}

TEST(VerifyNameInSubtreeInvalidDataTest, FailOnEmptyRdn) {}

TEST(VerifyNameInSubtreeTest, EmptyNameMatching) {}

// Verify that the normalized output matches the pre-generated expected value
// for a single larger input that exercises all of the string types, unicode
// (basic and supplemental planes), whitespace collapsing, case folding, as
// well as SET sorting.
TEST(NameNormalizationTest, TestEverything) {}

// Unknown AttributeValue types normalize as-is, even non-primitive tags.
TEST(NameNormalizationTest, NormalizeCustom) {}

BSSL_NAMESPACE_END