From 818adb70c9488652359c494c808d453f706f9d6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Wed, 6 Nov 2024 00:32:19 +0900 Subject: [PATCH] software/dufs: version up dufs 0.43.0 --- software/dufs/buildout.hash.cfg | 2 +- software/dufs/instance.cfg.in | 7 ++++--- software/dufs/software.cfg | 4 ++-- software/dufs/test/setup.py | 1 + software/dufs/test/test.py | 34 +++++++++++++++++++++++---------- 5 files changed, 32 insertions(+), 16 deletions(-) diff --git a/software/dufs/buildout.hash.cfg b/software/dufs/buildout.hash.cfg index b1abaf16e..c9078d862 100644 --- a/software/dufs/buildout.hash.cfg +++ b/software/dufs/buildout.hash.cfg @@ -15,4 +15,4 @@ [instance.cfg.in] filename = instance.cfg.in -md5sum = 1e9012cb8476e00497b3fe9881158440 +md5sum = c1c5db680dee5cfe5334cedae4b7fc51 diff --git a/software/dufs/instance.cfg.in b/software/dufs/instance.cfg.in index dd5df3367..c2263a679 100644 --- a/software/dufs/instance.cfg.in +++ b/software/dufs/instance.cfg.in @@ -189,9 +189,7 @@ return = domain secure_access [frontend-available-promise] <= check-url-available-promise -url = ${frontend:connection-secure_access} -check-secure = 1 - +url = ${frontend-url:healthcheck-url} [promises] recipe = @@ -216,6 +214,9 @@ init = assert not frontend_url.username self.options['upload-url'] = frontend_url._replace( netloc=f'{admin_user}:{admin_password}@{frontend_url.netloc}').geturl() + self.options['healthcheck-url'] = frontend_url._replace( + path='/__dufs__/health').geturl() + [publish-connection-parameter] recipe = slapos.cookbook:publish diff --git a/software/dufs/software.cfg b/software/dufs/software.cfg index 5de848ebe..1bf19b7d8 100644 --- a/software/dufs/software.cfg +++ b/software/dufs/software.cfg @@ -13,8 +13,8 @@ parts = [dufs] recipe = slapos.recipe.cmmi shared = true -url = https://github.com/sigoden/dufs/archive/refs/tags/v0.40.0.tar.gz -md5sum = 3b71b3d07af69d6ba92c054625dc0dd2 +url = https://github.com/sigoden/dufs/archive/refs/tags/v0.43.0.tar.gz +md5sum = 77da2d3e5b5f7f159707db5c93ce8a9d configure-command = : make-binary = cargo install --root=%(location)s --path . --locked make-targets = diff --git a/software/dufs/test/setup.py b/software/dufs/test/setup.py index 67aac58c3..4931245b9 100644 --- a/software/dufs/test/setup.py +++ b/software/dufs/test/setup.py @@ -43,6 +43,7 @@ setup( install_requires=[ 'slapos.core', 'slapos.libnetworkcache', + 'lxml', 'requests', ], zip_safe=True, diff --git a/software/dufs/test/test.py b/software/dufs/test/test.py index 626a63863..837ffae6a 100644 --- a/software/dufs/test/test.py +++ b/software/dufs/test/test.py @@ -25,7 +25,9 @@ # ############################################################################## +import base64 import contextlib +import json import io import os import pathlib @@ -33,13 +35,15 @@ import subprocess import tempfile import urllib.parse + import requests +import lxml.html from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass + setUpModule, SlapOSInstanceTestCase = makeModuleSetUpAndTestCaseClass( - os.path.abspath( - os.path.join(os.path.dirname(__file__), '..', 'software.cfg'))) + pathlib.Path(__file__).parent.parent / 'software.cfg') class TestFileServer(SlapOSInstanceTestCase): @@ -63,6 +67,11 @@ class TestFileServer(SlapOSInstanceTestCase): self.addCleanup(os.unlink, ca_cert.name) return ca_cert.name + def _decode_index_content(self, response_text:str) -> dict: + index_data, = lxml.html.fromstring( + response_text).xpath('.//template[@id="index-data"]/text()') + return json.loads(base64.b64decode(index_data)) + def test_anonymous_can_only_access_public(self): resp = requests.get( self.connection_parameters['public-url'], @@ -87,12 +96,13 @@ class TestFileServer(SlapOSInstanceTestCase): urllib.parse.urljoin(self.connection_parameters['public-url'], '..'), verify=self.ca_cert, ) - self.assertIn('pub', resp.text) - self.assertNotIn('secret', resp.text) + self.assertEqual( + [path['name'] for path in self._decode_index_content(resp.text)['paths']], + ['pub']) self.assertEqual(resp.status_code, requests.codes.ok) def test_index(self): - pub = pathlib.Path(self.computer_partition_root_path) / 'srv' / 'www' / 'pub' + pub = self.computer_partition_root_path / 'srv' / 'www' / 'pub' (pub / 'with-index').mkdir() (pub / 'with-index' / 'index.html').write_text('<html>Hello !</html>') self.assertEqual( @@ -106,10 +116,14 @@ class TestFileServer(SlapOSInstanceTestCase): (pub / 'without-index' / 'file.txt').write_text('Hello !') self.assertIn( 'file.txt', - requests.get( - urllib.parse.urljoin(self.connection_parameters['public-url'], 'without-index/'), - verify=self.ca_cert, - ).text) + [path['name'] for path in + self._decode_index_content( + requests.get( + urllib.parse.urljoin(self.connection_parameters['public-url'], 'without-index/'), + verify=self.ca_cert, + ).text)['paths'] + ] + ) def test_upload_file_refused_without_auth(self): parsed_upload_url = urllib.parse.urlparse(self.connection_parameters['upload-url']) @@ -168,7 +182,7 @@ class TestFileServer(SlapOSInstanceTestCase): # reprocess instance to get the new certificate, after removing the timestamp # to force execution - (pathlib.Path(self.computer_partition_root_path) / '.timestamp').unlink() + (self.computer_partition_root_path / '.timestamp').unlink() self.waitForInstance() cert_after = _getpeercert() -- 2.30.9