[feat] user assets (#3504)
This commit is contained in:
parent
c89721223f
commit
39c33699af
28 changed files with 1125 additions and 309 deletions
|
|
@ -1,42 +0,0 @@
|
|||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from lnbits.helpers import safe_upload_file_path
|
||||
from lnbits.settings import settings
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"filepath",
|
||||
[
|
||||
"test.txt",
|
||||
"test/test.txt",
|
||||
"test/test/test.txt",
|
||||
"test/../test.txt",
|
||||
"*/test.txt",
|
||||
"test/**/test.txt",
|
||||
"./test.txt",
|
||||
],
|
||||
)
|
||||
def test_safe_upload_file_path(filepath: str):
|
||||
safe_path = safe_upload_file_path(filepath)
|
||||
assert safe_path.name == "test.txt"
|
||||
|
||||
# check if subdirectories got removed
|
||||
images_folder = Path(settings.lnbits_data_folder) / "images"
|
||||
assert images_folder.resolve() / "test.txt" == safe_path
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"filepath",
|
||||
[
|
||||
"../test.txt",
|
||||
"test/../../test.txt",
|
||||
"../../test.txt",
|
||||
"test/../../../test.txt",
|
||||
"../../../test.txt",
|
||||
],
|
||||
)
|
||||
def test_unsafe_upload_file_path(filepath: str):
|
||||
with pytest.raises(ValueError):
|
||||
safe_upload_file_path(filepath)
|
||||
Loading…
Add table
Add a link
Reference in a new issue