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 ofClientHello
.
-
-
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 ofServerHello
.
-
test_parse_server_hello_extensions
()¶ parse_server_hello()
returns an instance ofServerHello
.
-
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.
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 ofTLSPlaintext
, 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 trivialconstruct.Construct()
.
-
test_decode_passes_value_through
(bytes_adapted, value)¶
-
-
class
tls.test.test_utils.
TestEnumClass
¶ Bases:
object
Tests for
tls.utils.EnumClass()
.-
UBInt8Enum
()¶ A
tls.utils.EnumClass()
that adaptsIntegerEnum
‘s members toUBInt8()
.
-
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()
raisesconstruct.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 antls.utils.EnumSwitch()
that switches onIntegerEnum
. The struct’svalue
field varies depending on the value of itstype
and the corresponding enum member specified in thevalue_choices
dictionary passed to thetls.utils.EnumSwitch()
.
-
test_build
(UBInt8EnumMappedStruct, type_, value, encoded)¶ A struct that contains
tls.utils.EnumSwitch()
encodes itsvalue_field
according to the enum member specified in itstype_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 itstype_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 sametls.utils.EnumSwitch()
and vice versa.
-
-
class
tls.test.test_utils.
TestPrefixedBytesWithDefaultLength
¶ Bases:
object
Tests for
tls.utils.PrefixedBytes()
with the defaultconstruct.macros.UBInt8()
length_field
construct.-
prefixed_bytes
()¶ A trivial
tls.utils.PrefixedBytes()
construct with the defaultconstruct.macros.UBInt8()
length field.
-
test_build
(prefixed_bytes, bytestring, encoded)¶ tls.utils.PrefixedBytes()
encodesbytes
as a length-prefixed byte sequence.
-
test_parse
(prefixed_bytes, bytestring, encoded)¶ tls.utils.PrefixedBytes()
decodes a length-prefixed byte sequence asbytes
.
-
test_round_trip
(prefixed_bytes, bytestring, encoded)¶ tls.utils.PrefixedBytes()
decodes a length-prefixed binary sequence encoded bytls.utils.PrefixedBytes()
and vice versa.
-
-
class
tls.test.test_utils.
TestPrefixedBytesWithOverriddenLength
¶ Bases:
object
Tests for
tls.utils.PrefixedBytes()
with a user-suppliedlength_field
construct.-
test_build
(bytestring, encoded, length_field)¶ tls.utils.PrefixedBytes()
uses the suppliedlength_field
to encodebytes
as a length-prefix binary sequence.
-
test_parse
(bytestring, encoded, length_field)¶ tls.utils.PrefixedBytes()
decodes a length-prefixed binary sequence intobytes
according to the suppliedlength_field
.
-
test_round_trip
(bytestring, encoded, length_field)¶ tls.utils.PrefixedBytes()
decodes a length-prefixed binary sequence encoded bytls.utils.PrefixedBytes()
when the two share alength_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 givenconstruct.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 givenconstruct.Construct()
decodes a binary sequence, prefixed by its 16-bit length, as alist
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 atls.utils.TLSPrefixedArray()
specialized on the same construct and vice versa.
-
tls_array
()¶ A
tls.utils.TLSPrefixedArray()
ofconstruct.macros.UBInt8()
.
-