Fixing API test for new restriction model change
Change-Id: I72e1c96bd21fea54f727620f0650c69161829472
This commit is contained in:
parent
f45680a70a
commit
1844d882bf
|
@ -87,10 +87,9 @@ class Restriction(common.DictSerializableModel):
|
|||
:returns o
|
||||
"""
|
||||
|
||||
o = cls("unnamed", 'whitelist')
|
||||
o.restriction = dict_obj.get("restriction", "unnamed")
|
||||
r_type = dict_obj.get("type", 'whitelist')
|
||||
o = cls("unnamed", r_type)
|
||||
o.name = dict_obj.get("name", "unnamed")
|
||||
o.type = dict_obj.get("type")
|
||||
rules_dict_list = dict_obj.get("rules", [])
|
||||
o.rules = []
|
||||
for rule_dict in rules_dict_list:
|
||||
|
|
|
@ -372,6 +372,26 @@
|
|||
"request_url" : "/index.htm"}]}],
|
||||
"restrictions_list": [{}]
|
||||
},
|
||||
"restrictions_non_sense_type": {
|
||||
"service_name": "restrictions_type_not_black_or_whitelist_service_name",
|
||||
"domain_list": [{"domain": "mywebsite.com",
|
||||
"protocol": "http"},
|
||||
{"domain": "website.com", "protocol": "http"}],
|
||||
"origin_list": [{"origin": "mywebsite1.com",
|
||||
"port": 80,
|
||||
"ssl": false}],
|
||||
"caching_list": [{"name": "default", "ttl": 3600},
|
||||
{"name": "home",
|
||||
"ttl": 1200,
|
||||
"rules": [{"name" : "index",
|
||||
"request_url" : "/index.htm"}]}],
|
||||
"restrictions_list": [
|
||||
{"name": "test",
|
||||
"type": "nonsense",
|
||||
"rules": [{"name": "only me",
|
||||
"referrer": "www.mywebsite.com"}]}
|
||||
]
|
||||
},
|
||||
"http_domain_with_certificate": {
|
||||
"service_name": "my_service_name",
|
||||
"domain_list": [{"domain": "mywebsite.com",
|
||||
|
|
|
@ -173,6 +173,92 @@
|
|||
"restrictions": [
|
||||
{
|
||||
"name": "test",
|
||||
"type": "whitelist",
|
||||
"rules": [
|
||||
{
|
||||
"name": "only me",
|
||||
"referrer": "www.mywebsite.com",
|
||||
"request_url": "/*"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"restrictions_blacklist": {
|
||||
"submit_value": {
|
||||
"name": "my_service_name",
|
||||
"domain_list": [
|
||||
{
|
||||
"domain": "mywebsite.com",
|
||||
"protocol": "http"
|
||||
}
|
||||
],
|
||||
"origin_list": [
|
||||
{
|
||||
"origin": "mywebsite1.com",
|
||||
"port": 80,
|
||||
"ssl": false,
|
||||
"hostheadertype": "domain"
|
||||
}
|
||||
],
|
||||
"caching_list": [
|
||||
{
|
||||
"name": "default",
|
||||
"ttl": 3600
|
||||
}
|
||||
],
|
||||
"restrictions": [
|
||||
{
|
||||
"name": "test",
|
||||
"type": "blacklist",
|
||||
"rules": [
|
||||
{
|
||||
"name": "only me",
|
||||
"referrer": "www.mywebsite.com"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"expected_value": {
|
||||
"name": "my_service_name",
|
||||
"domain_list": [
|
||||
{
|
||||
"domain": "mywebsite.com",
|
||||
"protocol": "http"
|
||||
}
|
||||
],
|
||||
"origin_list": [
|
||||
{
|
||||
"origin": "mywebsite1.com",
|
||||
"port": 80,
|
||||
"ssl": false,
|
||||
"rules": [
|
||||
{
|
||||
"name" : "default",
|
||||
"request_url" : "/*"
|
||||
}
|
||||
],
|
||||
"hostheadertype": "domain"
|
||||
}
|
||||
],
|
||||
"caching_list": [
|
||||
{
|
||||
"name": "default",
|
||||
"ttl": 3600,
|
||||
"rules": [
|
||||
{
|
||||
"name" : "default",
|
||||
"request_url" : "/*"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"restrictions": [
|
||||
{
|
||||
"name": "test",
|
||||
"type": "blacklist",
|
||||
"rules": [
|
||||
{
|
||||
"name": "only me",
|
||||
|
@ -256,6 +342,7 @@
|
|||
"restrictions": [
|
||||
{
|
||||
"name": "test",
|
||||
"type": "whitelist",
|
||||
"rules": [
|
||||
{
|
||||
"name": "only me",
|
||||
|
@ -340,6 +427,7 @@
|
|||
"restrictions": [
|
||||
{
|
||||
"name": "test",
|
||||
"type": "whitelist",
|
||||
"rules": [
|
||||
{
|
||||
"name": "only me",
|
||||
|
@ -425,6 +513,7 @@
|
|||
"restrictions": [
|
||||
{
|
||||
"name": "test",
|
||||
"type": "whitelist",
|
||||
"rules": [
|
||||
{
|
||||
"name": "only me",
|
||||
|
|
|
@ -204,6 +204,41 @@
|
|||
}
|
||||
}
|
||||
],
|
||||
"replace_restrictions_white_to_blacklist":[
|
||||
{"op": "replace",
|
||||
"path": "/restrictions/0",
|
||||
"value": {"name": "new_restricted",
|
||||
"type": "blacklist",
|
||||
"rules": [{"name": "rule1", "referrer": "www.thesite.com", "request_url": "/images2/*"}]
|
||||
}}
|
||||
],
|
||||
"replace_restrictions_black_to_whitelist":[
|
||||
{"op": "add",
|
||||
"path": "/restrictions/-",
|
||||
"value": {"name": "restricted",
|
||||
"type": "blacklist",
|
||||
"rules": [{"name": "rule1", "referrer": "www.thesite.com", "request_url": "/images3/*"}]
|
||||
}},
|
||||
{"op": "replace",
|
||||
"path": "/restrictions/1",
|
||||
"value": {"name": "new_restricted",
|
||||
"type": "whitelist",
|
||||
"rules": [{"name": "rule1", "referrer": "www.thesite.com", "request_url": "/images3/*"}]
|
||||
}}
|
||||
],
|
||||
"replace_restrictions_black_to_default":[
|
||||
{"op": "add",
|
||||
"path": "/restrictions/-",
|
||||
"value": {"name": "restricted",
|
||||
"type": "blacklist",
|
||||
"rules": [{"name": "rule1", "referrer": "www.thesite.com", "request_url": "/images3/*"}]
|
||||
}},
|
||||
{"op": "replace",
|
||||
"path": "/restrictions/1",
|
||||
"value": {"name": "new_restricted",
|
||||
"rules": [{"name": "rule1", "referrer": "www.thesite.com", "request_url": "/images3/*"}]
|
||||
}}
|
||||
]
|
||||
"add_restrictions_with_minimum_length_rule_name": [
|
||||
{"op": "add",
|
||||
"path": "/restrictions/-",
|
||||
|
|
|
@ -83,6 +83,7 @@ class TestServicePatch(base.TestBase):
|
|||
|
||||
self.restrictions_list = [
|
||||
{"name": "website only",
|
||||
"type": "whitelist",
|
||||
"rules": [{"name": "mywebsite.com",
|
||||
"referrer": "www.mywebsite.com",
|
||||
"request_url": "/*"
|
||||
|
@ -139,6 +140,12 @@ class TestServicePatch(base.TestBase):
|
|||
if 'hostheadertype' not in item:
|
||||
item['hostheadertype'] = 'domain'
|
||||
|
||||
# Default restriciton to whitelist
|
||||
expected_restrictions = expected_service_details['restrictions']
|
||||
for restriction in expected_restrictions:
|
||||
if 'type' not in restriction:
|
||||
restriction['type'] = 'whitelist'
|
||||
|
||||
resp = self.client.patch_service(location=self.service_url,
|
||||
request_body=test_data)
|
||||
self.assertEqual(resp.status_code, 202)
|
||||
|
@ -357,6 +364,7 @@ class TestServicePatchWithLogDelivery(base.TestBase):
|
|||
|
||||
self.restrictions_list = [
|
||||
{"name": "website only",
|
||||
"type": "whitelist",
|
||||
"rules": [{"name": "mywebsite.com",
|
||||
"referrer": "www.mywebsite.com",
|
||||
"request_url": "/*"
|
||||
|
|
Loading…
Reference in New Issue