Ejemplo n.º 1
0
 def test_service_serialization(self):
     srv = Service(name="http")
     srv.setDescription("Some description")
     srv.setOwned(True)
     srv.setProtocol("tcp")
     srv.setPorts(80)
     srv.setStatus("open")
     srv.setVersion("Apache 2.4")
     sserialized = self.smapper.serialize(srv)
     # if serialization fails, returns None
     self.assertNotEqual(sserialized, None,
                         "Serialized service shouldn't be None")
     # we check the service attributes
     self.assertEquals(sserialized.get("_id"), srv.getID(),
                       "Serialized ID is not the same as Service ID")
     self.assertEquals(sserialized.get("name"), srv.getName(),
                       "Serialized name is not the same as Service name")
     self.assertEquals(
         sserialized.get("protocol"), srv.getProtocol(),
         "Serialized protocol is not the same as Service protocol")
     self.assertEquals(
         sserialized.get("status"), srv.getStatus(),
         "Serialized status is not the same as Service status")
     self.assertEquals(sserialized.get("ports"), srv.getPorts(),
                       "Serialized ports is not the same as Service ports")
     self.assertEquals(
         sserialized.get("description"), srv.getDescription(),
         "Serialized description is not the same as Interface description")
     self.assertEquals(
         sserialized.get("owned"), srv.isOwned(),
         "Serialized owned flag is not the same as Interface owned flag")
Ejemplo n.º 2
0
    def testEditServiceSyncGetsMapperDispatchedASYNC(self):
        service = Service("coquito")

        params = ('new_name', 'new_desc', 'upd', 9000, 'closed', '2.1', True)
        self.genericEdit(service, params, controller.ModelController.editServiceASYNC, process_pending=True)

        self.assertEquals(service.getName(), 'new_name', "Name not updated")
        self.assertEquals(service.getDescription(), 'new_desc', "Description not updated")
        self.assertEquals(service.getProtocol(), 'upd', "Protocol not updated")
        self.assertEquals(service.isOwned(), True, "Owned status not updated")
Ejemplo n.º 3
0
    def testEditServiceSyncGetsMapperDispatchedSYNC(self):
        service = Service("coquito")

        params = ('new_name', 'new_desc', 'upd', 9000, 'closed', '2.1', True)
        self.genericEdit(service, params,
                         controller.ModelController.editServiceSYNC)

        self.assertEquals(service.getName(), 'new_name', "Name not updated")
        self.assertEquals(service.getDescription(), 'new_desc',
                          "Description not updated")
        self.assertEquals(service.getProtocol(), 'upd', "Protocol not updated")
        self.assertEquals(service.isOwned(), True, "Owned status not updated")
Ejemplo n.º 4
0
 def test_service_serialization(self):
     srv = Service(name="http")
     srv.setDescription("Some description")
     srv.setOwned(True)
     srv.setProtocol("tcp")
     srv.setPorts(80)
     srv.setStatus("open")
     srv.setVersion("Apache 2.4")
     sserialized = self.smapper.serialize(srv)
     # if serialization fails, returns None
     self.assertNotEqual(
         sserialized,
         None,
         "Serialized service shouldn't be None")
     # we check the service attributes
     self.assertEquals(
         sserialized.get("_id"),
         srv.getID(),
         "Serialized ID is not the same as Service ID")
     self.assertEquals(
         sserialized.get("name"),
         srv.getName(),
         "Serialized name is not the same as Service name")
     self.assertEquals(
         sserialized.get("protocol"),
         srv.getProtocol(),
         "Serialized protocol is not the same as Service protocol")
     self.assertEquals(
         sserialized.get("status"),
         srv.getStatus(),
         "Serialized status is not the same as Service status")
     self.assertEquals(
         sserialized.get("ports"),
         srv.getPorts(),
         "Serialized ports is not the same as Service ports")
     self.assertEquals(
         sserialized.get("description"),
         srv.getDescription(),
         "Serialized description is not the same as Interface description")
     self.assertEquals(
         sserialized.get("owned"),
         srv.isOwned(),
         "Serialized owned flag is not the same as Interface owned flag")