config: Allow better Apache default home page

- Don't redirect to '/index.html' when Apache Default is set as the home page.
This allows having other files such as 'index.php' as index file in
/var/www/html/.

- If the home page is currently set to 'Apache Default' upgrade the
configuration.

Tests:

- With Home page set to 'Apache Default' apply the patches. Config setup is
re-run. The configuration file becomes empty but is still present. Correctly
value is shown in the UI. /var/www/html/index.html is still shown as the home
page.

- With Home page set to 'Bepasty' apply the patches. Config setup is re-reun.
The configuration file is not modified. Bepasty is still shown as the home page.
Correctly value is shown in the UI.

- With Home page not modified apply the patches. Config setup is re-reun. The
configuration file is created. FreedomBox is the home page. Correctly value is
shown in the UI.

- On fresh machine with patches applied, perform first run. The configuration
file is not created. FreedomBox is the home page. Correctly value is shown in
the UI.

- Changing home page to Bepasty or 'Apache Default' works. Changing back to
'FreedomBox Service (Plinth)' also works.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2025-05-30 15:14:50 -04:00
1 parent 007d8de346
commit 298bb5ae58
4 files changed
+37 -28

No files matched your search

+2 -3
View File
@@ -17,7 +17,7 @@ from plinth.modules.config import (_home_page_scid2url, change_home_page,
def test_homepage_mapping():
"""Basic tests for homepage functions."""
func = home_page_url2scid
assert func(None) == 'plinth'
assert func(None) == 'apache-default'
assert func('/unknown/url') is None
assert func('/plinth/') == 'plinth'
assert func('/plinth') == 'plinth'
@@ -27,9 +27,8 @@ def test_homepage_mapping():
assert func('/~user/whatever/else') == 'uws-user'
func = _home_page_scid2url
assert func(None) is None
assert func('plinth') == '/plinth/'
assert func('apache-default') == '/index.html'
assert func('apache-default') is None
def test_homepage_mapping_skip_ci():