def test_invalid_input(self): """ Tests clean_template when an invalid input is given. """ template = 4.6 with self.assertRaises(phishingpage.ArgumentIsNotAString): phishingpage.clean_template(template)
def test_invalid_template_input(self): """ Tests clean_template when an invalid template input is given. """ template = "no template" with self.assertRaises(phishingpage.TemplateNotAvailable): phishingpage.clean_template(template)
def test_template_with_some_files(self): """ Tests clean_template when a template with some files is given as an input. """ template = "linksys" dir_path = phishingpage.PHISHING_PAGES_DIR path = phishingpage.get_path(template) local_directory_names_1 = [] local_directory_names_2 = [] # download the template phishingpage.grab_online(template) # remove a file os.remove(path + "/index.html") # loop through the directory content for name in os.listdir(dir_path): # check to see if it is a file if os.path.isdir(os.path.join(dir_path, name)): # add it to the list local_directory_names_1.append(name) phishingpage.clean_template(template) # loop through the directory content for name in os.listdir(dir_path): # check to see if it is a file if os.path.isdir(os.path.join(dir_path, name)): # add it to the list local_directory_names_2.append(name) # remove the template from original list local_directory_names_1.remove(template) self.assertListEqual(local_directory_names_1, local_directory_names_2, "Failed to clean up a template!")
def test_no_directory_available(self): """ Tests clean_template when no directory is locally present for the template. """ template = "linksys" self.assertEqual(phishingpage.clean_template(template), False, "Failed to return False for non-existence directory!")
def test_no_directory_available(self): """ Tests clean_template when no directory is locally present for the template. """ template = "linksys" self.assertEqual( phishingpage.clean_template(template), False, "Failed to return False for non-existence directory!")
get_hostapd() # get dnsmasq if needed get_dnsmasq() # get template_database template_database = phishingpage.get_template_database() # check to see if the template is local if not template_database[TEMPLATE_NAME] is None: # if template is incomplete locally, delete and ask for a download if not phishingpage.check_template(TEMPLATE_NAME): # clean up the previous download phishingpage.clean_template(TEMPLATE_NAME) # get user's response response = raw_input("Template is available online. Do you want"\ " to download it now? [y/n] ") # in case the user agrees to download if response == "Y" or response == "y": # display download info to the user print "[" + G + "+" + W + "] Downloading the template..." # download the content phishingpage.grab_online(TEMPLATE_NAME) # set the path for the template TEMPLATE_PATH = phishingpage.get_path(TEMPLATE_NAME)
proc = Popen(['airmon-ng', 'check', 'kill'], stdout=PIPE, stderr=DN) # Get hostapd if needed get_hostapd() # get template_database template_database = phishingpage.get_template_database() # check to see if the template is local if not template_database[TEMPLATE_NAME] is None: # if template is incomplete locally, delete and ask for a download if not phishingpage.check_template(TEMPLATE_NAME): # clean up the previous download phishingpage.clean_template(TEMPLATE_NAME) # get user's response response = raw_input("Template is available online. Do you want"\ " to download it now? [y/n] ") # in case the user agrees to download if response == "Y" or response == "y": # display download info to the user print "[" + G + "+" + W + "] Downloading the template..." # download the content phishingpage.grab_online(TEMPLATE_NAME) # set the path for the template TEMPLATE_PATH = phishingpage.get_path(TEMPLATE_NAME)