예제 #1
0
    def testCorrectScript(self):
        self.__ensureValidGoodService()
        path = os.path.join(modulePath(), 'testservices', 'GoodService.py')
        good = ServiceTask(path, 1, "NewFlag", "0.0.0.0", None)
        good.start()

        self.assert_(good.status() == ServiceTask.OK)
        self.assert_(good.getPrevFlag() == "TestFlag")
예제 #2
0
    def testSimpleInsert(self):
        test = ServiceTaskRunner()
        test.start()

        script = modulePath() + "/testservices/HangService.py"
        task = ServiceTask(script, 2, "Flag", "10.0.0.1", None)
        test.insert(task, -1, -1)

        test.terminateOnEmpty()
        self.assert_(task.status() == ServiceTask.KILLED)
예제 #3
0
	def build(self,teamId,serviceId,round):
		team = self.conf.getTeamInfoById(teamId)
		service = self.servicebot_conf.getServiceInfoById(serviceId)
		flag = Flag(teamId,serviceId,round,time.time())

		task = ServiceTask(
				service.script,
				service.timeout,
				self.flag_manager.toTxt(flag),
				team.host,
				self.storage[teamId][serviceId],
				self.service_loggers[service.name])

		return task
예제 #4
0
    def testErrorInsert(self):
        test = ServiceTaskRunner()
        test.start()

        script = modulePath() + "/testservices/ErrorService.py"

        tasks = []
        for i in range(0, 10):
            task = ServiceTask(script, 1, "Flag", "10.0.0.1", None)
            tasks.append(task)
            test.insert(task, -1, -1)
        test.terminateOnEmpty()

        for task in tasks:
            self.assert_(task.status() == ServiceTask.ERROR)
예제 #5
0
 def testPastTimeout(self):
     path = os.path.join(modulePath(), 'testservices', 'GoodService.py')
     good = ServiceTask(path, 1, "NewFlag", "0.0.0.0", None)
     good.start()
     time.sleep(2)
     self.assert_(good.status() == ServiceTask.OK)
예제 #6
0
 def testStoreScript(self):
     path = os.path.join(modulePath(), 'testservices', 'StoreService.py')
     store = ServiceTask(path, 0.5, "NewFlag", "0.0.0.0", None)
     store.start()
     self.assert_(store.status() == ServiceTask.INVALID_FLAG)
     self.assert_(store.store() == "Store Text")
예제 #7
0
 def testHangScript(self):
     path = os.path.join(modulePath(), 'testservices', 'HangService.py')
     hang = ServiceTask(path, 1, "NewFlag", "0.0.0.0", None)
     hang.start()
     self.assert_(hang.status() == ServiceTask.KILLED)
예제 #8
0
 def testErrorScript(self):
     path = os.path.join(modulePath(), 'testservices', 'ErrorService.py')
     err = ServiceTask(path, 1, "NewFlag", "0.0.0.0", None)
     err.start()
     self.assert_(err.status() == ServiceTask.ERROR)
     self.assert_(err.error() == "An Error")
예제 #9
0
 def testBrokenScript(self):
     path = os.path.join(modulePath(), 'testservices', 'BrokenService.py')
     err = ServiceTask(path, 2, "NewFlag", "0.0.0.0", None)
     err.start()
     self.assert_(err.status() == ServiceTask.INVALID_FLAG)