mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +00:00
- Change the mechanism for storing domain names in /etc/hosts. Don't write hostname to /etc/hosts. Don't prepend hostname to domain name. This means that when hostname changes, set_domain_name need not be called. - This means that domain names such as example.fbx.one were not resolvable using /etc/hosts but these will now resolve to 127.0.1.1. This is a minor concern to becoming a breaking change. - Don't use socket.getfqdn() for finding the domain name of the machine. Instead read from /etc/hosts. There does not seem to a glibc/python API for querying domain names from /etc/hosts with all variations it allows. Forward resolution properly works no matter the library. - Drop a pre-Python 3 conversion from unicode to ascii string for hostname. This is no longer relevant. - Domain name form is now domain add form. Passing domain name is mandatory. Domain delete form and view have been introduced. - Use augeas to edit hosts file. Add privileged methods to add/delete/get domains. Add method to migration from old format to new. Support reading old format too in get_domains. Tests: - Without hostname written in /etc/hosts, 'resolvectl query <hostname>' and 'ping <hostname>' work. - With old /etc/hosts format apply patches and restart service. It will be converted to new format. - Adding a domain adds a new line to /etc/hosts file. The domain is shown in domains list in Names app. Applications get reconfigured with the new domain name. - Deleting a domain adds a new line to /etc/hosts file. The domain is shown in domains list in Names app. Applications get reconfigured with the new domain name. - Restarting app triggers domain added signal for all domains and all the domains are shown in the Names app. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""Functional, browser based tests for names app."""
|
|
|
|
import pytest
|
|
|
|
from plinth.tests import functional
|
|
|
|
pytestmark = [
|
|
pytest.mark.system, pytest.mark.essential, pytest.mark.domain,
|
|
pytest.mark.names
|
|
]
|
|
|
|
|
|
@pytest.fixture(scope='module', autouse=True)
|
|
def fixture_background(session_browser):
|
|
"""Login."""
|
|
functional.login(session_browser)
|
|
|
|
|
|
def test_change_hostname(session_browser):
|
|
"""Test changing the hostname."""
|
|
functional.set_hostname(session_browser, 'mybox')
|
|
assert _get_hostname(session_browser) == 'mybox'
|
|
|
|
|
|
def _get_hostname(browser):
|
|
functional.visit(browser, '/plinth/sys/names/hostname/')
|
|
return browser.find_by_id('id_hostname-hostname').value
|
|
|
|
|
|
def test_change_domain_name(session_browser):
|
|
"""Test changing the domain name."""
|
|
functional.domain_remove(session_browser, 'mydomain.example')
|
|
functional.domain_add(session_browser, 'mydomain.example')
|
|
assert 'mydomain.example' in functional.domain_list(session_browser)
|
|
|
|
# Capitalization is ignored.
|
|
functional.domain_remove(session_browser, 'mydomain2.example')
|
|
functional.domain_add(session_browser, 'Mydomain2.example')
|
|
assert 'mydomain2.example' in functional.domain_list(session_browser)
|