Skip to content

Commit

Permalink
wizard.service: Changed NAMESERVER_REGEX
Browse files Browse the repository at this point in the history
to support tabs as separator
  • Loading branch information
DrPyser committed Dec 17, 2024
1 parent b539a25 commit 4c09810
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion wazo_confd/plugins/wizard/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from .validator import build_validator

USERNAME_VALUES = '2346789bcdfghjkmnpqrtvwxyzBCDFGHJKLMNPQRTVWXYZ'
NAMESERVER_REGEX = r'^nameserver (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})'
NAMESERVER_REGEX = r'^nameserver\s(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})'
DEFAULT_ROOT_POLICY = 'wazo_default_master_user_policy'
ASTERISK_AUTOPROV_CONFIG_FILENAME = '/etc/asterisk/pjsip.d/05-autoprov-wizard.conf'
ASTERISK_AUTOPROV_CONFIG_TPL = '''\
Expand Down
18 changes: 18 additions & 0 deletions wazo_confd/plugins/wizard/tests/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,24 @@ def test_get_nameservers(self):
mopen.assert_called_once_with('/etc/resolv.conf', 'r')
assert_that(result, equal_to(expected_result))

def test_get_nameservers_with_tabs(self):
resolv_conf = dedent(
'''
search\texample.com
nameserver\t192.168.2.0
nameserver\t192.168.2.1'''
)
expected_result = ['192.168.2.0', '192.168.2.1']
with patch(
'wazo_confd.plugins.wizard.service.open',
mock_open(read_data=resolv_conf),
create=True,
) as mopen:
result = self.service.get_nameservers()

mopen.assert_called_once_with('/etc/resolv.conf', 'r')
assert_that(result, equal_to(expected_result))

@patch('wazo_confd.plugins.wizard.service.open', create=True)
def test_get_nameservers_return_none_if_no_file(self, mopen):
mopen.side_effect = IOError()
Expand Down

0 comments on commit 4c09810

Please sign in to comment.