chore: extract nextcloud password from source files
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -43,4 +43,5 @@ helpers-results
|
||||
/.mypy_cache/
|
||||
.coverage
|
||||
.mypy_cache
|
||||
test/tmp
|
||||
test/tmp
|
||||
test/nextcloud_pwd.mdp
|
||||
@@ -10,9 +10,12 @@ import unittest
|
||||
from os import chdir, path as os_path
|
||||
from pathlib import Path
|
||||
import pprint
|
||||
import os
|
||||
import glob
|
||||
from io import StringIO
|
||||
from contextlib import redirect_stdout, redirect_stderr
|
||||
import shutil
|
||||
import json
|
||||
from contexttimer import Timer
|
||||
|
||||
print(__name__)
|
||||
@@ -32,7 +35,28 @@ class TestDabDataSync(unittest.TestCase):
|
||||
shutil.rmtree(testdir_path / "test_data2", ignore_errors=True)
|
||||
shutil.copytree(testdir_path / "test_data_origin", testdir_path / "test_data")
|
||||
shutil.copytree(testdir_path / "test_data_origin", testdir_path / "test_data2")
|
||||
|
||||
|
||||
nextcloud_pwd=""
|
||||
if 'nextcloud_pwd' in os.environ:
|
||||
nextcloud_pwd = os.environ.get("nextcloud_pwd")
|
||||
elif os.path.isfile(testdir_path / "nextcloud_pwd.mdp"):
|
||||
with open(testdir_path / "nextcloud_pwd.mdp","rt",encoding="utf-8") as pwd_file:
|
||||
nextcloud_pwd=pwd_file.read()
|
||||
else:
|
||||
raise RuntimeError("NextCloud pwd file not found")
|
||||
files = glob.glob(str(testdir_path / "test_data" / "*.json"))
|
||||
files += glob.glob(str(testdir_path / "test_data2" / "*.json"))
|
||||
for file in files:
|
||||
with open(file) as f:
|
||||
data = json.load(f)
|
||||
try:
|
||||
data["Args"]["FSSync_NextCloud_Password"]["value"] = nextcloud_pwd
|
||||
except Exception as exc:
|
||||
print(f"ignoring exception: {exc}")
|
||||
os.remove(file)
|
||||
with open(file, 'w') as f:
|
||||
json.dump(data, f)
|
||||
|
||||
def tearDown(self) -> None:
|
||||
shutil.rmtree(testdir_path / "test_data", ignore_errors=True)
|
||||
shutil.rmtree(testdir_path / "test_data2", ignore_errors=True)
|
||||
|
||||
@@ -254,7 +254,7 @@
|
||||
},
|
||||
"FSSync_NextCloud_Password": {
|
||||
"type": "STRING",
|
||||
"value": "F3P8m-nQHik-NSmb2-mnFEF-s85RE"
|
||||
"value": ""
|
||||
},
|
||||
"FSSync_NextCloud_Path": {
|
||||
"type": "STRING",
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
"FSSync_NextCloud_Enabled": {"type": "BOOL", "value": false},
|
||||
"FSSync_NextCloud_Address": {"type": "URL", "value": "https://chacha.ddns.net/nextcloud"},
|
||||
"FSSync_NextCloud_User": {"type": "STRING", "value": "chacha-bot"},
|
||||
"FSSync_NextCloud_Password": {"type": "STRING", "value": "F3P8m-nQHik-NSmb2-mnFEF-s85RE"},
|
||||
"FSSync_NextCloud_Password": {"type": "STRING", "value": ""},
|
||||
"FSSync_NextCloud_Path": {"type": "STRING", "value": "pydabfactory"}
|
||||
}}
|
||||
Reference in New Issue
Block a user