Merge "fix: Validate length of domain in get_service_by_domain"

This commit is contained in:
Jenkins 2015-07-27 19:10:44 +00:00 committed by Gerrit Code Review
commit e18e44e2cb
2 changed files with 9 additions and 1 deletions

View File

@ -393,6 +393,14 @@ def is_valid_domain_by_name(domain_name):
# shared ssl domain
shared_ssl_domain_regex = '^[a-z0-9][a-z0-9-]{0,62}[a-z0-9]?$'
if len(domain_name) > 253:
raise exceptions.ValidationFailed(
u'Domain {0} is too long'.format(domain_name))
if len(domain_name) < 3:
raise exceptions.ValidationFailed(
u'Domain {0} is too short'.format(domain_name))
if not re.match(domain_regex, domain_name):
if not re.match(shared_ssl_domain_regex, domain_name):
raise exceptions.ValidationFailed(

View File

@ -165,7 +165,7 @@ class TestGetServiceByDomain(base.TestBase):
"_long_name_too_long_name_too_long_name_too_long_name_too_" \
"long_name.com"
resp = self.operator_client.admin_get_service_by_domain_name(domain)
self.assertEqual(resp.status_code, 404)
self.assertEqual(resp.status_code, 400)
def tearDown(self):
self.client.delete_service(location=self.service_url)