Commit 818adb70 authored by Jérome Perrin's avatar Jérome Perrin

software/dufs: version up dufs 0.43.0

parent 51ca4092
Pipeline #37908 failed with stage
in 0 seconds
......@@ -15,4 +15,4 @@
[instance.cfg.in]
filename = instance.cfg.in
md5sum = 1e9012cb8476e00497b3fe9881158440
md5sum = c1c5db680dee5cfe5334cedae4b7fc51
......@@ -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
......
......@@ -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 =
......
......@@ -43,6 +43,7 @@ setup(
install_requires=[
'slapos.core',
'slapos.libnetworkcache',
'lxml',
'requests',
],
zip_safe=True,
......
......@@ -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()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment