コード例 #1
0
def test_no_verification_sequence_nested_messages(
        sequence_message_package: Package,
        message_sequence_value: MessageValue) -> None:
    sequence_message_one = sequence_message_package.new_message(
        "Sequence_Element")
    sequence_message_one.set("Byte", 5)
    sequence_message_two = sequence_message_package.new_message(
        "Sequence_Element")
    sequence_message_two.set("Byte", 6)
    sequence: List[TypeValue] = [sequence_message_one, sequence_message_two]
    message_sequence_value.set("Length", 2)
    message_sequence_value.set("Sequence_Field", sequence)
    assert message_sequence_value.valid_message

    pyrflx_ = PyRFLX.from_specs(
        [SPEC_DIR / "sequence_message.rflx"],
        skip_model_verification=True,
        skip_message_verification=True,
    )
    sequence_message_package_unv = pyrflx_.package("Sequence_Message")
    sequence_message_unv = sequence_message_package_unv.new_message(
        "Message_Sequence")
    sequence_element_one_unv = sequence_message_package_unv.new_message(
        "Sequence_Element")
    sequence_element_one_unv.set("Byte", 5)
    sequence_element_two_unv = sequence_message_package_unv.new_message(
        "Sequence_Element")
    sequence_element_two_unv.set("Byte", 6)
    sequence_unv: List[TypeValue] = [
        sequence_element_one_unv, sequence_element_two_unv
    ]
    sequence_message_unv.set("Length", 2)
    sequence_message_unv.set("Sequence_Field", sequence_unv)
    assert sequence_message_unv.valid_message
    assert sequence_message_unv.bytestring == message_sequence_value.bytestring
コード例 #2
0
def test_sequence_message_serialization(
        sequence_message_package: Package,
        message_sequence_value: MessageValue) -> None:
    sequence_message_one = sequence_message_package.new_message(
        "Sequence_Element")
    sequence_message_one.set("Byte", 5)
    sequence_message_two = sequence_message_package.new_message(
        "Sequence_Element")
    sequence_message_two.set("Byte", 6)
    sequence: List[TypeValue] = [sequence_message_one, sequence_message_two]
    message_sequence_value.set("Length", 2)
    message_sequence_value.set("Sequence_Field", sequence)
    assert message_sequence_value.valid_message
    assert message_sequence_value.as_json() == {
        "Length": {
            "first": 0,
            "last": 7,
            "value": 2
        },
        "Sequence_Field": {
            "first":
            8,
            "last":
            23,
            "value": [
                {
                    "Byte": {
                        "first": 0,
                        "last": 7,
                        "value": 5
                    }
                },
                {
                    "Byte": {
                        "first": 0,
                        "last": 7,
                        "value": 6
                    }
                },
            ],
        },
    }
コード例 #3
0
def fixture_icmp_message(icmp_package: pyrflx.Package) -> model.Message:
    # pylint: disable = protected-access
    return icmp_package.new_message("Message")._type
コード例 #4
0
def fixture_icmp_message_value(icmp_package: pyrflx.Package) -> pyrflx.MessageValue:
    return icmp_package.new_message("Message")
コード例 #5
0
def fixture_ethernet_frame_value(ethernet_package: pyrflx.Package) -> pyrflx.MessageValue:
    return ethernet_package.new_message("Frame")
コード例 #6
0
def fixture_always_valid_aspect_value(
    always_valid_aspect_package: pyrflx.Package,
) -> pyrflx.MessageValue:
    return always_valid_aspect_package.new_message("Message")
コード例 #7
0
def fixture_message_type_size_value(
    message_type_size_package: pyrflx.Package,
) -> pyrflx.MessageValue:
    return message_type_size_package.new_message("Message")
コード例 #8
0
def fixture_sequence_message_refinement_value(
    sequence_message_package: pyrflx.Package,
) -> pyrflx.MessageValue:
    return sequence_message_package.new_message("Message_Sequence_And_Refinement")
コード例 #9
0
def fixture_sequence_message_value(sequence_message_package: pyrflx.Package) -> pyrflx.MessageValue:
    return sequence_message_package.new_message("Message_Sequence")
コード例 #10
0
def fixture_tlv_message_value(tlv_package: pyrflx.Package) -> pyrflx.MessageValue:
    return tlv_package.new_message("Message")
コード例 #11
0
def fixture_udp_datagram_value(udp_package: pyrflx.Package) -> pyrflx.MessageValue:
    return udp_package.new_message("Datagram")
コード例 #12
0
def fixture_tls_alert_value(tls_alert_package: pyrflx.Package) -> pyrflx.MessageValue:
    return tls_alert_package.new_message("Alert")
コード例 #13
0
def fixture_tls_record_value(tls_record_package: pyrflx.Package) -> pyrflx.MessageValue:
    return tls_record_package.new_message("TLS_Record")
コード例 #14
0
def fixture_ipv4_option_value(ipv4_package: pyrflx.Package) -> pyrflx.MessageValue:
    return ipv4_package.new_message("Option")
コード例 #15
0
def fixture_ipv4_packet_value(ipv4_package: pyrflx.Package) -> pyrflx.MessageValue:
    return ipv4_package.new_message("Packet")
コード例 #16
0
ファイル: test_pyrflx.py プロジェクト: kug1977/RecordFlux
def test_package_name() -> None:
    p = Package("Test")
    assert p.name == "Test"