mirror of
https://github.com/unode/firefox_decrypt.git
synced 2025-12-16 12:01:52 +01:00
83 lines
2.8 KiB
Python
Executable File
83 lines
2.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
|
||
import os
|
||
import unittest
|
||
from simpletap.fdecrypt import lib
|
||
|
||
|
||
class TestDirectProfilePass(unittest.TestCase):
|
||
def validate_one(self, userkey, grepkey, output):
|
||
expected = lib.get_user_data(userkey)
|
||
matches = lib.grep(grepkey, output, context=1)
|
||
|
||
self.assertEqual(matches, expected)
|
||
|
||
def validate(self, out):
|
||
self.validate_one("doesntexist", "doesntexist", out)
|
||
self.validate_one("onemore", "onemore", out)
|
||
self.validate_one("complex", "cömplex", out)
|
||
self.validate_one("jamie", "jãmïe", out)
|
||
|
||
def run_firefox_with_password(self):
|
||
cmd = lib.get_script() + [self.test]
|
||
pwd = lib.get_password()
|
||
|
||
output = lib.run(cmd, stdin=pwd)
|
||
self.validate(output)
|
||
|
||
def run_firefox_nopassword(self):
|
||
# Must run in non-interactive mode or password prompt will be shown
|
||
cmd = lib.get_script() + [self.test, "-n"]
|
||
|
||
output = lib.run(cmd)
|
||
self.validate(output)
|
||
|
||
@unittest.skipIf(lib.platform == "Windows",
|
||
"Windows DLL isn't backwards compatible")
|
||
def test_firefox_20(self):
|
||
self.test = os.path.join(lib.get_test_data(),
|
||
"test_profile_firefox_20")
|
||
self.run_firefox_with_password()
|
||
|
||
@unittest.skipIf(lib.platform == "Windows",
|
||
"Windows DLL isn't backwards compatible")
|
||
def test_firefox_46(self):
|
||
self.test = os.path.join(lib.get_test_data(),
|
||
"test_profile_firefox_46")
|
||
self.run_firefox_with_password()
|
||
|
||
def test_firefox_59(self):
|
||
self.test = os.path.join(lib.get_test_data(),
|
||
"test_profile_firefox_59")
|
||
self.run_firefox_with_password()
|
||
|
||
def test_firefox_144(self):
|
||
self.test = os.path.join(lib.get_test_data(),
|
||
"test_profile_firefox_144")
|
||
self.run_firefox_with_password()
|
||
|
||
def test_firefox_non_ascii(self):
|
||
self.test = os.path.join(lib.get_test_data(),
|
||
"test_profile_firefox_LЮшр/")
|
||
self.run_firefox_with_password()
|
||
|
||
@unittest.skipIf(lib.platform == "Windows",
|
||
"Windows DLL isn't backwards compatible")
|
||
def test_firefox_nopass_46(self):
|
||
self.test = os.path.join(lib.get_test_data(),
|
||
"test_profile_firefox_nopassword_46")
|
||
self.run_firefox_nopassword()
|
||
|
||
def test_firefox_nopass_59(self):
|
||
self.test = os.path.join(lib.get_test_data(),
|
||
"test_profile_firefox_nopassword_59")
|
||
self.run_firefox_nopassword()
|
||
|
||
|
||
if __name__ == "__main__":
|
||
from simpletap import TAPTestRunner
|
||
unittest.main(testRunner=TAPTestRunner(buffer=True), exit=False)
|
||
|
||
# vim: ai sts=4 et sw=4
|