Merge "Makes sure that origin and domain cannot be same"
This commit is contained in:
commit
5e66d6e676
|
@ -16,6 +16,10 @@
|
||||||
import functools
|
import functools
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
try:
|
||||||
|
set
|
||||||
|
except NameError: # noqa pragma: no cover
|
||||||
|
from sets import Set as set # noqa pragma: no cover
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import jsonschema
|
import jsonschema
|
||||||
|
@ -248,6 +252,23 @@ def is_valid_service_configuration(service, schema):
|
||||||
if not re.match(domain_regex, domain_name):
|
if not re.match(domain_regex, domain_name):
|
||||||
raise exceptions.ValidationFailed(
|
raise exceptions.ValidationFailed(
|
||||||
u'Domain {0} is not valid'.format(domain_name))
|
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
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -616,5 +616,18 @@
|
||||||
"rules": [{"name" : "index",
|
"rules": [{"name" : "index",
|
||||||
"request_url" : "/index.htm"}]}],
|
"request_url" : "/index.htm"}]}],
|
||||||
"restrictions_list": []
|
"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": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue