config, names: Move setting hostname from config to names

Tests:

- Config app description is as expected.
- Config form does not show hostname anymore.
  - Submitting the form with changes works.
- Names app has correct link for configuring Local Domain Name. Clicking it
  takes to page for setting hostname.
- Avahi shows the current .local domain correctly in Names app.
- Change hostname form shows correct value for current hostname.
- Change hostname form sets the value for hostname properly.
  - Page title is correct.
  - Validations works.
  - Pre/post hostname change signals are sent properly
  - Success message as shown expected
  - hostnamectl shows the set domain
- If domain name is not set, downloaded OpenVPN profile shows hostname.
- Unit tests work.
- Functional tests on names/config/avahi apps work.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Sunil Mohan Adapa authored and Veiko Aasa committed 2024-09-19 13:42:47 +03:00
1 parent dceee56684
commit 8c69858d43
16 files changed
+173 -120

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""Tests for forms in names app."""
from ..forms import HostnameForm
def test_hostname_field():
"""Test that hostname field accepts only valid hostnames."""
valid_hostnames = [
'a', '0a', 'a0', 'AAA', '00', '0-0', 'example-hostname', 'example',
'012345678901234567890123456789012345678901234567890123456789012'
]
invalid_hostnames = [
'', '-', '-a', 'a-', '.a', 'a.', 'a.a', '?', 'a?a',
'0123456789012345678901234567890123456789012345678901234567890123'
]
for hostname in valid_hostnames:
form = HostnameForm({'hostname': hostname})
assert form.is_valid()
for hostname in invalid_hostnames:
form = HostnameForm({'hostname': hostname})
assert not form.is_valid()