Exemplo n.º 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")
Exemplo n.º 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)
Exemplo n.º 3
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)
Exemplo n.º 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)
Exemplo n.º 5
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)
Exemplo n.º 6
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")
Exemplo n.º 7
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
Exemplo n.º 8
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)
Exemplo n.º 9
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)
Exemplo n.º 10
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")
Exemplo n.º 11
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)
Exemplo n.º 12
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")
Exemplo n.º 13
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)
Exemplo n.º 14
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")
Exemplo n.º 15
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)
Exemplo n.º 16
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")
Exemplo n.º 17
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)