Commit f384d03d authored by Jérome Perrin's avatar Jérome Perrin

software/dufs: serve index.html files instead of directory index

parent 9ca4e938
...@@ -15,4 +15,4 @@ ...@@ -15,4 +15,4 @@
[instance.cfg.in] [instance.cfg.in]
filename = instance.cfg.in filename = instance.cfg.in
md5sum = 6edf5c64bf25dfd2e6e8a4e74c9b9812 md5sum = b7da4404a3a773a8aafb88ab9785ea72
...@@ -155,6 +155,7 @@ command-line = ...@@ -155,6 +155,7 @@ command-line =
--enable-cors --enable-cors
--bind ${:ip} --bind ${:ip}
--port ${:port} --port ${:port}
--render-try-index
--allow-all --allow-all
--auth-method basic --auth-method basic
--auth ${admin-password:user}:${admin-password:passwd}@/:rw --auth ${admin-password:user}:${admin-password:passwd}@/:rw
......
...@@ -91,6 +91,26 @@ class TestFileServer(SlapOSInstanceTestCase): ...@@ -91,6 +91,26 @@ class TestFileServer(SlapOSInstanceTestCase):
self.assertNotIn('secret', resp.text) self.assertNotIn('secret', resp.text)
self.assertEqual(resp.status_code, requests.codes.ok) self.assertEqual(resp.status_code, requests.codes.ok)
def test_index(self):
pub = pathlib.Path(self.computer_partition_root_path) / 'srv' / 'www' / 'pub'
(pub / 'with-index').mkdir()
(pub / 'with-index' / 'index.html').write_text('<html>Hello !</html>')
self.assertEqual(
requests.get(
urllib.parse.urljoin(self.connection_parameters['public-url'], 'with-index/'),
verify=self.ca_cert,
).text,
'<html>Hello !</html>')
(pub / 'without-index').mkdir()
(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)
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'])
# upload-url has username:password, remove it # upload-url has username:password, remove it
......
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