mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-06-27 17:08:32 +00:00
fix tests
This commit is contained in:
parent
b73145ebde
commit
fa76f8a286
@ -11,6 +11,7 @@
|
|||||||
_LinuxDesktopEnvironment,
|
_LinuxDesktopEnvironment,
|
||||||
parse_safari_cookies,
|
parse_safari_cookies,
|
||||||
pbkdf2_sha1,
|
pbkdf2_sha1,
|
||||||
|
_get_chromium_based_browser_settings,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -92,24 +93,27 @@ def test_chrome_cookie_decryptor_mac_derive_key(self):
|
|||||||
self.assertEqual(key, b'Y\xe2\xc0\xd0P\xf6\xf4\xe1l\xc1\x8cQ\xcb|\xcdY')
|
self.assertEqual(key, b'Y\xe2\xc0\xd0P\xf6\xf4\xe1l\xc1\x8cQ\xcb|\xcdY')
|
||||||
|
|
||||||
def test_chrome_cookie_decryptor_linux_v10(self):
|
def test_chrome_cookie_decryptor_linux_v10(self):
|
||||||
|
config = _get_chromium_based_browser_settings('chrome')
|
||||||
with MonkeyPatch(cookies, {'_get_linux_keyring_password': lambda *args, **kwargs: b''}):
|
with MonkeyPatch(cookies, {'_get_linux_keyring_password': lambda *args, **kwargs: b''}):
|
||||||
encrypted_value = b'v10\xccW%\xcd\xe6\xe6\x9fM" \xa7\xb0\xca\xe4\x07\xd6'
|
encrypted_value = b'v10\xccW%\xcd\xe6\xe6\x9fM" \xa7\xb0\xca\xe4\x07\xd6'
|
||||||
value = 'USD'
|
value = 'USD'
|
||||||
decryptor = LinuxChromeCookieDecryptor('Chrome', Logger())
|
decryptor = LinuxChromeCookieDecryptor(config, 'Chrome', Logger())
|
||||||
self.assertEqual(decryptor.decrypt(encrypted_value), value)
|
self.assertEqual(decryptor.decrypt(encrypted_value), value)
|
||||||
|
|
||||||
def test_chrome_cookie_decryptor_linux_v11(self):
|
def test_chrome_cookie_decryptor_linux_v11(self):
|
||||||
|
config = _get_chromium_based_browser_settings('chrome')
|
||||||
with MonkeyPatch(cookies, {'_get_linux_keyring_password': lambda *args, **kwargs: b''}):
|
with MonkeyPatch(cookies, {'_get_linux_keyring_password': lambda *args, **kwargs: b''}):
|
||||||
encrypted_value = b'v11#\x81\x10>`w\x8f)\xc0\xb2\xc1\r\xf4\x1al\xdd\x93\xfd\xf8\xf8N\xf2\xa9\x83\xf1\xe9o\x0elVQd'
|
encrypted_value = b'v11#\x81\x10>`w\x8f)\xc0\xb2\xc1\r\xf4\x1al\xdd\x93\xfd\xf8\xf8N\xf2\xa9\x83\xf1\xe9o\x0elVQd'
|
||||||
value = 'tz=Europe.London'
|
value = 'tz=Europe.London'
|
||||||
decryptor = LinuxChromeCookieDecryptor('Chrome', Logger())
|
decryptor = LinuxChromeCookieDecryptor(config, 'Chrome', Logger())
|
||||||
self.assertEqual(decryptor.decrypt(encrypted_value), value)
|
self.assertEqual(decryptor.decrypt(encrypted_value), value)
|
||||||
|
|
||||||
def test_chrome_cookie_decryptor_linux_v10_meta24(self):
|
def test_chrome_cookie_decryptor_linux_v10_meta24(self):
|
||||||
|
config = _get_chromium_based_browser_settings('chrome')
|
||||||
with MonkeyPatch(cookies, {'_get_linux_keyring_password': lambda *args, **kwargs: b''}):
|
with MonkeyPatch(cookies, {'_get_linux_keyring_password': lambda *args, **kwargs: b''}):
|
||||||
encrypted_value = b'v10\x1f\xe4\x0e[\x83\x0c\xcc*kPi \xce\x8d\x1d\xbb\x80\r\x11\t\xbb\x9e^Hy\x94\xf4\x963\x9f\x82\xba\xfe\xa1\xed\xb9\xf1)\x00710\x92\xc8/<\x96B'
|
encrypted_value = b'v10\x1f\xe4\x0e[\x83\x0c\xcc*kPi \xce\x8d\x1d\xbb\x80\r\x11\t\xbb\x9e^Hy\x94\xf4\x963\x9f\x82\xba\xfe\xa1\xed\xb9\xf1)\x00710\x92\xc8/<\x96B'
|
||||||
value = 'DE'
|
value = 'DE'
|
||||||
decryptor = LinuxChromeCookieDecryptor('Chrome', Logger(), meta_version=24)
|
decryptor = LinuxChromeCookieDecryptor(config, 'Chrome', Logger(), meta_version=24)
|
||||||
self.assertEqual(decryptor.decrypt(encrypted_value), value)
|
self.assertEqual(decryptor.decrypt(encrypted_value), value)
|
||||||
|
|
||||||
def test_chrome_cookie_decryptor_windows_v10(self):
|
def test_chrome_cookie_decryptor_windows_v10(self):
|
||||||
|
@ -195,10 +195,12 @@ def _extract_firefox_cookies(browser_name, profile, container, logger):
|
|||||||
if cursor is not None:
|
if cursor is not None:
|
||||||
cursor.connection.close()
|
cursor.connection.close()
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class _FirefoxBrowserSettings:
|
class _FirefoxBrowserSettings:
|
||||||
browser_dirs: list[str]
|
browser_dirs: list[str]
|
||||||
|
|
||||||
|
|
||||||
def _firefox_based_browser_settings(browser_name):
|
def _firefox_based_browser_settings(browser_name):
|
||||||
if sys.platform in ('cygwin', 'win32'):
|
if sys.platform in ('cygwin', 'win32'):
|
||||||
appdata = os.path.expandvars(R'%APPDATA%')
|
appdata = os.path.expandvars(R'%APPDATA%')
|
||||||
@ -242,6 +244,7 @@ def _firefox_based_browser_settings(browser_name):
|
|||||||
browser_dirs=browser_dirs,
|
browser_dirs=browser_dirs,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _firefox_cookie_dbs(roots):
|
def _firefox_cookie_dbs(roots):
|
||||||
for root in map(os.path.abspath, roots):
|
for root in map(os.path.abspath, roots):
|
||||||
for pattern in ('', '*/', 'Profiles/*/'):
|
for pattern in ('', '*/', 'Profiles/*/'):
|
||||||
|
Loading…
Reference in New Issue
Block a user