Added simple tldname regex test

This test was removed during a previous refactor.

Change-Id: Ief4d42625bc100d3a881163c684f86e010237f82
This commit is contained in:
Erik Olof Gunnar Andersson 2023-08-22 15:19:12 +02:00
parent 9d115c88a1
commit 0cf0ccd9d8
1 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,42 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import oslotest.base
from designate.common import constants
class TestRegex(oslotest.base.BaseTestCase):
def setUp(self):
super(TestRegex, self).setUp()
def test_tldname_is_valid(self):
valid_tldnames = [
'com',
'net',
'org',
'co.uk',
]
for tldname in valid_tldnames:
self.assertTrue(constants.RE_TLDNAME.match(tldname))
def test_tldname_is_not_valid(self):
invalid_tldnames = [
# Invalid Formats
'com.',
'.com',
# Trailing newline - Bug 1471158
"com\n",
]
for tldname in invalid_tldnames:
self.assertFalse(constants.RE_TLDNAME.match(tldname))