Commit 5188a187 authored by Elena Grandi's avatar Elena Grandi
Browse files

When using the ip as a name, keep it up to date with changes

parent 2f63ea2a
......@@ -130,6 +130,9 @@ class Machine:
# better as soon as possible.
if == self.mac and self.ip is not None: = self.ip
# When using the ip as a name, keep it up to date with changes
if "ip" in changes and == changes["ip"][0]: = self.ip
return changes
......@@ -196,6 +196,24 @@ class TestMockMachineStore(AsyncTestCase):
self.assertEqual([mac].name, ip)
async def test_add_machine_by_ip_no_name_then_change_ip(self):
mac = '52:54:00:f2:f7:64'
ip = ''
gathered = await self.post_host_seen(mac=mac, ip=ip)
self.assertIsInstance(gathered[1], events.HostNewEvent)
self.assertEqual([mac].ip, ip)
self.assertEqual([mac].name, ip)
new_ip = ''
gathered = await self.post_host_seen(mac=mac, ip=new_ip)
self.assertIsInstance(gathered[1], events.HostChangedEvent)
self.assertEqual([mac].ip, new_ip)
self.assertEqual([mac].name, new_ip)
async def test_add_machine_w_timestamp(self):
mac = self.machine['mac']
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment