mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
dynamicdns: Convert entered domain name to lower case
Domain name is not case sensitive, but Let's Encrypt certificate paths use lower-case domain name. Add an extra 1 second delay to tests that configure DynamicDNS domain. Test: DynamicDNS functional tests are passing. Signed-off-by: James Valleroy <jvalleroy@mailbox.org> Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
parent
bdd078a406
commit
929e7626f0
@ -14,6 +14,11 @@ Background:
|
||||
Given I'm a logged in user
|
||||
And the dynamicdns application is installed
|
||||
|
||||
Scenario: Capitalized domain name
|
||||
Given dynamicdns is configured
|
||||
When I change the domain name to FreedomBox.example.com
|
||||
Then the domain name should be freedombox.example.com
|
||||
|
||||
@backups
|
||||
Scenario: Backup and restore configuration
|
||||
Given dynamicdns is configured
|
||||
|
||||
@ -3,7 +3,9 @@
|
||||
Functional, browser based tests for dynamicdns app.
|
||||
"""
|
||||
|
||||
from pytest_bdd import given, scenarios, then, when
|
||||
import time
|
||||
|
||||
from pytest_bdd import given, parsers, scenarios, then, when
|
||||
|
||||
from plinth.tests import functional
|
||||
|
||||
@ -20,11 +22,21 @@ def dynamicdns_change_config(session_browser):
|
||||
_change_config(session_browser)
|
||||
|
||||
|
||||
@when(parsers.parse('I change the domain name to {domain:S}'))
|
||||
def dynamicdns_change_domain(session_browser, domain):
|
||||
_configure_domain(session_browser, domain)
|
||||
|
||||
|
||||
@then('dynamicdns should have the original configuration')
|
||||
def dynamicdns_has_original_config(session_browser):
|
||||
assert _has_original_config(session_browser)
|
||||
|
||||
|
||||
@then(parsers.parse('the domain name should be {domain:S}'))
|
||||
def dynamicdns_has_domain(session_browser, domain):
|
||||
assert _get_domain(session_browser) == domain
|
||||
|
||||
|
||||
def _configure(browser):
|
||||
functional.nav_to_module(browser, 'dynamicdns')
|
||||
browser.find_link_by_href(
|
||||
@ -41,6 +53,7 @@ def _configure(browser):
|
||||
|
||||
# After a domain name change, Let's Encrypt will restart the web
|
||||
# server and could cause a connection failure.
|
||||
time.sleep(1)
|
||||
functional.eventually(functional.nav_to_module, [browser, 'dynamicdns'])
|
||||
|
||||
|
||||
@ -78,4 +91,25 @@ def _change_config(browser):
|
||||
|
||||
# After a domain name change, Let's Encrypt will restart the web
|
||||
# server and could cause a connection failure.
|
||||
time.sleep(1)
|
||||
functional.eventually(functional.nav_to_module, [browser, 'dynamicdns'])
|
||||
|
||||
|
||||
def _configure_domain(browser, domain):
|
||||
functional.nav_to_module(browser, 'dynamicdns')
|
||||
browser.find_link_by_href(
|
||||
'/plinth/sys/dynamicdns/configure/').first.click()
|
||||
browser.find_by_id('id_dynamicdns_domain').fill(domain)
|
||||
functional.submit(browser)
|
||||
|
||||
# After a domain name change, Let's Encrypt will restart the web
|
||||
# server and could cause a connection failure.
|
||||
time.sleep(1)
|
||||
functional.eventually(functional.nav_to_module, [browser, 'dynamicdns'])
|
||||
|
||||
|
||||
def _get_domain(browser):
|
||||
functional.nav_to_module(browser, 'dynamicdns')
|
||||
browser.find_link_by_href(
|
||||
'/plinth/sys/dynamicdns/configure/').first.click()
|
||||
return browser.find_by_id('id_dynamicdns_domain').value
|
||||
|
||||
@ -129,13 +129,33 @@ def _apply_changes(request, old_status, new_status):
|
||||
if new_status.get('use_ipv6'):
|
||||
use_ipv6 = "enabled"
|
||||
|
||||
# Domain name should be ASCII. If it's unicode, convert to
|
||||
# ASCII.
|
||||
new_domain_name = str(new_status['dynamicdns_domain'])
|
||||
|
||||
# Domain name is not case sensitive, but Let's Encrypt
|
||||
# certificate paths use lower-case domain name.
|
||||
new_domain_name = new_domain_name.lower()
|
||||
|
||||
_run([
|
||||
'configure', '-s', new_status['dynamicdns_server'], '-d',
|
||||
new_status['dynamicdns_domain'], '-u',
|
||||
new_status['dynamicdns_user'], '-p', '-I',
|
||||
new_status['dynamicdns_ipurl'], '-U',
|
||||
new_status['dynamicdns_update_url'], '-c', disable_ssl_check, '-b',
|
||||
use_http_basic_auth, '-6', use_ipv6,
|
||||
'configure',
|
||||
'-s',
|
||||
new_status['dynamicdns_server'],
|
||||
'-d',
|
||||
new_domain_name,
|
||||
'-u',
|
||||
new_status['dynamicdns_user'],
|
||||
'-p',
|
||||
'-I',
|
||||
new_status['dynamicdns_ipurl'],
|
||||
'-U',
|
||||
new_status['dynamicdns_update_url'],
|
||||
'-c',
|
||||
disable_ssl_check,
|
||||
'-b',
|
||||
use_http_basic_auth,
|
||||
'-6',
|
||||
use_ipv6,
|
||||
], input=new_status['dynamicdns_secret'].encode())
|
||||
|
||||
if old_status['enabled']:
|
||||
@ -147,8 +167,7 @@ def _apply_changes(request, old_status, new_status):
|
||||
if new_status['enabled']:
|
||||
domain_added.send_robust(sender='dynamicdns',
|
||||
domain_type='domain-type-dynamic',
|
||||
name=new_status['dynamicdns_domain'],
|
||||
services='__all__')
|
||||
name=new_domain_name, services='__all__')
|
||||
_run(['start'])
|
||||
|
||||
messages.success(request, _('Configuration updated'))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user