Skip to content

Commit

Permalink
test: download key in unlock test
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanljones committed Feb 11, 2025
1 parent 6a6d296 commit 31df6f9
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion tests/test_db6.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
# Date: 2023-02-01

import os
import re
import shutil
import tempfile
import urllib.request
from pathlib import Path

import pytest
Expand Down Expand Up @@ -36,6 +38,40 @@
# Playlist ID
PID1 = 2602250856 # Trial playlist - Cloud Library Sync

KEY_SOURCES = [
{
"url": r"https://raw.githubusercontent.com/mganss/CueGen/19878e6eb3f586dee0eb3eb4f2ce3ef18309de9d/CueGen/Generator.cs", # noqa: E501
"regex": re.compile(
r'((.|\n)*)Config\.UseSqlCipher.*\?.*"(?P<dp>.*)".*:.*null',
flags=re.IGNORECASE | re.MULTILINE,
),
},
{
"url": r"https://raw.githubusercontent.com/dvcrn/go-rekordbox/8be6191ba198ed7abd4ad6406d177ed7b4f749b5/cmd/getencryptionkey/main.go", # noqa: E501
"regex": re.compile(
r'((.|\n)*)fmt\.Print\("(?P<dp>.*)"\)', flags=re.IGNORECASE | re.MULTILINE
),
},
]


def download_db6_key():
dp = ""
for source in KEY_SOURCES:
url = source["url"]
regex = source["regex"]

res = urllib.request.urlopen(url)
data = res.read().decode("utf-8")
match = regex.match(data)
if match:
dp = match.group("dp")
break
if dp:
return dp
else:
raise Exception("No key found in the online sources.")


@pytest.fixture
def db():
Expand All @@ -54,7 +90,8 @@ def test_open_rekordbox_database():


def test_unlock_rekordbox_database():
con = open_rekordbox_database(LOCKED, unlock=True)
dp = download_db6_key()
con = open_rekordbox_database(LOCKED, key=dp, unlock=True)
con.execute("SELECT name FROM sqlite_master WHERE type='table';")
con.close()

Expand Down

0 comments on commit 31df6f9

Please sign in to comment.