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 @@ ...@@ -15,4 +15,4 @@
[instance.cfg.in] [instance.cfg.in]
filename = instance.cfg.in filename = instance.cfg.in
md5sum = 1e9012cb8476e00497b3fe9881158440 md5sum = c1c5db680dee5cfe5334cedae4b7fc51
...@@ -189,9 +189,7 @@ return = domain secure_access ...@@ -189,9 +189,7 @@ return = domain secure_access
[frontend-available-promise] [frontend-available-promise]
<= check-url-available-promise <= check-url-available-promise
url = ${frontend:connection-secure_access} url = ${frontend-url:healthcheck-url}
check-secure = 1
[promises] [promises]
recipe = recipe =
...@@ -216,6 +214,9 @@ init = ...@@ -216,6 +214,9 @@ init =
assert not frontend_url.username assert not frontend_url.username
self.options['upload-url'] = frontend_url._replace( self.options['upload-url'] = frontend_url._replace(
netloc=f'{admin_user}:{admin_password}@{frontend_url.netloc}').geturl() netloc=f'{admin_user}:{admin_password}@{frontend_url.netloc}').geturl()
self.options['healthcheck-url'] = frontend_url._replace(
path='/__dufs__/health').geturl()
[publish-connection-parameter] [publish-connection-parameter]
recipe = slapos.cookbook:publish recipe = slapos.cookbook:publish
......
...@@ -13,8 +13,8 @@ parts = ...@@ -13,8 +13,8 @@ parts =
[dufs] [dufs]
recipe = slapos.recipe.cmmi recipe = slapos.recipe.cmmi
shared = true shared = true
url = https://github.com/sigoden/dufs/archive/refs/tags/v0.40.0.tar.gz url = https://github.com/sigoden/dufs/archive/refs/tags/v0.43.0.tar.gz
md5sum = 3b71b3d07af69d6ba92c054625dc0dd2 md5sum = 77da2d3e5b5f7f159707db5c93ce8a9d
configure-command = : configure-command = :
make-binary = cargo install --root=%(location)s --path . --locked make-binary = cargo install --root=%(location)s --path . --locked
make-targets = make-targets =
......
...@@ -43,6 +43,7 @@ setup( ...@@ -43,6 +43,7 @@ setup(
install_requires=[ install_requires=[
'slapos.core', 'slapos.core',
'slapos.libnetworkcache', 'slapos.libnetworkcache',
'lxml',
'requests', 'requests',
], ],
zip_safe=True, zip_safe=True,
......
...@@ -25,7 +25,9 @@ ...@@ -25,7 +25,9 @@
# #
############################################################################## ##############################################################################
import base64
import contextlib import contextlib
import json
import io import io
import os import os
import pathlib import pathlib
...@@ -33,13 +35,15 @@ import subprocess ...@@ -33,13 +35,15 @@ import subprocess
import tempfile import tempfile
import urllib.parse import urllib.parse
import requests import requests
import lxml.html
from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass
setUpModule, SlapOSInstanceTestCase = makeModuleSetUpAndTestCaseClass( setUpModule, SlapOSInstanceTestCase = makeModuleSetUpAndTestCaseClass(
os.path.abspath( pathlib.Path(__file__).parent.parent / 'software.cfg')
os.path.join(os.path.dirname(__file__), '..', 'software.cfg')))
class TestFileServer(SlapOSInstanceTestCase): class TestFileServer(SlapOSInstanceTestCase):
...@@ -63,6 +67,11 @@ class TestFileServer(SlapOSInstanceTestCase): ...@@ -63,6 +67,11 @@ class TestFileServer(SlapOSInstanceTestCase):
self.addCleanup(os.unlink, ca_cert.name) self.addCleanup(os.unlink, ca_cert.name)
return 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): def test_anonymous_can_only_access_public(self):
resp = requests.get( resp = requests.get(
self.connection_parameters['public-url'], self.connection_parameters['public-url'],
...@@ -87,12 +96,13 @@ class TestFileServer(SlapOSInstanceTestCase): ...@@ -87,12 +96,13 @@ class TestFileServer(SlapOSInstanceTestCase):
urllib.parse.urljoin(self.connection_parameters['public-url'], '..'), urllib.parse.urljoin(self.connection_parameters['public-url'], '..'),
verify=self.ca_cert, verify=self.ca_cert,
) )
self.assertIn('pub', resp.text) self.assertEqual(
self.assertNotIn('secret', resp.text) [path['name'] for path in self._decode_index_content(resp.text)['paths']],
['pub'])
self.assertEqual(resp.status_code, requests.codes.ok) self.assertEqual(resp.status_code, requests.codes.ok)
def test_index(self): 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').mkdir()
(pub / 'with-index' / 'index.html').write_text('<html>Hello !</html>') (pub / 'with-index' / 'index.html').write_text('<html>Hello !</html>')
self.assertEqual( self.assertEqual(
...@@ -106,10 +116,14 @@ class TestFileServer(SlapOSInstanceTestCase): ...@@ -106,10 +116,14 @@ class TestFileServer(SlapOSInstanceTestCase):
(pub / 'without-index' / 'file.txt').write_text('Hello !') (pub / 'without-index' / 'file.txt').write_text('Hello !')
self.assertIn( self.assertIn(
'file.txt', 'file.txt',
requests.get( [path['name'] for path in
urllib.parse.urljoin(self.connection_parameters['public-url'], 'without-index/'), self._decode_index_content(
verify=self.ca_cert, requests.get(
).text) urllib.parse.urljoin(self.connection_parameters['public-url'], 'without-index/'),
verify=self.ca_cert,
).text)['paths']
]
)
def test_upload_file_refused_without_auth(self): def test_upload_file_refused_without_auth(self):
parsed_upload_url = urllib.parse.urlparse(self.connection_parameters['upload-url']) parsed_upload_url = urllib.parse.urlparse(self.connection_parameters['upload-url'])
...@@ -168,7 +182,7 @@ class TestFileServer(SlapOSInstanceTestCase): ...@@ -168,7 +182,7 @@ class TestFileServer(SlapOSInstanceTestCase):
# reprocess instance to get the new certificate, after removing the timestamp # reprocess instance to get the new certificate, after removing the timestamp
# to force execution # to force execution
(pathlib.Path(self.computer_partition_root_path) / '.timestamp').unlink() (self.computer_partition_root_path / '.timestamp').unlink()
self.waitForInstance() self.waitForInstance()
cert_after = _getpeercert() 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