tls.test package

Submodules

tls.test.test_alert module

tls.test.test_ciphersuites module

tls.test.test_hello_messages module

class tls.test.test_hello_messages.TestClientHello

Bases: object

Tests for the parsing of ClientHello messages.

test_as_bytes_no_extensions()

ClientHello.as_bytes() returns the bytes it was created with

test_as_bytes_with_extensions()

ClientHello.as_bytes() returns the bytes it was created with

test_resumption_no_extensions()

parse_client_hello() returns an instance of ClientHello.

class tls.test.test_hello_messages.TestServerHello

Bases: object

Tests for the parsing of ServerHello messages.

test_as_bytes_no_extensions()

ServerHello.as_bytes() returns the bytes it was created with

test_as_bytes_with_extensions()

ServerHello.as_bytes() returns the bytes it was created with

test_parse_server_hello()

parse_server_hello() returns an instance of ServerHello.

test_parse_server_hello_extensions()

parse_server_hello() returns an instance of ServerHello.

tls.test.test_message module

class tls.test.test_message.TestCertificateParsing

Bases: object

Tests for parsing of Certificate messages.

class tls.test.test_message.TestCertificateRequestParsing

Bases: object

Tests for parsing of CertificateRequest messages.

class tls.test.test_message.TestHandshakeStructParsing

Bases: object

Tests for parsing of Handshake structs.

class tls.test.test_message.TestPreMasterSecretParsing

Bases: object

Tests for parsing of PreMasterSecret struct.

class tls.test.test_message.TestServerDHParamsparsing

Bases: object

Tests for parsing of ServerDHParams struct.

tls.test.test_record module

class tls.test.test_record.TestTLSCiphertextParser

Bases: object

Tests for parsing of TLSCiphertext records.

test_parse_tls_ciphertext_handshake()

TLSCiphertext, which has attributes representing all the fields in the TLSCiphertext struct.

class tls.test.test_record.TestTLSCompressedParsing

Bases: object

Tests for parsing of TLSCompressed records.

test_incomplete_packet()

Reject an incomplete packet

test_not_enough_data_to_fragment()

Detect insufficient data to fragment.

test_parse_tls_compressed_handshake()

TLSCompressed, which has attributes representing all the fields in the TLSCompressed struct.

test_parse_tls_compressed_wrong_type()

Raise an error when the type is not one of those defined in ContentType

class tls.test.test_record.TestTLSPlaintextParsing

Bases: object

Tests for parsing of TLSPlaintext records.

test_as_bytes()

Construct a TLSPlaintext object as bytes.

test_incomplete_packet()

Reject an incomplete packet

test_not_enough_data_to_fragment()

Detect insufficient data to fragment.

test_parse_tls_plaintext_handshake()

parse_tls_plaintext() returns an instance of TLSPlaintext, which has attributes representing all the fields in the TLSPlaintext struct.

test_parse_tls_plaintext_wrong_type()

Raise an error when the type is not one of those defined in ContentType

tls.test.test_utils module

class tls.test.test_utils.IntegerEnum

Bases: enum.Enum

An enum of int instances. Used as a test fixture.

class tls.test.test_utils.TestBytesAdapter

Bases: object

Tests for tls.utils.BytesAdapter.

bytes_adapted()

A tls.utils.BytesAdapter that adapts a trivial construct.Construct().

test_decode_passes_value_through(bytes_adapted, value)

tls.utils.BytesAdapter._decode() decodes bytes as bytes.

test_encode_allows_bytes(bytes_adapted, byte_string)

tls.utils.BytesAdapter._encode() encodes bytes without raising an exception.

test_encode_disallows_non_bytes(bytes_adapted, non_bytes)

tls.utils.BytesAdapter._encode() raises a construct.core.AdaptationError when encoding anything that isn’t bytes.

class tls.test.test_utils.TestEnumClass

Bases: object

Tests for tls.utils.EnumClass().

UBInt8Enum()

A tls.utils.EnumClass() that adapts IntegerEnum‘s members to UBInt8().

test_build(UBInt8Enum)

tls.utils.EnumClass() encodes members of its enum according to its construct.

test_build_enum_has_wrong_type(UBInt8Enum)

tls.utils.EnumClass() raises construct.adapters.MappingError when encoding something that isn’t a member of its enum.

test_parse(UBInt8Enum)

tls.utils.EnumClass() decodes a binary sequence as members of its enum via its construct.

class tls.test.test_utils.TestEnumSwitch

Bases: object

Tests for tls.utils.EnumSwitch().

UBInt8EnumMappedStruct()

A construct.core.Struct containing an tls.utils.EnumSwitch() that switches on IntegerEnum. The struct’s value field varies depending on the value of its type and the corresponding enum member specified in the value_choices dictionary passed to the tls.utils.EnumSwitch().

test_build(UBInt8EnumMappedStruct, type_, value, encoded)

A struct that contains tls.utils.EnumSwitch() encodes its value_field according to the enum member specified in its type_field.

test_parse(UBInt8EnumMappedStruct, type_, value, encoded)

A struct that contains tls.utils.EnumSwitch() decodes its value field according to the enum member specified by its type_field.

test_round_trip(UBInt8EnumMappedStruct, type_, value, encoded)

A struct that contains tls.utils.EnumSwitch() decodes a binary sequence encoded by a struct with that same tls.utils.EnumSwitch() and vice versa.

class tls.test.test_utils.TestPrefixedBytesWithDefaultLength

Bases: object

Tests for tls.utils.PrefixedBytes() with the default construct.macros.UBInt8() length_field construct.

prefixed_bytes()

A trivial tls.utils.PrefixedBytes() construct with the default construct.macros.UBInt8() length field.

test_build(prefixed_bytes, bytestring, encoded)

tls.utils.PrefixedBytes() encodes bytes as a length-prefixed byte sequence.

test_parse(prefixed_bytes, bytestring, encoded)

tls.utils.PrefixedBytes() decodes a length-prefixed byte sequence as bytes.

test_round_trip(prefixed_bytes, bytestring, encoded)

tls.utils.PrefixedBytes() decodes a length-prefixed binary sequence encoded by tls.utils.PrefixedBytes() and vice versa.

class tls.test.test_utils.TestPrefixedBytesWithOverriddenLength

Bases: object

Tests for tls.utils.PrefixedBytes() with a user-supplied length_field construct.

test_build(bytestring, encoded, length_field)

tls.utils.PrefixedBytes() uses the supplied length_field to encode bytes as a length-prefix binary sequence.

test_parse(bytestring, encoded, length_field)

tls.utils.PrefixedBytes() decodes a length-prefixed binary sequence into bytes according to the supplied length_field.

test_round_trip(bytestring, encoded, length_field)

tls.utils.PrefixedBytes() decodes a length-prefixed binary sequence encoded by tls.utils.PrefixedBytes() when the two share a length_field and vice versa.

class tls.test.test_utils.TestTLSPrefixedArray

Bases: object

Tests for tls.utils.TLSPrefixedArray().

test_build(tls_array, ints, uint8_encoded)

A tls.utils.TLSPrefixedArray() specialized on a given construct.Construct() encodes a sequence of objects as a 16-bit length followed by each object as encoded by that construct.

test_parse(tls_array, ints, uint8_encoded)

A tls.utils.TLSPrefixedArray() specialized on a given construct.Construct() decodes a binary sequence, prefixed by its 16-bit length, as a list of objects decoded by that construct.

test_round_trip(tls_array, ints, uint8_encoded)

A tls.utils.TLSPrefixedArray() decodes a length-prefixed binary sequence encoded by a tls.utils.TLSPrefixedArray() specialized on the same construct and vice versa.

tls_array()

A tls.utils.TLSPrefixedArray() of construct.macros.UBInt8().

class tls.test.test_utils.UnicodeEnum

Bases: enum.Enum

An enum of str (or unicode) instances. Used as a test fixture.

Module contents