From 9b551240b456d4cd6c49263919f4e6beed0d1a78 Mon Sep 17 00:00:00 2001 From: malken21 Date: Sun, 8 Nov 2026 00:28:26 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=97=E3=83=A9=E3=82=B0=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E3=82=92=20lock=20=E9=A7=86=E5=8B=95?= =?UTF-8?q?=E3=81=AB=E5=86=8D=E8=A8=AD=E8=A8=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 旧方式 (最新版を無検証で上書き) を廃止し、TORO-Proxy の plugin-pins と同じ型にする: plugins.lock.json に版と配布元の公開ハッシュを固定し、check (三者照合) / update (PR で上げる) / fetch (staging へ取りそろえ) を提供する。配布元は Modrinth 17件と GitHub 4件が自動対象、toro-plugin-compat の5件は compat、検証可能な配布元が無いものと内製の37件は manual として自動処理から外す。初期 lock は plugin-provenance 監査 (2026-11-06) の実測を種に実 API と実ダウンロードで照合して生成した。Velocity は TORO-Proxy の lock が担うため対象外。SignedVelocity-Paper は撤去決定済みのため収載しない。 --- .github/workflows/ci.yml | 36 +++ .github/workflows/plugin-lock.yml | 66 +++++ README.md | 52 ++++ auto_update_plugins.py | 316 +++++++++++++++++++++ plugins.lock.json | 439 ++++++++++++++++++++++++++++++ tests/test_auto_update_plugins.py | 157 +++++++++++ 6 files changed, 1066 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/plugin-lock.yml create mode 100644 auto_update_plugins.py create mode 100644 plugins.lock.json create mode 100644 tests/test_auto_update_plugins.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8a1d1bf --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,36 @@ +name: ci + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + - uses: actions/setup-python@v6 + with: + python-version: '3.12' + - name: 単体テスト + run: python3 -m unittest discover -s tests -v + - name: lock の形を確かめる + run: | + python3 - << 'PYEOF' + import json, pathlib + lock = json.loads(pathlib.Path('plugins.lock.json').read_text(encoding='utf-8')) + assert lock, 'lock が空です' + for name, e in lock.items(): + assert e['source'].split(':')[0] in ('modrinth', 'github', 'compat', 'manual'), (name, e['source']) + assert e['version'] and e['file'], name + if e['source'].startswith(('modrinth:', 'github:')): + assert e['url'].startswith('https://'), name + assert len(e['sha256']) == 64, name + print(f"{len(lock)} 件のエントリの形が正しい") + PYEOF diff --git a/.github/workflows/plugin-lock.yml b/.github/workflows/plugin-lock.yml new file mode 100644 index 0000000..25568de --- /dev/null +++ b/.github/workflows/plugin-lock.yml @@ -0,0 +1,66 @@ +name: plugin-lock + +# plugins.lock.json の確かめと更新。TORO-Proxy の plugin-pins と同じ型。 +# プルリクエストでは、固定した版を配布元の公開ハッシュと比べる。 +# 週に1度 (と手動で) 新しいリリースを調べて PR を作る。 + +on: + schedule: + - cron: '31 19 * * 2' + workflow_dispatch: + pull_request: + paths: + - 'plugins.lock.json' + - 'auto_update_plugins.py' + - '.github/workflows/plugin-lock.yml' + +permissions: + contents: read + +concurrency: + group: plugin-lock-${{ github.ref }} + cancel-in-progress: true + +jobs: + check: + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + - name: 固定した版を確かめる + env: + GH_TOKEN: ${{ github.token }} + run: python3 auto_update_plugins.py check + + update: + if: github.event_name != 'pull_request' + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v7 + - name: 新しいリリースを調べる + env: + GH_TOKEN: ${{ github.token }} + run: python3 auto_update_plugins.py update + - name: 変わっていれば PR を作る + env: + GH_TOKEN: ${{ github.token }} + run: | + if git diff --quiet -- plugins.lock.json; then + echo '更新はありません' + exit 0 + fi + branch="aup/update-$(date +%Y%m%d)" + git config user.name 'github-actions[bot]' + git config user.email 'github-actions[bot]@users.noreply.github.com' + git checkout -b "$branch" + git add plugins.lock.json + git commit -m 'プラグインの固定を最新リリースへ上げる' + git push -u origin "$branch" + gh pr create --title 'プラグインの固定を最新リリースへ上げる' \ + --body 'auto_update_plugins.py update の自動生成。check が配布元の公開ハッシュと実ダウンロードの一致を確かめてからマージすること。' \ + --base main --head "$branch" diff --git a/README.md b/README.md index dead6a3..7e7619b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,54 @@ # AutoUpdatePlugins +toro-main (Paper) のプラグインを、版を固定して配布元の公開ハッシュで確かめながらそろえるためのツール。 +旧実装 (dev ブランチにあった、最新版を無検証で上書きする方式) は廃止し、TORO-Proxy の +plugin-pins と同じ lock 駆動の設計に作り替えた。 + +## 設計 + +- `plugins.lock.json` が正本。プラグインごとに配布元・版・ファイル名・URL・ハッシュを持つ。 +- `auto_update_plugins.py` は標準ライブラリだけの Python で、サブコマンドは3つ。 + - `check`: 固定した版について、配布元が現在公開している情報と、実際にダウンロードした + もののハッシュを、lock と照合する。 + - `update`: 配布元の最新リリースを解決し、ダウンロードして公開ハッシュと一致することを + 確かめてから lock を書き換える。上げるかどうかは PR のレビューで決める。 + - `fetch `: lock の版をディレクトリへ取りそろえる。既にある jar はハッシュが合えば + 取り直さず、版上げで旧くなった jar は glob に合うものを除く。本番の plugins へ直接 + 書く用途ではなく、staging へそろえて運用の段階適用で配置する。 +- 配布元 (`source`) は4種。 + - `modrinth:`: Modrinth。版は loader が Paper 系の release から選ぶ。公開ハッシュは + ファイルの sha512。環境変数 `AUP_GAME_VERSION` があればゲーム版でも絞る。 + - `github:`: GitHub Releases。アセットは glob で選ぶ。公開ハッシュはアセットの + digest (sha256)。古いアセットには digest が無いものがあり、その場合は取ったものの + sha256 を lock として照合する。 + - `compat`: toro-plugin-compat のパッチ済みビルド (CoreProtect、Shopkeepers、EssentialsX、 + MyPet、Vehicles)。上流の自動更新で上書きしてはいけないため自動処理から外す。 + - `manual`: 検証できる公開ハッシュを持つ配布元が無いもの (スナップショット、閉源、公式 + サイト配布) と内製プラグイン。自動処理から外し、理由を note に書く。 +- Velocity のプラグインは TORO-Proxy の `ops/both-service/plugins.lock.json` が担うため、 + ここには入れない。 +- SignedVelocity-Paper は本番からの撤去が決まっているため収載していない + (撤去はゲーム設定 Critical 対応の段階適用で行う)。 + +## lock の初期値について + +初期の版とハッシュは、本番の全 jar の出所を実測した plugin-provenance 監査 (2026-11-06) の +結果を種にし、Modrinth と GitHub の実 API で解決して実ダウンロードと照合して埋めた。 +自動対象は Modrinth 17件と GitHub 4件、compat 5件、manual 37件の計63件 +(本番の64本から SignedVelocity-Paper を除いた数と一致する)。 + +## CI + +- `ci.yml`: 単体テスト (ネットワークなし) と lock の形の検証。 +- `plugin-lock.yml`: lock に触れる PR では `check` を実行。週1回と手動では `update` を + 実行し、差分があれば PR を作る。 + +## 使い方 + +``` +python3 auto_update_plugins.py check +python3 auto_update_plugins.py update +python3 auto_update_plugins.py fetch /path/to/staging +``` + +GitHub API の回数制限を避ける場合は環境変数 `GH_TOKEN` を設定する。 diff --git a/auto_update_plugins.py b/auto_update_plugins.py new file mode 100644 index 0000000..3ab65bd --- /dev/null +++ b/auto_update_plugins.py @@ -0,0 +1,316 @@ +#!/usr/bin/env python3 +"""toro-main (Paper) のプラグインの固定を確かめる・上げる・取りそろえる (標準ライブラリだけ)。 + +使い方: + python3 auto_update_plugins.py check 固定した版を配布元の公開ハッシュと比べ、取ったものとも比べる + python3 auto_update_plugins.py update 配布元の最新のリリースに lock を書き換える (上げるのは PR で) + python3 auto_update_plugins.py fetch 固定した版を へ取りそろえる (本番への配置は運用の段階適用で行う) + +設計: + plugins.lock.json が正本。エントリの source は modrinth:、github:、 + compat、manual の4種。compat は toro-plugin-compat のパッチ済みビルドで、上流の自動更新で + 上書きしてはいけない。manual は検証できる公開ハッシュを持つ配布元が無いものと内製で、 + check / update / fetch の自動処理から外す。Velocity のプラグインは TORO-Proxy の + ops/both-service/plugins.lock.json が担うため、ここには入れない。 + +公開ハッシュ: Modrinth はファイルの sha512、GitHub はアセットの digest (sha256)。 +GitHub の古いアセットには digest が無いものがあり、その場合は update のときに取ったものの +sha256 を lock とし、check では取ったものと lock の照合だけを行う (NG にはしない)。 +環境変数 GH_TOKEN があれば GitHub API の回数制限に使う。AUP_GAME_VERSION を指定すると +Modrinth の版をそのゲーム版に絞る。 +""" +import fnmatch +import hashlib +import json +import os +import pathlib +import re +import sys +import urllib.request + +LOCK = pathlib.Path(__file__).resolve().parent / "plugins.lock.json" +MODRINTH_API = "https://api.modrinth.com/v2" +GITHUB_API = "https://api.github.com/repos" +USER_AGENT = "TORO-AutoUpdatePlugins/1.0 (+https://github.com/TORO-Server/AutoUpdatePlugins)" +TIMEOUT_SECONDS = 120 +SHA256 = re.compile(r"^[0-9a-f]{64}$") +SHA512 = re.compile(r"^[0-9a-f]{128}$") +PAPER_LOADERS = {"paper", "bukkit", "spigot", "purpur"} + + +def api_json(url): + headers = {"User-Agent": USER_AGENT, "Accept": "application/json"} + token = os.environ.get("GH_TOKEN", "") + if token and url.startswith(GITHUB_API): + headers["Authorization"] = f"Bearer {token}" + req = urllib.request.Request(url, headers=headers) + with urllib.request.urlopen(req, timeout=TIMEOUT_SECONDS) as res: + return json.load(res) + + +def _open(url): + req = urllib.request.Request(url, headers={"User-Agent": USER_AGENT}) + return urllib.request.urlopen(req, timeout=TIMEOUT_SECONDS) + + +def download_hashes(url): + """(sha256, sha512) を返す。CDN の一時的な切断に備えて最大3回まで取り直す。""" + last = None + for _ in range(3): + sha256 = hashlib.sha256() + sha512 = hashlib.sha512() + try: + with _open(url) as res: + for chunk in iter(lambda: res.read(1024 * 1024), b""): + sha256.update(chunk) + sha512.update(chunk) + return sha256.hexdigest(), sha512.hexdigest() + except Exception as e: # 切断時は途中までのハッシュを捨てて最初から取り直す + last = e + raise last + + +def download_to(url, dest): + tmp = dest.with_suffix(dest.suffix + ".part") + last = None + for _ in range(3): + try: + with _open(url) as res, open(tmp, "wb") as f: + for chunk in iter(lambda: res.read(1024 * 1024), b""): + f.write(chunk) + os.replace(tmp, dest) + return + except Exception as e: + last = e + tmp.unlink(missing_ok=True) + raise last + + +def file_sha256(path): + digest = hashlib.sha256() + with open(path, "rb") as f: + for chunk in iter(lambda: f.read(1024 * 1024), b""): + digest.update(chunk) + return digest.hexdigest() + + +def is_auto(entry): + return entry["source"].startswith(("modrinth:", "github:")) + + +# --- Modrinth --- + +def modrinth_pick_file(version_data, glob): + files = version_data.get("files", []) + matched = [f for f in files if fnmatch.fnmatch(f["filename"], glob)] + if not matched: + return None + for f in matched: + if f.get("primary"): + return f + return matched[0] + + +def modrinth_select(versions, entry, latest): + """entry の条件に合う版を1つ選ぶ。latest なら release で loader が Paper 系のうち最新。""" + game_version = os.environ.get("AUP_GAME_VERSION", "") + candidates = [] + for v in versions: + if latest: + if v.get("version_type") != "release": + continue + if not PAPER_LOADERS.intersection(v.get("loaders", [])): + continue + if game_version and game_version not in v.get("game_versions", []): + continue + else: + if v.get("version_number") != entry["version"]: + continue + f = modrinth_pick_file(v, entry["glob"]) + if f is None: + continue + candidates.append((v, f)) + if not candidates: + return None + if latest: + candidates.sort(key=lambda vf: vf[0].get("date_published", ""), reverse=True) + v, f = candidates[0] + return { + "version": v["version_number"], + "file": f["filename"], + "url": f["url"], + "sha512": f["hashes"]["sha512"], + } + + +def modrinth_resolve(entry, latest): + slug = entry["source"].partition(":")[2] + versions = api_json(f"{MODRINTH_API}/project/{slug}/version") + got = modrinth_select(versions, entry, latest) + if got is None: + raise ValueError(f"{entry['source']}: 条件に合う版が Modrinth にありません") + return got + + +# --- GitHub --- + +def github_pick_asset(release, glob): + matched = [a for a in release.get("assets", []) if fnmatch.fnmatch(a["name"], glob)] + return matched[0] if matched else None + + +def github_normalize(release, entry): + asset = github_pick_asset(release, entry["glob"]) + if asset is None: + raise ValueError(f"{entry['source']} {release.get('tag_name')}: {entry['glob']} に合うアセットがありません") + got = { + "version": release["tag_name"], + "file": asset["name"], + "url": asset["browser_download_url"], + } + digest = str(asset.get("digest") or "") + if digest.startswith("sha256:"): + got["sha256_published"] = digest.removeprefix("sha256:") + return got + + +def github_resolve(entry, latest): + repo = entry["source"].partition(":")[2] + if latest: + release = api_json(f"{GITHUB_API}/{repo}/releases/latest") + if release.get("prerelease") or release.get("draft"): + raise ValueError(f"{entry['source']}: 最新がリリース版ではありません") + return github_normalize(release, entry) + releases = api_json(f"{GITHUB_API}/{repo}/releases?per_page=100") + for release in releases: + if release.get("tag_name") == entry["version"]: + return github_normalize(release, entry) + raise ValueError(f"{entry['source']}: 固定した版 {entry['version']} のリリースがありません") + + +# --- 共通 --- + +def resolve(entry, latest): + kind = entry["source"].partition(":")[0] + if kind == "modrinth": + return modrinth_resolve(entry, latest) + if kind == "github": + return github_resolve(entry, latest) + raise ValueError(f"{entry['source']}: 自動処理の対象外です") + + +def validated(entry): + if not entry["version"] or not entry["url"].startswith("https://") or not SHA256.match(entry["sha256"]): + raise ValueError(f"{entry['source']}: lock の値の形が想定と違います") + if entry["source"].startswith("modrinth:") and not SHA512.match(entry.get("sha512", "")): + raise ValueError(f"{entry['source']}: lock の sha512 の形が想定と違います") + return entry + + +def check(lock): + bad = 0 + for name, entry in lock.items(): + if not is_auto(entry): + print(f"SKIP {name}: {entry['source']} ({entry.get('note', '自動処理の対象外')})") + continue + try: + validated(entry) + published = resolve(entry, latest=False) + sha256, sha512 = download_hashes(entry["url"]) + except Exception as e: + print(f"NG {name}: {e}") + bad += 1 + continue + problems = [] + if published["url"] != entry["url"] or published["file"] != entry["file"]: + problems.append("配布元のファイルが lock と違う") + if entry["source"].startswith("modrinth:") and published["sha512"] != entry["sha512"]: + problems.append("配布元の sha512 が lock と違う") + if entry["source"].startswith("github:") and published.get("sha256_published") not in (None, entry["sha256"]): + problems.append("配布元の digest が lock と違う") + if sha256 != entry["sha256"]: + problems.append("取ったものの sha256 が lock と違う") + if entry["source"].startswith("modrinth:") and sha512 != entry["sha512"]: + problems.append("取ったものの sha512 が lock と違う") + if problems: + print(f"NG {name}: {'; '.join(problems)}") + bad += 1 + else: + print(f"OK {name}: {entry['version']} {sha256}") + return 1 if bad else 0 + + +def update(lock): + new = {} + changed = 0 + for name, entry in lock.items(): + if not is_auto(entry): + new[name] = entry + continue + latest = resolve(entry, latest=True) + if latest["version"] == entry["version"] and latest["file"] == entry["file"] and latest["url"] == entry["url"]: + new[name] = entry + continue + sha256, sha512 = download_hashes(latest["url"]) + if latest.get("sha512") and sha512 != latest["sha512"]: + raise ValueError(f"{name}: 取ったものが Modrinth の公開ハッシュと違います") + if latest.get("sha256_published") and sha256 != latest["sha256_published"]: + raise ValueError(f"{name}: 取ったものが GitHub の公開ハッシュと違います") + updated = dict(entry) + updated.update({"version": latest["version"], "file": latest["file"], "url": latest["url"], "sha256": sha256}) + if latest.get("sha512"): + updated["sha512"] = latest["sha512"] + new[name] = validated(updated) + print(f"{name}: {entry['version']} -> {latest['version']}") + changed += 1 + if changed: + tmp = LOCK.with_suffix(".json.tmp") + tmp.write_text(json.dumps(new, indent=2, ensure_ascii=False) + "\n", encoding="utf-8", newline="\n") + os.replace(tmp, LOCK) + else: + print("更新はありません") + return 0 + + +def fetch(lock, target): + target = pathlib.Path(target) + target.mkdir(parents=True, exist_ok=True) + bad = 0 + for name, entry in lock.items(): + if not is_auto(entry): + print(f"SKIP {name}: {entry['source']} は自動でそろえません") + continue + dest = target / entry["file"] + if dest.exists() and file_sha256(dest) == entry["sha256"]: + print(f"OK {name}: 既に {entry['file']} がそろっています") + else: + download_to(entry["url"], dest) + got = file_sha256(dest) + if got != entry["sha256"]: + print(f"NG {name}: 取ったものの sha256 が lock と違います ({got})") + dest.unlink(missing_ok=True) + bad += 1 + continue + print(f"FETCH {name}: {entry['file']} ({entry['version']})") + for other in sorted(target.glob(entry["glob"])): + if other.name != entry["file"] and other.is_file(): + other.unlink() + print(f"REMOVE {name}: 旧い {other.name} を除きました") + return 1 if bad else 0 + + +def main(): + args = sys.argv[1:] + if args not in (["check"], ["update"]) and not (len(args) == 2 and args[0] == "fetch"): + print(__doc__) + return 2 + lock = json.loads(LOCK.read_text(encoding="utf-8")) + if args[0] == "check": + return check(lock) + if args[0] == "update": + return update(lock) + return fetch(lock, args[1]) + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/plugins.lock.json b/plugins.lock.json new file mode 100644 index 0000000..21100f2 --- /dev/null +++ b/plugins.lock.json @@ -0,0 +1,439 @@ +{ + "BlueMap": { + "source": "modrinth:bluemap", + "version": "5.29-paper", + "file": "bluemap-5.29-paper.jar", + "glob": "bluemap-*-paper.jar", + "url": "https://cdn.modrinth.com/data/swbUV1cr/versions/uHQIrUdf/bluemap-5.29-paper.jar", + "sha256": "7bf475936c26107d476c63151c76d5b49e865eebeada12c9e7d92155de877b9f", + "sha512": "e936198eaf7ea83429e1d08b8e2a5447dd359c0252e3410cb3cc101860c933abcc055462a11b034a4dd77b699da54017412ac73728860fd8b68a672c32d9926c" + }, + "DiscordSRV": { + "source": "modrinth:discordsrv", + "version": "1.30.5", + "file": "DiscordSRV-Build-1.30.5.jar", + "glob": "DiscordSRV-*.jar", + "url": "https://cdn.modrinth.com/data/UmLGoGij/versions/ATlquwiT/DiscordSRV-Build-1.30.5.jar", + "sha256": "ef2fa1f2eb146c7c77412b7190a7dd33f1fc91282683fe45407739554c8aefef", + "sha512": "ef31c7dd8962c7f907bc37b6d762c0ebd1b52f20ff72bb2dd35edb0e354010c03d3eb4cafa8f7acec42aa5e91988814bd0c338a5bced06095c07a6b9b366505c" + }, + "WorldEdit": { + "source": "modrinth:worldedit", + "version": "7.4.6", + "file": "worldedit-bukkit-7.4.6.jar", + "glob": "worldedit-bukkit-*.jar", + "url": "https://cdn.modrinth.com/data/1u6JkXh5/versions/YFnqiUlL/worldedit-bukkit-7.4.6.jar", + "sha256": "e0ce67d870ad1fef8a40dd9d7926360caf3bb44722438545d6b20b55f82a0c91", + "sha512": "1fe3975132857093f971fed9efc601299bfa76fa7885f52a542fee41e7a0165ca9cb3cbcf5ae244474887d774d650b0db6f8f79aa80f98b245dea44f1c1b4152" + }, + "WorldGuard": { + "source": "modrinth:worldguard", + "version": "7.0.20", + "file": "worldguard-bukkit-7.0.20.jar", + "glob": "worldguard-bukkit-*.jar", + "url": "https://cdn.modrinth.com/data/DKY9btbd/versions/9YdeGXiK/worldguard-bukkit-7.0.20.jar", + "sha256": "8768a49bcbecbb7a413ad134ee72d9871cdf967b7d938e6b96bb0ca72bb1467b", + "sha512": "d7ad3f8b14c57deceb409dc8997fe3d7f0a98dd4158c52648111bfbe6934ca9be53fa42ece4d60d9c2d9da33f7d6ecf597117991bd3b8e7afbf308cd925e409c" + }, + "EssentialsXChat": { + "source": "modrinth:essentialsx-chat-module", + "version": "2.22.0", + "file": "EssentialsXChat-2.22.0.jar", + "glob": "EssentialsXChat-*.jar", + "url": "https://cdn.modrinth.com/data/2qgyQbO1/versions/2k7YvKOk/EssentialsXChat-2.22.0.jar", + "sha256": "e5b0211f98af1eaba712d9294997639a39209db1fc842394a0923820073ec65a", + "sha512": "93d60889a463475f2a7ce204115f8f0cfb4be0347e6c060774cd4734ec0ba036c5789b0eef183cca735069063698ae99301056556f0511fb8e80eb0545366cd1" + }, + "PlaceholderAPI": { + "source": "modrinth:placeholderapi", + "version": "2.12.3", + "file": "PlaceholderAPI-2.12.3.jar", + "glob": "PlaceholderAPI-*.jar", + "url": "https://cdn.modrinth.com/data/lKEzGugV/versions/pIvQcXW8/PlaceholderAPI-2.12.3.jar", + "sha256": "fde03259f5af6938f3c33eeb4d814000a1adabf1d2304ce14970be81f609a437", + "sha512": "f048d55b633fd816c08e2e4472bd54a75fc4d13534682e6e7745408253d2f393706efdc389d12ca2cf28d4dc035a9afdda3eed9ecde51c7e332831391d9b6479" + }, + "CommandPanels": { + "source": "modrinth:commandpanels", + "version": "4.2.5", + "file": "CommandPanels-4.2.5.jar", + "glob": "CommandPanels-*.jar", + "url": "https://cdn.modrinth.com/data/towqcvHT/versions/pPFH50wN/CommandPanels-4.2.5.jar", + "sha256": "2308d96d258844aecea5a1da81143793e55dfca34435a0cd7def9dd60c224b9e", + "sha512": "ec89df6862ed496701913e90cf629a853ee7ccec7aef138ddc0a17661fbbe46d019457c694025d597d8988ca4fab2367977b3738dcd1acee88651664fdf0759a" + }, + "ImageFrame": { + "source": "modrinth:imageframe", + "version": "2026.1.5", + "file": "ImageFrame-2026.1.5.0.jar", + "glob": "ImageFrame-*.jar", + "url": "https://cdn.modrinth.com/data/lJFOpcEj/versions/dKkWOwRr/ImageFrame-2026.1.5.0.jar", + "sha256": "65b5c14eb6bd847f1cc0f4985efa95ab43d2f3e2f67dbaec2ecf3ea327fde9b1", + "sha512": "e9ee5cea569946767c125397550c7ca5bbcbe0d504832af216ec9d8dea99f532f4af80e0e9a17ee917c7fd78c10292ba3bbe61457947f19d3edf68bbf5f2f4a8" + }, + "GSit": { + "source": "modrinth:gsit", + "version": "3.7.0", + "file": "GSit-3.7.0.jar", + "glob": "GSit-*.jar", + "url": "https://cdn.modrinth.com/data/GOHbQGyX/versions/gnY5Flgo/GSit-3.7.0.jar", + "sha256": "143d38509f49c40b214887ad3c682c8db7fdd81c610787d0186d65f51256f4d2", + "sha512": "7813fe99d2fde47e3a40538c09b87b88b6101c27fb4f3305e0fd9bf806809c37e4e67c726f96596caca79785cdd7aa8d8ae724b211535775db21e602f57993d5" + }, + "TrainCarts": { + "source": "modrinth:traincarts", + "version": "2.0.3", + "file": "TrainCarts-2.0.3-1768.jar", + "glob": "TrainCarts-*.jar", + "url": "https://cdn.modrinth.com/data/7xgugLBo/versions/tczjSWCe/TrainCarts-2.0.3-1768.jar", + "sha256": "915402d2818acc5f0356c51f08c6a10e5252688c048c366659dd673cca78db9b", + "sha512": "450d33c2f1a75e161ea99dd69ad5751e554328152bf8a6d904b36211b220f543ca9ae9a4a175b32d682c451b5e6d0250031dc1d32472fc530081fb57da47fc94" + }, + "BKCommonLib": { + "source": "modrinth:bkcommonlib", + "version": "2.0.5", + "file": "BKCommonLib-2.0.5-2090.jar", + "glob": "BKCommonLib-*.jar", + "url": "https://cdn.modrinth.com/data/rTg6ckWb/versions/bV0IsMUE/BKCommonLib-2.0.5-2090.jar", + "sha256": "cd5971e2bd453eb0fef3e35660f1c593f8433b23e6f82ac74a46f899cb0335f6", + "sha512": "f9c8ddb60c11a14dbbc989a170fedd484ad3bef1b96e9071102e98db3834cbbacf3736ce92972543961fc2c7f683599e3423e299615a3a54e786d8ab6d958502" + }, + "Multiverse-Core": { + "source": "modrinth:multiverse-core", + "version": "4.3.12", + "file": "multiverse-core-4.3.12.jar", + "glob": "multiverse-core-*.jar", + "url": "https://cdn.modrinth.com/data/3wmN97b8/versions/LgvHOAFp/multiverse-core-4.3.12.jar", + "sha256": "98237aaf35c6ee7bfd95fb7f399ef703b3e72bff8eab488a904aad9d4530cd10", + "sha512": "8edfb100403dc6af2056c63b12429e98d5945817229d135c6b1e98735ec15203712ac8f0d229bc1aa478d25ccfb8410918d4ff805f20b9d4b997e11543183d5c" + }, + "FreedomChat": { + "source": "modrinth:freedomchat", + "version": "1.7.10", + "file": "FreedomChat-Paper-1.7.10.jar", + "glob": "FreedomChat-Paper-*.jar", + "url": "https://cdn.modrinth.com/data/MubyTbnA/versions/EizopLcV/FreedomChat-Paper-1.7.10.jar", + "sha256": "2b23719fcf64ffa6947634cdf6fdc5f4d12e32bafec7e00efc7fdfa8a56a7be2", + "sha512": "5532808fa4e08a9156832d54462435b7ff058d0159a14f171bbf1899b16ffb35c74e98ca9e7ca7fec43d4e7b46f9ac18a3386533b8d0b16cbc16fb048a9c47e4" + }, + "RealScoreboard": { + "source": "modrinth:realscoreboard", + "version": "1.6", + "file": "RealScoreboard-1.6.jar", + "glob": "RealScoreboard-*.jar", + "url": "https://cdn.modrinth.com/data/rw3Y0WsP/versions/eGDksV0d/RealScoreboard-1.6.jar", + "sha256": "f849fb18244267699556404de74447dab5759e11d6468dfd7d8ee9f84de9d87d", + "sha512": "72f50fb283415f4b8943a3785ecd4cbf5cdca8cb9b366c3d84af8ba3b022d5396f202bb6f6595f4f0a07bb8d521b1749eb8c4eb91cb9eb2eb2f9b445642af80c" + }, + "SeeMore": { + "source": "modrinth:seemore", + "version": "1.0.2", + "file": "SeeMore-1.0.2.jar", + "glob": "SeeMore-*.jar", + "url": "https://cdn.modrinth.com/data/IEt1Yy3F/versions/QXCh3qCi/SeeMore-1.0.2.jar", + "sha256": "8d06d342489947a296f07fbd012ea0e9842242f5af8d534f2dc91b9d2f0721e6", + "sha512": "5b6ad1edf059b8f78bb75b0cb7a47df39c05a1443d35e3b8a1f71ed78c4ccbc75d0422001442e6fc3bfdb9df26545600825af22bb00671135d5d206c20fc016b" + }, + "ArmorStandEditor": { + "source": "modrinth:armorstandeditor-reborn", + "version": "26.3-52.1", + "file": "ArmorStandEditor-26.3-52.1.jar", + "glob": "ArmorStandEditor-*.jar", + "url": "https://cdn.modrinth.com/data/oIBGjZ77/versions/rIPMStjV/ArmorStandEditor-26.3-52.1.jar", + "sha256": "ae80f6d14cefc08ba8bece4871b3245cd756e6784c94af02712696c65110ade4", + "sha512": "01bc8575f3cba159b6bab3022fe0e61bb2e703115a1ee656563950db72e8aa09dca750c96f93319e5287d0eeb1aecab40d6f5aa0b47ab11cfa9279c359381cce" + }, + "WESV": { + "source": "modrinth:wesv", + "version": "2.1.10", + "file": "WorldEditSelectionVisualizer-2.1.10.jar", + "glob": "WorldEditSelectionVisualizer-*.jar", + "url": "https://cdn.modrinth.com/data/irvQvXtE/versions/QJkYgQDu/WorldEditSelectionVisualizer-2.1.10.jar", + "sha256": "5897fd8de2fafa3fadcde94bb4e48d69047817548bcb9190254190a596509bd2", + "sha512": "a760d432eacc37b38c536a1ff216c11e06721e6f3c639a22bc5c494708d56d19c37f180b7f561c753cd6a82effb1c617fc41f6c435c6c385411a43c7c12eb924" + }, + "Vault": { + "source": "github:MilkBowl/Vault", + "version": "1.7.3", + "file": "Vault.jar", + "glob": "Vault.jar", + "url": "https://github.com/MilkBowl/Vault/releases/download/1.7.3/Vault.jar", + "sha256": "a6b5ed97f43a5cf5bbaf00a7c8cd23c5afc9bd003f849875af8b36e6cf77d01d" + }, + "BlocksHub": { + "source": "github:SBPrime/BlocksHub", + "version": "v3.2.1", + "file": "BlocksHub-3.2.1.jar", + "glob": "BlocksHub-*.jar", + "url": "https://github.com/SBPrime/BlocksHub/releases/download/v3.2.1/BlocksHub-3.2.1.jar", + "sha256": "e5e1b484d7f062a191337438fe38c2ca9d9ac0fbb10bc24c9cc5600378c2dda2" + }, + "GeyserSkinManager": { + "source": "github:Camotoy/GeyserSkinManager", + "version": "1.8", + "file": "GeyserSkinManager-Spigot.jar", + "glob": "GeyserSkinManager-Spigot*.jar", + "url": "https://github.com/Camotoy/GeyserSkinManager/releases/download/1.8/GeyserSkinManager-Spigot.jar", + "sha256": "48d9e2d6f7184db9b4bae6ab17227c00de1d51782c1841a1277ec8c398272edd" + }, + "WorldGuardExtraFlags": { + "source": "github:aromaa/WorldGuardExtraFlags", + "version": "v4.2.2", + "file": "WorldGuardExtraFlags.jar", + "glob": "WorldGuardExtraFlags*.jar", + "url": "https://github.com/aromaa/WorldGuardExtraFlags/releases/download/v4.2.2/WorldGuardExtraFlags.jar", + "sha256": "033c40998f66752568429af007cdc0e6dd1b0ce16fae1ea065f4c25ff6272755" + }, + "CoreProtect": { + "source": "compat", + "version": "24.1", + "file": "CoreProtect-24.1-toro26.3.jar", + "note": "toro-plugin-compat のパッチ済みビルド。上流の自動更新で上書きしない" + }, + "Shopkeepers": { + "source": "compat", + "version": "2.28.1", + "file": "Shopkeepers-2.28.1-toro26.3.jar", + "note": "toro-plugin-compat のパッチ済みビルド。上流の自動更新で上書きしない" + }, + "EssentialsX": { + "source": "compat", + "version": "2.22.0", + "file": "EssentialsX-2.22.0-mc26.3.jar", + "note": "toro-plugin-compat のパッチ済みビルド。上流の自動更新で上書きしない" + }, + "MyPet": { + "source": "compat", + "version": "3.14.3", + "file": "MyPet-3.14.3-mc26.3.jar", + "note": "toro-plugin-compat のパッチ済みビルド。上流の自動更新で上書きしない" + }, + "Vehicles": { + "source": "compat", + "version": "14.4", + "file": "Vehicles-14.4-mc26.3.jar", + "note": "toro-plugin-compat のパッチ済みビルド。上流の自動更新で上書きしない" + }, + "LuckPerms": { + "source": "manual", + "version": "5.5.88", + "file": "LuckPerms-Bukkit-5.5.88.jar", + "note": "公式サイト luckperms.net 配布。検証できる公開ハッシュの API が無い" + }, + "ProtocolLib": { + "source": "manual", + "version": "5.5.0-SNAPSHOT", + "file": "ProtocolLib.jar", + "note": "公式 Jenkins のスナップショット。版が流動的なため固定対象外" + }, + "Dynmap": { + "source": "manual", + "version": "3.9-SNAPSHOT", + "file": "Dynmap-3.9-SNAPSHOT-spigot.jar", + "note": "公式スナップショット。地図描画は TORO-Renderer へ一本化する方針もあり別途判断" + }, + "Dynmap-WorldGuard": { + "source": "manual", + "version": "1.4-beta-1", + "file": "Dynmap-WorldGuard-1.4-beta-1.jar", + "note": "Dynmap 公式アドオン。公開ハッシュなし" + }, + "BungeeGuard": { + "source": "manual", + "version": "1.3-SNAPSHOT", + "file": "BungeeGuard.jar", + "note": "Luck 公式スナップショット" + }, + "LunaChat": { + "source": "manual", + "version": "3.1.6", + "file": "LunaChat.jar", + "note": "3.1.6 の配布元が GitHub リリース (ucchyocean は v3.0.16 まで) に無い" + }, + "WorldBorder": { + "source": "manual", + "version": "2.1.5", + "file": "WorldBorder.jar", + "note": "配布元の公開ハッシュなし" + }, + "CrackShot": { + "source": "manual", + "version": "0.98.13", + "file": "CrackShot.jar", + "note": "閉源配布。公開ハッシュなし" + }, + "Valoshot": { + "source": "manual", + "version": "1.0.1", + "file": "Valoshot-1.0.1.jar", + "note": "第三者作。配布元の公開ハッシュなし" + }, + "Lift": { + "source": "manual", + "version": "unknown", + "file": "Lift.jar", + "note": "jar 内の版数が未置換プレースホルダで特定不能 (監査 PLUGIN-PROVENANCE-2)" + }, + "TORO-Core": { + "source": "manual", + "version": "1.0.0", + "file": "TORO-Core-1.0.0.jar", + "note": "内製。TORO-Server/TORO-Core でビルド・配布する" + }, + "MarumaSignCompanion": { + "source": "manual", + "version": "2.3.0", + "file": "MarumaSignCompanion-2.3.0.jar", + "note": "内製。TORO-Server/MarumaSign-Companion でビルド・配布する" + }, + "TOROpassICsystem": { + "source": "manual", + "version": "1.7", + "file": "TOROpassICsystem-1.7.jar", + "note": "内製。TORO-Server/TOROpassICsystem でビルド・配布する" + }, + "TextBeacon": { + "source": "manual", + "version": "1.0", + "file": "TextBeacon-1.0.jar", + "note": "内製。TORO-Server/TextBeacon でビルド・配布する" + }, + "Skills": { + "source": "manual", + "version": "1.0", + "file": "skills-1.0.jar", + "note": "内製。TORO-Server/Skills でビルド・配布する" + }, + "Report": { + "source": "manual", + "version": "1.1.2", + "file": "report-1.1.2.jar", + "note": "内製。TORO-Server/Report でビルド・配布する" + }, + "MasconCart": { + "source": "manual", + "version": "1.3.3", + "file": "MasconCart-1.3.3.jar", + "note": "内製。TORO-Server/MasconCart でビルド・配布する" + }, + "AddPerm": { + "source": "manual", + "version": "1.2", + "file": "add-parm-1.2.jar", + "note": "内製。TORO-Server/addperm (本番のファイル名は add-parm) でビルド・配布する" + }, + "InventoryBackup": { + "source": "manual", + "version": "1.0", + "file": "InventoryBackup-1.0.jar", + "note": "内製。TORO-Server/InventoryBackup でビルド・配布する" + }, + "InfinityDispense": { + "source": "manual", + "version": "1.0", + "file": "InfinityDispense-1.0.jar", + "note": "内製。TORO-Server/InfinityDispense でビルド・配布する" + }, + "raidwatcher": { + "source": "manual", + "version": "1.0", + "file": "raidwatcher-1.0.jar", + "note": "内製。TORO-Server/raidwatcher でビルド・配布する" + }, + "EffectGUI": { + "source": "manual", + "version": "1.0", + "file": "effect_gui-1.0.jar", + "note": "内製 (ソース所在は監査時点で未確認)" + }, + "ClockPlugin": { + "source": "manual", + "version": "2.0", + "file": "clock-2.0.jar", + "note": "内製 (ソース所在は監査時点で未確認)" + }, + "DispenserFallingBlock": { + "source": "manual", + "version": "1.1", + "file": "dispenser_falling_block-1.1.jar", + "note": "内製 (ソース所在は監査時点で未確認)" + }, + "BanPlayerSheet": { + "source": "manual", + "version": "1.1", + "file": "BanPlayerSheet-1.1.jar", + "note": "内製 (ソース所在は監査時点で未確認)" + }, + "HatColorTeam": { + "source": "manual", + "version": "1.0", + "file": "HatColorTeam-1.0.jar", + "note": "内製 (ソース所在は監査時点で未確認)" + }, + "KillPotionDeathLog": { + "source": "manual", + "version": "1.0", + "file": "KillPotionDeathLog-1.0.jar", + "note": "内製 (ソース所在は監査時点で未確認)" + }, + "AutoMessage": { + "source": "manual", + "version": "2.1", + "file": "auto_message-2.1.jar", + "note": "内製 (ソース所在は監査時点で未確認)" + }, + "WarnKillPotion": { + "source": "manual", + "version": "2.0", + "file": "Warn_KillPotion-2.0.jar", + "note": "内製 (ソース所在は監査時点で未確認)" + }, + "ClockItemTimer": { + "source": "manual", + "version": "1.1", + "file": "clock_item_timer-1.1.jar", + "note": "内製 (ソース所在は監査時点で未確認)" + }, + "TeleportSpectator": { + "source": "manual", + "version": "1.0", + "file": "teleport_spectator-1.0.jar", + "note": "内製 (ソース所在は監査時点で未確認)" + }, + "ArmorStand": { + "source": "manual", + "version": "1.0", + "file": "armor_stand-1.0.jar", + "note": "内製 (ソース所在は監査時点で未確認)" + }, + "DispenserActions": { + "source": "manual", + "version": "1.1", + "file": "DispenserActions-1.1.jar", + "note": "内製 (ソース所在は監査時点で未確認)" + }, + "HideNametagCMD": { + "source": "manual", + "version": "1.0", + "file": "hide_nametag_cmd-1.0.jar", + "note": "内製 (ソース所在は監査時点で未確認)" + }, + "TpsLog": { + "source": "manual", + "version": "4.0", + "file": "tps_log-4.0.jar", + "note": "内製 (ソース所在は監査時点で未確認)" + }, + "ItemDropCooldown": { + "source": "manual", + "version": "1.0", + "file": "item_drop_cooldown-1.0.jar", + "note": "内製 (ソース所在は監査時点で未確認)" + }, + "ClickMinecart": { + "source": "manual", + "version": "3.1", + "file": "ClickMinecart-3.1.jar", + "note": "内製 (ソース所在は監査時点で未確認)" + } +} diff --git a/tests/test_auto_update_plugins.py b/tests/test_auto_update_plugins.py new file mode 100644 index 0000000..466c312 --- /dev/null +++ b/tests/test_auto_update_plugins.py @@ -0,0 +1,157 @@ +#!/usr/bin/env python3 +"""auto_update_plugins の単体テスト。ネットワークは使わない。""" +import hashlib +import json +import os +import pathlib +import sys +import tempfile +import unittest +from unittest import mock + +sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) +import auto_update_plugins as aup + + +def version(number, loaders, files, date="2026-01-01T00:00:00Z", vtype="release"): + return { + "version_number": number, + "version_type": vtype, + "loaders": loaders, + "game_versions": ["1.21.11", "26.3"], + "date_published": date, + "files": files, + } + + +def mfile(name, sha512="a" * 128, primary=True): + return {"filename": name, "url": f"https://cdn.example/{name}", "primary": primary, + "hashes": {"sha512": sha512, "sha1": "b" * 40}} + + +class ModrinthSelectTest(unittest.TestCase): + def setUp(self): + self.entry = {"source": "modrinth:example", "version": "1.0-paper", "glob": "ex-*-paper.jar"} + + def test_pinned(self): + versions = [version("1.0-paper", ["paper"], [mfile("ex-1.0-paper.jar")]), + version("2.0-paper", ["paper"], [mfile("ex-2.0-paper.jar")])] + got = aup.modrinth_select(versions, self.entry, latest=False) + self.assertEqual(got["file"], "ex-1.0-paper.jar") + self.assertEqual(got["sha512"], "a" * 128) + + def test_latest_skips_beta_and_wrong_loader(self): + versions = [ + version("3.0-paper", ["paper"], [mfile("ex-3.0-paper.jar")], date="2026-03-01T00:00:00Z", vtype="beta"), + version("2.0-fabric", ["fabric"], [mfile("ex-2.0-fabric.jar")], date="2026-02-01T00:00:00Z"), + version("1.5-paper", ["paper"], [mfile("ex-1.5-paper.jar")], date="2026-01-15T00:00:00Z"), + version("1.0-paper", ["paper"], [mfile("ex-1.0-paper.jar")], date="2026-01-01T00:00:00Z"), + ] + got = aup.modrinth_select(versions, self.entry, latest=True) + self.assertEqual(got["version"], "1.5-paper") + + def test_latest_prefers_primary_file(self): + v = version("2.0-paper", ["paper"], [ + mfile("ex-2.0-paper-sources.jar", primary=False), + mfile("ex-2.0-paper.jar", primary=True), + ]) + got = aup.modrinth_select([v], self.entry, latest=True) + self.assertEqual(got["file"], "ex-2.0-paper.jar") + + def test_game_version_filter(self): + versions = [version("2.0-paper", ["paper"], [mfile("ex-2.0-paper.jar")], date="2026-02-01T00:00:00Z"), + version("1.0-paper", ["paper"], [mfile("ex-1.0-paper.jar")], date="2026-01-01T00:00:00Z")] + versions[0]["game_versions"] = ["1.21.11"] + with mock.patch.dict(os.environ, {"AUP_GAME_VERSION": "26.3"}): + got = aup.modrinth_select(versions, self.entry, latest=True) + self.assertEqual(got["version"], "1.0-paper") + + +class GitHubTest(unittest.TestCase): + def test_normalize_with_digest(self): + release = {"tag_name": "v2.0", "assets": [ + {"name": "Other.jar", "browser_download_url": "https://x/Other.jar", "digest": None}, + {"name": "Plug-2.0.jar", "browser_download_url": "https://x/Plug-2.0.jar", + "digest": "sha256:" + "c" * 64}, + ]} + entry = {"source": "github:o/r", "glob": "Plug-*.jar"} + got = aup.github_normalize(release, entry) + self.assertEqual(got["file"], "Plug-2.0.jar") + self.assertEqual(got["sha256_published"], "c" * 64) + + def test_normalize_without_digest(self): + release = {"tag_name": "1.0", "assets": [ + {"name": "Plug.jar", "browser_download_url": "https://x/Plug.jar", "digest": None}]} + got = aup.github_normalize(release, {"source": "github:o/r", "glob": "Plug.jar"}) + self.assertNotIn("sha256_published", got) + + +class ValidatedTest(unittest.TestCase): + def test_rejects_bad_sha256(self): + entry = {"source": "github:o/r", "version": "1.0", "url": "https://x/a.jar", "sha256": "zz"} + with self.assertRaises(ValueError): + aup.validated(entry) + + +class FetchTest(unittest.TestCase): + def test_fetch_places_and_removes_stale(self): + content = b"jar-bytes" + sha = hashlib.sha256(content).hexdigest() + lock = { + "Plug": {"source": "github:o/r", "version": "2.0", "file": "Plug-2.0.jar", + "glob": "Plug-*.jar", "url": "https://x/Plug-2.0.jar", "sha256": sha}, + "Hand": {"source": "manual", "version": "1.0", "file": "Hand.jar", "note": "手動"}, + } + + def fake_download(url, dest): + pathlib.Path(dest).write_bytes(content) + + with tempfile.TemporaryDirectory() as td: + target = pathlib.Path(td) + (target / "Plug-1.0.jar").write_bytes(b"old") + with mock.patch.object(aup, "download_to", fake_download): + rc = aup.fetch(lock, td) + self.assertEqual(rc, 0) + self.assertTrue((target / "Plug-2.0.jar").exists()) + self.assertFalse((target / "Plug-1.0.jar").exists()) + # 2回目はダウンロードしない + with mock.patch.object(aup, "download_to", side_effect=AssertionError("再取得した")): + rc = aup.fetch(lock, td) + self.assertEqual(rc, 0) + + +class CheckTest(unittest.TestCase): + def test_check_ok_and_ng(self): + entry = {"source": "github:o/r", "version": "1.0", "file": "Plug.jar", "glob": "Plug.jar", + "url": "https://x/Plug.jar", "sha256": "d" * 64} + published = {"version": "1.0", "file": "Plug.jar", "url": "https://x/Plug.jar"} + lock = {"Plug": entry, "Hand": {"source": "compat", "version": "1", "file": "H.jar", "note": "n"}} + with mock.patch.object(aup, "resolve", return_value=published), \ + mock.patch.object(aup, "download_hashes", return_value=("d" * 64, "e" * 128)): + self.assertEqual(aup.check(lock), 0) + with mock.patch.object(aup, "resolve", return_value=published), \ + mock.patch.object(aup, "download_hashes", return_value=("f" * 64, "e" * 128)): + self.assertEqual(aup.check(lock), 1) + + +class UpdateTest(unittest.TestCase): + def test_update_rewrites_lock(self): + entry = {"source": "github:o/r", "version": "1.0", "file": "Plug-1.0.jar", "glob": "Plug-*.jar", + "url": "https://x/Plug-1.0.jar", "sha256": "0" * 64} + latest = {"version": "2.0", "file": "Plug-2.0.jar", "url": "https://x/Plug-2.0.jar", + "sha256_published": "1" * 64} + lock = {"Plug": entry, "Hand": {"source": "manual", "version": "9", "file": "H.jar", "note": "n"}} + with tempfile.TemporaryDirectory() as td: + lockpath = pathlib.Path(td) / "plugins.lock.json" + with mock.patch.object(aup, "LOCK", lockpath), \ + mock.patch.object(aup, "resolve", return_value=latest), \ + mock.patch.object(aup, "download_hashes", return_value=("1" * 64, "2" * 128)): + self.assertEqual(aup.update(lock), 0) + written = json.loads(lockpath.read_text(encoding="utf-8")) + self.assertEqual(written["Plug"]["version"], "2.0") + self.assertEqual(written["Plug"]["sha256"], "1" * 64) + self.assertEqual(written["Hand"]["version"], "9") + + +if __name__ == "__main__": + unittest.main()