class DeletePopup(ModalView):
    """
    This class contains the logic for the delete popup.
    """
    def __init__(self, button_number):
        super().__init__()
        self.popup_io = PopupIO(button_number, user_info_directory)

    def delete_info_btn(self):
        self.popup_io.delete_login()
        Menu.refresh_screen(App.get_running_app().root)
        self.dismiss()
示例#2
0
class AddPopup(ModalView):
    """
    This class contains the logic for the add popup.
    """
    def __init__(self):
        super().__init__()
        self.popup_io = PopupIO(None, user_info_directory)

    def save_input(self):
        self.popup_io.save_login(self.ids.website_input.text, self.ids.user_input.text,
                                 self.ids.password_input.text.encode())
        Menu.refresh_screen(App.get_running_app().root)
        self.dismiss()
class ModifyPopup(ModalView):
    """
    Defines the logic for the modify popup.
    """
    def __init__(self, button_number):
        super().__init__()
        self.popup_io = PopupIO(button_number, user_info_directory)
        self.load_input()

    def load_input(self):
        self.ids.website_input.text, self.ids.user_input.text, self.ids.password_input.text = self.popup_io.load_login()

    def save_input(self):
        self.popup_io.delete_login()
        self.popup_io.save_login(self.ids.website_input.text, self.ids.user_input.text,
                                 self.ids.password_input.text.encode())
        Menu.refresh_screen(App.get_running_app().root)
        self.dismiss()
示例#4
0
 def setUp(self):
     self.user_info_line_1 = {"website": "https://example.com", "username": "******", "password": "******"}
     self.user_info_line_2 = {"website": "https://github.com/login", "username": "******",
                              "password": "******"}
     self.user_info_line_3 = {"website": "website", "username": "******", "password": "******"}
     self.reload_user_info()
     self.io_1 = PopupIO(0, user_info_test_directory)
     self.io_2 = PopupIO(1, user_info_test_directory)
     self.io_3 = PopupIO(2, user_info_test_directory)
示例#5
0
    def run(self):
        """
        Automatically login to each webpage using the information from the user info file.
        :return: nothing
        """
        try:
            user_info = open(user_info_directory, "rb")
        except FileNotFoundError:
            logging.error("User info file not found")
            return
        for index, line in enumerate(user_info):
            website, username, password = PopupIO(index, user_info_directory).load_login()
            payload = {"username": username, "password": password.decode()}
            self.open_new(website, payload)

        # close first tab
        self.driver.switch_to.window(self.driver.window_handles[0])
        self.driver.close()
 def __init__(self, button_number):
     super().__init__()
     self.popup_io = PopupIO(button_number, user_info_directory)
示例#7
0
 def __init__(self):
     super().__init__()
     self.popup_io = PopupIO(None, user_info_directory)
示例#8
0
class TestPopupIO(unittest.TestCase):
    """
    Tests for the PopupIO class.
    """
    def setUp(self):
        self.user_info_line_1 = {"website": "https://example.com", "username": "******", "password": "******"}
        self.user_info_line_2 = {"website": "https://github.com/login", "username": "******",
                                 "password": "******"}
        self.user_info_line_3 = {"website": "website", "username": "******", "password": "******"}
        self.reload_user_info()
        self.io_1 = PopupIO(0, user_info_test_directory)
        self.io_2 = PopupIO(1, user_info_test_directory)
        self.io_3 = PopupIO(2, user_info_test_directory)

    def reload_user_info(self):
        self.user_info = open(user_info_test_directory, "w")
        json.dump(self.user_info_line_1, self.user_info)
        self.user_info.write("\n")
        json.dump(self.user_info_line_2, self.user_info)
        self.user_info.write("\n")
        self.user_info.close()
        self.user_info = open(user_info_test_directory, "r")

    def tearDown(self):
        self.user_info.close()
        os.remove(user_info_test_directory)

    def test_load_login_unencrypted(self):
        self.reload_user_info()
        website, username, password = self.io_1.load_login(encrypted=False)
        self.assertEqual(website, "https://example.com")
        self.assertEqual(username, "testuser")
        self.assertEqual(password, "testpass")

    def test_add_login_unencrypted(self):
        self.reload_user_info()

        self.io_3.save_login("website", "user", "pass", encrypted=False)
        self.assertEqual(json.loads(self.user_info.readline()), self.user_info_line_1)
        self.assertEqual(json.loads(self.user_info.readline()), self.user_info_line_2)
        self.assertEqual(json.loads(self.user_info.readline()), self.user_info_line_3)

    def test_add_login_encrypted(self):
        self.reload_user_info()
        self.io_3.save_login("website", "user", b"pass")
        self.user_info.readline()
        self.user_info.readline()
        user_info_pw_encrypted = json.loads(self.user_info.readline())
        self.assertEqual(user_info_pw_encrypted.get("website"), "website")
        self.assertEqual(user_info_pw_encrypted.get("username"), "user")
        self.assertNotEqual(user_info_pw_encrypted.get("password"), "pass")

    def test_add_and_load_login_encrypted(self):
        self.reload_user_info()
        self.io_3.save_login("website", "user", b"pass")
        website, username, password = self.io_3.load_login()
        self.assertEqual(password, b"pass")

    def test_delete_login(self):
        self.reload_user_info()
        self.io_2.delete_login()
        self.assertEqual(json.loads(self.user_info.readline()), self.user_info_line_1)
        self.reload_user_info()
        self.io_1.delete_login()
        self.assertEqual(json.loads(self.user_info.readline()), self.user_info_line_2)

    def test_modify_login(self):
        self.reload_user_info()
        self.io_2.delete_login()
        self.io_2.save_login("website", "user", b"pass")
        self.assertEqual(json.loads(self.user_info.readline()), self.user_info_line_1)
        login = json.loads(self.user_info.readline())
        self.assertEqual(login.get("website"), "website")
        self.assertEqual(login.get("username"), "user")
        self.assertNotEqual(login.get("password"), "pass")

    def test_modify_middle_encrypted(self):
        self.reload_user_info()
        self.io_3.save_login("website", "user", b"pass")
        self.io_2.delete_login()
        self.io_2.save_login("https://github.com/login", "fakeuser", b"fakepass")
        website, username, password = self.io_1.load_login(encrypted=False)
        self.assertEqual(password, "testpass")
        website, username, password = self.io_2.load_login()
        self.assertEqual(password, b"pass")
        website, username, password = self.io_3.load_login()
        self.assertEqual(password, b"fakepass")