Skip to content

Commit

Permalink
Merge pull request #493 from wazo-platform/WAZO-3988-wizard-nameserve…
Browse files Browse the repository at this point in the history
…r-parsing

wizard.service: Changed NAMESERVER_REGEX

to support tabs as separator

Reviewed-by: Sebastien Duthil
  • Loading branch information
wazo-community-zuul[bot] authored Dec 17, 2024
2 parents b539a25 + 4c09810 commit bfd26bb
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 bfd26bb

Please sign in to comment.