def test_create_message(self): message = SMB2CreateResponseLease() message['lease_key'] = b"\xff" * 16 message['lease_state'].set_flag(LeaseState.SMB2_LEASE_HANDLE_CACHING) message['lease_flags'].set_flag( LeaseResponseFlags.SMB2_LEASE_FLAG_BREAK_IN_PROGRESS) message['lease_duration'] = 12 expected = b"\xff\xff\xff\xff\xff\xff\xff\xff" \ b"\xff\xff\xff\xff\xff\xff\xff\xff" \ b"\x02\x00\x00\x00" \ b"\x02\x00\x00\x00" \ b"\x0c\x00\x00\x00\x00\x00\x00\x00" actual = message.pack() assert len(message) == 32 assert actual == expected
def test_parse_message(self): actual = SMB2CreateResponseLease() data = b"\xff\xff\xff\xff\xff\xff\xff\xff" \ b"\xff\xff\xff\xff\xff\xff\xff\xff" \ b"\x02\x00\x00\x00" \ b"\x02\x00\x00\x00" \ b"\x0c\x00\x00\x00\x00\x00\x00\x00" data = actual.unpack(data) assert len(actual) == 32 assert data == b"" assert actual['lease_key'].get_value() == b"\xff" * 16 assert actual['lease_state'].get_value() == \ LeaseState.SMB2_LEASE_HANDLE_CACHING assert actual['lease_flags'].get_value() == \ LeaseResponseFlags.SMB2_LEASE_FLAG_BREAK_IN_PROGRESS assert actual['lease_duration'].get_value() == 12