Merge "Makes sure that origin and domain cannot be same"

This commit is contained in:
Jenkins 2015-06-02 18:41:53 +00:00 committed by Gerrit Code Review
commit 5e66d6e676
2 changed files with 34 additions and 0 deletions

View File

@ -16,6 +16,10 @@
import functools
import json
import re
try:
set
except NameError: # noqa pragma: no cover
from sets import Set as set # noqa pragma: no cover
import uuid
import jsonschema
@ -248,6 +252,23 @@ def is_valid_service_configuration(service, schema):
if not re.match(domain_regex, domain_name):
raise exceptions.ValidationFailed(
u'Domain {0} is not valid'.format(domain_name))
# 8. origins and domains cannot be the same
if 'origins' in service and 'domains' in service:
origins = set()
for origin in service['origins']:
origin_name = origin.get('origin').lower().strip()
origins.add(origin_name)
domains = set()
for domain in service['domains']:
domain_name = domain.get('domain').lower().strip()
domains.add(domain_name)
if origins.intersection(domains):
raise exceptions.ValidationFailed(
u'Domains and origins cannot be same: {0}'.format(origin))
return

View File

@ -616,5 +616,18 @@
"rules": [{"name" : "index",
"request_url" : "/index.htm"}]}],
"restrictions_list": []
},
"same_domain_and_origin": {
"service_name": "same_domain_and_origin",
"domain_list": [{"domain": "mywebsite.com "}],
"origin_list": [{"origin": "mywebsite.com",
"port": 80,
"ssl": false}],
"caching_list": [{"name": "default", "ttl": 3600},
{"name": "home",
"ttl": 1200,
"rules": [{"name" : "index",
"request_url" : "/index.htm"}]}],
"restrictions_list": []
}
}