// Copyright (c) 2015 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 "quiche/http2/core/spdy_alt_svc_wire_format.h" #include <cstddef> #include <cstdint> #include <string> #include "absl/strings/string_view.h" #include "quiche/common/platform/api/quiche_test.h" namespace spdy { namespace test { // Expose all private methods of class SpdyAltSvcWireFormat. class SpdyAltSvcWireFormatPeer { … }; namespace { // Generate header field values, possibly with multiply defined parameters and // random case, and corresponding AlternativeService entries. void FuzzHeaderFieldValue( int i, std::string* header_field_value, SpdyAltSvcWireFormat::AlternativeService* expected_altsvc) { … } // Generate AlternativeService entries and corresponding header field values in // canonical form, that is, what SerializeHeaderFieldValue() should output. void FuzzAlternativeService(int i, SpdyAltSvcWireFormat::AlternativeService* altsvc, std::string* expected_header_field_value) { … } // Tests of public API. TEST(SpdyAltSvcWireFormatTest, DefaultValues) { … } TEST(SpdyAltSvcWireFormatTest, ParseInvalidEmptyHeaderFieldValue) { … } TEST(SpdyAltSvcWireFormatTest, ParseHeaderFieldValueClear) { … } // Fuzz test of ParseHeaderFieldValue() with optional whitespaces, ignored // parameters, duplicate parameters, trailing space, trailing alternate service // separator, etc. Single alternative service at a time. TEST(SpdyAltSvcWireFormatTest, ParseHeaderFieldValue) { … } // Fuzz test of ParseHeaderFieldValue() with optional whitespaces, ignored // parameters, duplicate parameters, trailing space, trailing alternate service // separator, etc. Possibly multiple alternative service at a time. TEST(SpdyAltSvcWireFormatTest, ParseHeaderFieldValueMultiple) { … } TEST(SpdyAltSvcWireFormatTest, SerializeEmptyHeaderFieldValue) { … } // Test ParseHeaderFieldValue() and SerializeHeaderFieldValue() on the same pair // of |expected_header_field_value| and |altsvc|, with and without hostname and // each // parameter. Single alternative service at a time. TEST(SpdyAltSvcWireFormatTest, RoundTrip) { … } // Test ParseHeaderFieldValue() and SerializeHeaderFieldValue() on the same pair // of |expected_header_field_value| and |altsvc|, with and without hostname and // each // parameter. Multiple alternative services at a time. TEST(SpdyAltSvcWireFormatTest, RoundTripMultiple) { … } // ParseHeaderFieldValue() should return false on malformed field values: // invalid percent encoding, unmatched quotation mark, empty port, non-numeric // characters in numeric fields. TEST(SpdyAltSvcWireFormatTest, ParseHeaderFieldValueInvalid) { … } // ParseHeaderFieldValue() should return false on a field values truncated // before closing quotation mark, without trying to access memory beyond the end // of the input. TEST(SpdyAltSvcWireFormatTest, ParseTruncatedHeaderFieldValue) { … } // Tests of private methods. // Test SkipWhiteSpace(). TEST(SpdyAltSvcWireFormatTest, SkipWhiteSpace) { … } // Test PercentDecode() on valid input. TEST(SpdyAltSvcWireFormatTest, PercentDecodeValid) { … } // Test PercentDecode() on invalid input. TEST(SpdyAltSvcWireFormatTest, PercentDecodeInvalid) { … } // Test ParseAltAuthority() on valid input. TEST(SpdyAltSvcWireFormatTest, ParseAltAuthorityValid) { … } // Test ParseAltAuthority() on invalid input: empty string, no port, zero port, // non-digit characters following port. TEST(SpdyAltSvcWireFormatTest, ParseAltAuthorityInvalid) { … } // Test ParseInteger() on valid input. TEST(SpdyAltSvcWireFormatTest, ParseIntegerValid) { … } // Test ParseIntegerValid() on invalid input: empty, zero, non-numeric, trailing // non-numeric characters. TEST(SpdyAltSvcWireFormatTest, ParseIntegerInvalid) { … } // Test ParseIntegerValid() around overflow limit. TEST(SpdyAltSvcWireFormatTest, ParseIntegerOverflow) { … } // Test parsing an Alt-Svc entry with IP literal hostname. // Regression test for https://crbug.com/664173. TEST(SpdyAltSvcWireFormatTest, ParseIPLiteral) { … } TEST(SpdyAltSvcWireFormatTest, HexDigitToInt) { … } TEST(SpdyAltSvcWireFormatTest, HexDecodeToUInt32) { … } } // namespace } // namespace test } // namespace spdy