本文整理汇总了Python中model.hosts.Host类的典型用法代码示例。如果您正苦于以下问题:Python Host类的具体用法?Python Host怎么用?Python Host使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Host类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_host_creation
def test_host_creation(self):
name = "pepito"
os = "Windows"
host_id = self.client.createHost(name, os)
host = Host(name, os)
self.assertEquals(host.getID(), host_id, "ids should be the same")
开发者ID:BwRy,项目名称:faraday,代码行数:7,代码来源:integration_create_model_objects_api.py
示例2: test_host_create_and_delete
def test_host_create_and_delete(self):
host = Host(name="coquito")
self.mapper_manager.save(host)
h_id = host.getID()
self.assertNotEquals(
self.mapper_manager.find(h_id),
None,
"Host should be in the mapper")
self.assertNotEquals(
self.connector.getDocument(h_id),
None,
"Host should be in the db")
self.mapper_manager.remove(h_id)
self.assertEquals(
self.mapper_manager.find(h_id),
None,
"Host shouldn't exist anymore in the mapper")
self.assertEquals(
self.connector.getDocument(h_id),
None,
"Host shouldn't exist anymore in the db")
开发者ID:BwRy,项目名称:faraday,代码行数:26,代码来源:mapper_integration.py
示例3: test_interface_creation
def test_interface_creation(self):
name = "pepito"
os = "Windows"
host = Host(name, os)
when(self._model_controller).find(host.getID()).thenReturn(host)
name = ""
mac = "00:00:00:00:00:00"
ipv4_address = "0.0.0.0"
ipv4_mask = "0.0.0.0"
ipv4_gateway = "0.0.0.0"
ipv4_dns = []
ipv6_address = "0000:0000:0000:0000:0000:0000:0000:0000"
ipv6_prefix = "00"
ipv6_gateway = "0000:0000:0000:0000:0000:0000:0000:0000"
ipv6_dns = []
network_segment = ""
hostname_resolution = []
interface_id = self.client.createInterface(
name, mac, ipv4_address, ipv4_mask, ipv4_gateway, ipv4_dns,
ipv6_address, ipv6_prefix, ipv6_gateway, ipv6_dns, network_segment,
hostname_resolution, host.getID())
interface = Interface(
name, mac, ipv4_address, ipv4_mask, ipv4_gateway, ipv4_dns,
ipv6_address, ipv6_prefix, ipv6_gateway, ipv6_dns, network_segment,
hostname_resolution, parent_id=host.getID())
self.assertNotEquals(
interface_id, None, "interface created shouldn't be None")
self.assertEquals(
interface.getID(), interface_id, "ids should be the same")
开发者ID:BwRy,项目名称:faraday,代码行数:35,代码来源:integration_create_model_objects_api.py
示例4: testAddInterfaceToHost
def testAddInterfaceToHost(self):
host = Host('coco')
inter = Interface('cuca')
host.addChild(inter)
self.assertIn(inter, host.childs.values(), 'Interface not in childs')
self.assertIn(inter, host.getAllInterfaces(), 'Interface not accessible')
开发者ID:BecomingMore,项目名称:faraday,代码行数:7,代码来源:model_composite.py
示例5: test_host_serialization
def test_host_serialization(self):
host = Host(name="pepito", os="linux")
host.setDescription("Some description")
host.setOwned(True)
hserialized = self.hmapper.serialize(host)
# if serialization fails, returns None
self.assertNotEqual(
hserialized,
None,
"Serialized host shouldn't be None")
# we check the host attributes
self.assertEquals(
hserialized.get("_id"),
host.getID(),
"Serialized ID is not the same as Host ID")
self.assertEquals(
hserialized.get("name"),
host.getName(),
"Serialized name is not the same as Host name")
self.assertEquals(
hserialized.get("os"),
host.getOS(),
"Serialized OS is not the same as Host OS")
self.assertEquals(
hserialized.get("description"),
host.getDescription(),
"Serialized description is not the same as Host description")
self.assertEquals(
hserialized.get("owned"),
host.isOwned(),
"Serialized owned flag is not the same as Host owned flag")
开发者ID:BwRy,项目名称:faraday,代码行数:31,代码来源:mapper.py
示例6: test_composite_host
def test_composite_host(self):
# add host
host = Host(name="pepito", os="linux")
host.setDescription("Some description")
host.setOwned(True)
self.mapper_manager.save(host)
# add inteface
iface = Interface(name="192.168.10.168", mac="01:02:03:04:05:06")
iface.setDescription("Some description")
iface.setOwned(True)
iface.addHostname("www.test.com")
iface.setIPv4({
"address": "192.168.10.168",
"mask": "255.255.255.0",
"gateway": "192.168.10.1",
"DNS": "192.168.10.1"
})
iface.setPortsOpened(2)
iface.setPortsClosed(3)
iface.setPortsFiltered(4)
host.addChild(iface)
self.mapper_manager.save(iface)
h = self.mapper_manager.find(host.getID())
self.assertEquals(
len(h.getAllInterfaces()),
len(host.getAllInterfaces()),
"Interfaces from original host should be equals to retrieved host's interfaces")
i = self.mapper_manager.find(h.getAllInterfaces()[0].getID())
self.assertEquals(
i.getID(),
iface.getID(),
"Interface's id' from original host should be equals to retrieved host's interface's id")
开发者ID:BwRy,项目名称:faraday,代码行数:34,代码来源:mapper_integration.py
示例7: testHostSetInterfaces
def testHostSetInterfaces(self):
host = Host('coco')
interfaces = {}
for i in range(50, 60):
inter = Interface('cuca%s' % i, ipv4_address="192.168.0.%d" % i)
interfaces[inter.getID()] = inter
host.setInterfaces(interfaces)
self.assertEquals(len(host.getChildsByType(Interface.__name__)), 10, "not all interfaces added")
for s in interfaces.values():
self.assertIn(s, host.getChildsByType(Interface.__name__), "what happened with interfaces?")
开发者ID:BecomingMore,项目名称:faraday,代码行数:11,代码来源:model_composite.py
示例8: test_host_creation
def test_host_creation(self):
host = Host(name="pepito", os="linux")
self.hmapper.save(host)
h = self.hmapper.find(host.getID())
self.assertEquals(
h,
host,
"Host retrieved should be the same as persisted")
self.assertEquals(
h.getID(),
host.getID(),
"Host retrieved's Id should be the same as persisted's Id")
开发者ID:BwRy,项目名称:faraday,代码行数:12,代码来源:mapper.py
示例9: testDeleteHostObjectDispatchRemoveSYNC
def testDeleteHostObjectDispatchRemoveSYNC(self):
host = Host("coquito")
mappersManager = self.createMapperMock()
objectMapper = mock()
when(mappersManager).getMapper(host.getID()).thenReturn(objectMapper)
when(objectMapper).delObject(host.getID()).thenReturn(True)
model_controller = controller.ModelController(mock(), mappersManager)
model_controller.delHostSYNC(host)
verify(mappersManager).getMapper(host.getID())
verify(objectMapper).delObject(host.getID())
开发者ID:BwRy,项目名称:faraday,代码行数:12,代码来源:model_controller.py
示例10: testDeleteHostObjectDispatchRemoveASYNC
def testDeleteHostObjectDispatchRemoveASYNC(self):
host = Host("coquito")
mappersManager = self.createMapperMock()
objectMapper = mock()
when(mappersManager).find(host.getID()).thenReturn(host)
when(mappersManager).remove(host.getID()).thenReturn(True)
model_controller = controller.ModelController(mock(), mappersManager)
model_controller.delHostASYNC(host.getID())
model_controller.processAllPendingActions()
verify(mappersManager).remove(host.getID())
开发者ID:BecomingMore,项目名称:faraday,代码行数:13,代码来源:dont_run_but_update_model_controller.py
示例11: testAddInterfaceGetsMapperDispatchSaveSYNC
def testAddInterfaceGetsMapperDispatchSaveSYNC(self):
host = Host('coco')
interface = Interface("int_mock0")
mappersManager = self.createMapperMock()
objectMapper = mock()
when(mappersManager).getMapper(interface).thenReturn(objectMapper)
when(objectMapper).saveObject(interface).thenReturn(True)
model_controller = controller.ModelController(mock(), mappersManager)
model_controller.addInterfaceSYNC(host.getID(), interface)
verify(mappersManager).getMapper(interface)
verify(objectMapper).saveObject(interface)
开发者ID:BwRy,项目名称:faraday,代码行数:14,代码来源:model_controller.py
示例12: testAddVulnToHostGetsMapperDispatchSaveSYNC
def testAddVulnToHostGetsMapperDispatchSaveSYNC(self):
host = Host("pepito")
vuln = ModelObjectVuln("a_vuln")
mappersManager = self.createMapperMock()
objectMapper = mock()
when(mappersManager).getMapper(vuln).thenReturn(objectMapper)
when(objectMapper).saveObject(vuln).thenReturn(True)
model_controller = controller.ModelController(mock(), mappersManager)
model_controller.addVulnToHostSYNC(host.getID(), vuln)
verify(mappersManager).getMapper(vuln)
verify(objectMapper).saveObject(vuln)
开发者ID:BwRy,项目名称:faraday,代码行数:15,代码来源:model_controller.py
示例13: testAddNoteToModelObjectSYNC
def testAddNoteToModelObjectSYNC(self):
host = Host("pepito")
note = ModelObjectNote("a_note")
mappersManager = self.createMapperMock()
objectMapper = mock()
when(mappersManager).getMapper(note).thenReturn(objectMapper)
when(objectMapper).saveObject(note).thenReturn(True)
model_controller = controller.ModelController(mock(), mappersManager)
model_controller.addNoteSYNC(host.getID(), note)
verify(mappersManager).getMapper(note)
verify(objectMapper).saveObject(note)
开发者ID:BwRy,项目名称:faraday,代码行数:15,代码来源:model_controller.py
示例14: testAddInterfaceGetsMapperDispatchSaveASYNC
def testAddInterfaceGetsMapperDispatchSaveASYNC(self):
host = Host('coco')
interface = Interface("int_mock0")
mappersManager = self.createMapperMock()
objectMapper = mock()
when(mappersManager).getMapper(interface.class_signature).thenReturn(objectMapper)
when(objectMapper).save(interface).thenReturn(True)
model_controller = controller.ModelController(mock(), mappersManager)
model_controller.addInterfaceASYNC(host.getID(), interface)
model_controller.processAllPendingActions()
verify(mappersManager).getMapper(interface.class_signature)
verify(objectMapper).save(interface)
开发者ID:BecomingMore,项目名称:faraday,代码行数:16,代码来源:dont_run_but_update_model_controller.py
示例15: testAddVulnToHostGetsMapperDispatchSaveASYNC
def testAddVulnToHostGetsMapperDispatchSaveASYNC(self):
host = Host("pepito")
vuln = ModelObjectVuln("a_vuln")
mappersManager = self.createMapperMock()
objectMapper = mock()
when(mappersManager).getMapper(vuln.class_signature).thenReturn(objectMapper)
when(objectMapper).save(vuln).thenReturn(True)
model_controller = controller.ModelController(mock(), mappersManager)
model_controller.addVulnToHostASYNC(host.getID(), vuln)
model_controller.processAllPendingActions()
verify(mappersManager).getMapper(vuln.class_signature)
verify(objectMapper).save(vuln)
开发者ID:BecomingMore,项目名称:faraday,代码行数:16,代码来源:dont_run_but_update_model_controller.py
示例16: testAddNoteToHostGetsMapperDispatchSaveASYNC
def testAddNoteToHostGetsMapperDispatchSaveASYNC(self):
host = Host("pepito")
note = ModelObjectNote("a_note")
mappersManager = self.createMapperMock()
objectMapper = mock()
when(mappersManager).getMapper(note).thenReturn(objectMapper)
when(objectMapper).saveObject(note).thenReturn(True)
model_controller = controller.ModelController(mock(), mappersManager)
model_controller.addNoteToHostASYNC(host.getID(), note)
model_controller.processAllPendingActions()
verify(mappersManager).getMapper(note)
verify(objectMapper).saveObject(note)
开发者ID:BwRy,项目名称:faraday,代码行数:16,代码来源:model_controller.py
示例17: test_host_create_and_delete
def test_host_create_and_delete(self):
host = Host(name="pepito", os="linux")
self.hmapper.save(host)
h_id = host.getID()
self.assertNotEquals(
self.hmapper.load(h_id),
None,
"Host should be saved")
self.hmapper.delete(h_id)
self.assertEquals(
self.hmapper.find(h_id),
None,
"Host shouldn't exist anymore")
开发者ID:BwRy,项目名称:faraday,代码行数:16,代码来源:mapper.py
示例18: testGetHost
def testGetHost(self):
host = Host("coquito")
mappersManager = self.createMapperMock()
objectMapper = mock()
when(mappersManager).getMapper(host.__class__.__name__).thenReturn(objectMapper)
when(objectMapper).find(host.getName()).thenReturn(host)
model_controller = controller.ModelController(mock(), mappersManager)
host_obt = model_controller.getHost('coquito')
verify(objectMapper).find(host.getName())
verify(mappersManager).getMapper(host.__class__.__name__)
self.assertEqual(host, host_obt)
开发者ID:BecomingMore,项目名称:faraday,代码行数:16,代码来源:dont_run_but_update_model_controller.py
示例19: testHostWithMultipleChildTypes
def testHostWithMultipleChildTypes(self):
host = Host('coco')
inter = Interface('cuca')
vuln = ModelObjectVuln('vuln')
host.addChild(inter)
host.addChild(vuln)
self.assertEquals(len(host.getVulns()), 1, "Vulns added is not 1")
self.assertIn(vuln, host.getVulns(), "Vuln not accessible")
self.assertEquals(len(host.getAllInterfaces()), 1, "Interfaces added is not 1")
开发者ID:BecomingMore,项目名称:faraday,代码行数:10,代码来源:model_composite.py
示例20: test_service_creation
def test_service_creation(self):
name = "pepito"
os = "Windows"
host = Host(name, os)
name = ""
mac = "00:00:00:00:00:00"
ipv4_address = "0.0.0.0"
ipv4_mask = "0.0.0.0"
ipv4_gateway = "0.0.0.0"
ipv4_dns = []
ipv6_address = "0000:0000:0000:0000:0000:0000:0000:0000"
ipv6_prefix = "00"
ipv6_gateway = "0000:0000:0000:0000:0000:0000:0000:0000"
ipv6_dns = []
network_segment = ""
hostname_resolution = []
interface = Interface(
name, mac, ipv4_address, ipv4_mask, ipv4_gateway, ipv4_dns,
ipv6_address, ipv6_prefix, ipv6_gateway, ipv6_dns, network_segment,
hostname_resolution, parent_id=host.getID())
when(self._model_controller).find(
interface.getID()).thenReturn(interface)
name = "srv"
protocol = "tcp"
ports = []
status = "running"
version = "unknown"
description = ""
service_id = self.client.createService(
name, protocol, ports, status, version, description,
interface.getID())
service = Service(name, protocol, ports, status, version, description,
parent_id=interface.getID())
self.assertNotEquals(
service_id, None, "service created shouldn't be None")
self.assertEquals(
service.getID(), service_id, "ids should be the same")
开发者ID:BwRy,项目名称:faraday,代码行数:45,代码来源:integration_create_model_objects_api.py
注:本文中的model.hosts.Host类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论