def test_parse_message(self): actual = FaultPDU() data = b"\x05" \ b"\x00" \ b"\x03" \ b"\x22" \ b"\x10\x00\x00\x00" \ b"\x1c\x00" \ b"\x00\x00" \ b"\x01\x00\x00\x00" \ b"\x20\x00\x00\x00" \ b"\x00\x00" \ b"\x00" \ b"\x00" \ b"\x02\x00\x00\x1c" data = actual.unpack(data) assert len(actual) == 28 assert data == b"" assert actual['rpc_vers'].get_value() == 5 assert actual['rpc_vers_minor'].get_value() == 0 assert actual['ptype'].get_value() == PType.FAULT assert actual['pfx_flags'].get_value() == 34 assert actual['packed_drep'].pack() == b"\x10\x00\x00\x00" assert actual['frag_length'].get_value() == 28 assert actual['auth_length'].get_value() == 0 assert actual['call_id'].get_value() == 1 assert actual['alloc_hint'].get_value() == 32 assert actual['p_cont_id'].get_value() == 0 assert actual['cancel_count'].get_value() == 0 assert actual['reserved'].get_value() == 0 assert actual['status'].get_value() == \ FaultStatus.NCA_S_FAULT_ADDR_ERROR
def test_parse_pdu_failure(self): connection = Connection(uuid.uuid4(), "server", 445) session = Session(connection, "user", "password") api = SCMRApi(session) fault_pdu = FaultPDU() fault_pdu['packed_drep'] = DataRepresentationFormat() with pytest.raises(PDUException) as exc: api._parse_pdu(fault_pdu.pack(), 10) assert "Expecting ResponsePDU for opnum 10 response but got: " \ "FaultPDU" in str(exc.value)
def test_create_message(self): message = FaultPDU() message['pfx_flags'].set_flag(PFlags.PFC_DID_NOT_EXECUTE) message['pfx_flags'].set_flag(PFlags.PFC_LAST_FRAG) message['packed_drep'] = DataRepresentationFormat() message['call_id'] = 1 message['alloc_hint'] = 32 message['status'] = FaultStatus.NCA_S_FAULT_ADDR_ERROR expected = b"\x05" \ b"\x00" \ b"\x03" \ b"\x22" \ b"\x10\x00\x00\x00" \ b"\x1c\x00" \ b"\x00\x00" \ b"\x01\x00\x00\x00" \ b"\x20\x00\x00\x00" \ b"\x00\x00" \ b"\x00" \ b"\x00" \ b"\x02\x00\x00\x1c" actual = message.pack() assert len(message) == 28 assert actual == expected