class BlacklistManagerTest(TestCase): fixtures = ['blacklistDB.json'] def testBlacklistManagerCheckWithMaliciousURL(self): self.bm = BlacklistManager("http://nigooglekbgo.xyz/uk/google22/5230/") self.result = self.bm.check() self.assertIsInstance(self.result, BlacklistResult) self.assertEqual(self.result.maliciousType, "SOCIAL_ENGINEERING") def testBlacklistManagerCheckWithSafeURL(self): self.bm = BlacklistManager("http://google.com") self.result = self.bm.check() self.assertIsInstance(self.result, BlacklistResult) self.assertEqual(self.result.maliciousType, "safe URL") def testCacheCheck(self): self.bm = BlacklistManager("http://google.com") self.bm.check() self.result = self.bm.checkCache() self.assertEqual(self.result, "safe URL") def testDBCheckWithExistedURL(self): self.bm = BlacklistManager("http://nigooglekbgo.xyz/uk/google22/5230/") self.result = self.bm.checkDB() self.assertEqual(self.result, "SOCIAL_ENGINEERING") def testDBCheckWithUnexistedURL(self): self.bm = BlacklistManager("http://google.com") self.result = self.bm.checkDB() self.assertEqual(self.result, "") def testThirdPartyCheck(self): self.bm = BlacklistManager("http://nigooglekbgo.xyz/uk/google22/5230/") self.result = self.bm.checkThirdParty() self.assertEqual(self.result, "SOCIAL_ENGINEERING") def testThirdPartyCheckError(self): self.bm = BlacklistManager("http://google.com") self.result = self.bm.checkThirdParty() self.assertEqual(self.result, "")
def urlProcess(self, url): bs = BrowserSimulator(url) sc = SourceCodeHandler(url) bl = BlacklistManager(url) bsResult = MyThread(target=bs.simulateManager) scResult = MyThread(target=sc.call) blResult = MyThread(target=bl.check) bsResult.start() scResult.start() blResult.start() #print(bsResult.get_result()) #print(scResult.get_result()) self.result.SourceCodeHandler = scResult.get_result() self.result.BrowserSimulator = bsResult.get_result() self.result.BlacklistManager = blResult.get_result() #print(self.result.BlacklistManager.maliciousType) #print(self.result.SourceCodeHandler.isMining) #print(self.result.SourceCodeHandler.miningType) #print(self.result.SourceCodeHandler.hasAutoDownload) #print(self.result.SourceCodeHandler.hasPopUp) #print(self.result.BrowserSimulator.usage.mem) #print(self.result.BrowserSimulator.viewfilename) return self.result
def testBlacklistManagerCheckWithMaliciousURL(self): self.bm = BlacklistManager("http://nigooglekbgo.xyz/uk/google22/5230/") self.result = self.bm.check() self.assertIsInstance(self.result, BlacklistResult) self.assertEqual(self.result.maliciousType, "SOCIAL_ENGINEERING")
def testThirdPartyCheckError(self): self.bm = BlacklistManager("http://google.com") self.result = self.bm.checkThirdParty() self.assertEqual(self.result, "")
def testThirdPartyCheck(self): self.bm = BlacklistManager("http://nigooglekbgo.xyz/uk/google22/5230/") self.result = self.bm.checkThirdParty() self.assertEqual(self.result, "SOCIAL_ENGINEERING")
def testDBCheckWithUnexistedURL(self): self.bm = BlacklistManager("http://google.com") self.result = self.bm.checkDB() self.assertEqual(self.result, "")
def testDBCheckWithExistedURL(self): self.bm = BlacklistManager("http://nigooglekbgo.xyz/uk/google22/5230/") self.result = self.bm.checkDB() self.assertEqual(self.result, "SOCIAL_ENGINEERING")
def testCacheCheck(self): self.bm = BlacklistManager("http://google.com") self.bm.check() self.result = self.bm.checkCache() self.assertEqual(self.result, "safe URL")
def testBlacklistManagerCheckWithSafeURL(self): self.bm = BlacklistManager("http://google.com") self.result = self.bm.check() self.assertIsInstance(self.result, BlacklistResult) self.assertEqual(self.result.maliciousType, "safe URL")