Merge pull request 'Preserve ZIP entry metadata while validating Atelier updates' (#335) from dev/kit-atelier-v3 into main
All checks were successful
DuneRealms Kit Delivery CI / kits (push) Successful in 38s
All checks were successful
DuneRealms Kit Delivery CI / kits (push) Successful in 38s
This commit is contained in:
commit
1d8ac96a20
3 changed files with 34 additions and 2 deletions
|
|
@ -31,7 +31,7 @@ jobs:
|
|||
gradle-version: '9.2.1'
|
||||
- name: Verify bridge and build native kit items
|
||||
run: |
|
||||
python3 -m unittest discover -s network/server-control -p 'test_kit_equipment.py' -v
|
||||
python3 -m unittest discover -s network/server-control -p 'test_*.py' -v
|
||||
gradle --no-daemon -p DuneKits test jar
|
||||
- name: Upload verified kit plugin
|
||||
uses: actions/upload-artifact@v3
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
"""Preserve the existing Atelier menus/quests; adapt only receipt metadata rendering."""
|
||||
from pathlib import Path
|
||||
import hashlib
|
||||
import copy
|
||||
import os
|
||||
import sys
|
||||
import zipfile
|
||||
|
|
@ -30,7 +31,7 @@ def install(artifact, apply=False):
|
|||
try:
|
||||
with zipfile.ZipFile(temporary, 'w', zipfile.ZIP_DEFLATED) as output:
|
||||
for item in original.infolist():
|
||||
output.writestr(item, descriptor.encode() if item.filename == 'plugin.yml' else entries.get(item.filename, original.read(item.filename)))
|
||||
output.writestr(copy.copy(item), descriptor.encode() if item.filename == 'plugin.yml' else entries.get(item.filename, original.read(item.filename)))
|
||||
with zipfile.ZipFile(temporary) as check:
|
||||
assert check.testzip() is None
|
||||
assert all(check.read(name) == original.read(name) for name in original.namelist() if name not in CLASSES | {'plugin.yml'})
|
||||
|
|
|
|||
31
network/server-control/test_atelier_compat.py
Normal file
31
network/server-control/test_atelier_compat.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import hashlib
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import unittest
|
||||
import zipfile
|
||||
|
||||
|
||||
class AtelierArchiveTest(unittest.TestCase):
|
||||
def test_patch_preserves_unrelated_menu_and_quest_entries(self):
|
||||
spec = importlib.util.spec_from_file_location('installer', Path(__file__).with_name('install-atelier-compat.py'))
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
with tempfile.TemporaryDirectory(prefix='dune-atelier-test-') as directory:
|
||||
target, artifact = Path(directory)/'original.jar', Path(directory)/'compat.jar'
|
||||
with zipfile.ZipFile(target, 'w') as output:
|
||||
output.writestr('plugin.yml', 'name: DuneAtelier\nversion: 1.0.0\n')
|
||||
output.writestr('Unchanged.class', b'original-menu-and-quest-code')
|
||||
for name in module.CLASSES:
|
||||
output.writestr(name, b'original-adapter')
|
||||
with zipfile.ZipFile(artifact, 'w') as output:
|
||||
for name in module.CLASSES:
|
||||
output.writestr(name, b'\xca\xfe\xba\xbefixture-adapter')
|
||||
module.BASELINE = hashlib.sha256(target.read_bytes()).hexdigest()
|
||||
module.Path = lambda value: target if str(value) == '/opt/dunerealms/lobby/plugins/DuneAtelier-1.0.0.jar' else Path(value)
|
||||
module.install(artifact, True)
|
||||
with zipfile.ZipFile(target) as result:
|
||||
self.assertEqual(result.read('Unchanged.class'), b'original-menu-and-quest-code')
|
||||
self.assertIn('softdepend: [DuneKits]', result.read('plugin.yml').decode())
|
||||
with self.assertRaises(RuntimeError):
|
||||
module.install(artifact, True)
|
||||
Loading…
Reference in a new issue

Staff