config: Fix showing the value of the default home page

Closes: #2314.

Tests:

- On a fresh testing container, verify that the file
/etc/apache2/conf-available/freedombox-apache-homepage.conf is not present.
Visit the config app and notice that home page shows as 'Apache Default'.

- Apply the patch and refresh the page. The page now shows 'FreedomBox
Service (Plinth)' as the home page.

- Functional tests work.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2023-01-29 07:22:54 -08:00 committed by James Valleroy
parent 9597654ca8
commit f394beb2ef
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 7 additions and 1 deletions

View File

@ -105,6 +105,12 @@ def get_hostname():
def home_page_url2scid(url):
"""Return the shortcut ID of the given home page url."""
# url is None when the freedombox-apache-homepage configuration file does
# not exist. In this case, the default redirect in /plinth from the shipped
# configuration file is effective.
if url is None:
return 'plinth'
if url in ('/plinth/', '/plinth', 'plinth'):
return 'plinth'

View File

@ -76,7 +76,7 @@ def test_domainname_field():
def test_homepage_mapping():
"""Basic tests for homepage functions."""
func = home_page_url2scid
assert func(None) is None
assert func(None) == 'plinth'
assert func('/unknown/url') is None
assert func('/plinth/') == 'plinth'
assert func('/plinth') == 'plinth'