Merge pull request #2103 from mikegrima/config
Fixed validation bugs in put_configuration_recorder
This commit is contained in:
commit
53b94606de
@ -166,21 +166,23 @@ class ConfigBackend(BaseBackend):
|
|||||||
recorder_status = self.recorders[config_recorder['name']].status
|
recorder_status = self.recorders[config_recorder['name']].status
|
||||||
|
|
||||||
# Validate the Recording Group:
|
# Validate the Recording Group:
|
||||||
if not config_recorder.get('recordingGroup'):
|
if config_recorder.get('recordingGroup') is None:
|
||||||
recording_group = RecordingGroup()
|
recording_group = RecordingGroup()
|
||||||
else:
|
else:
|
||||||
rg = config_recorder['recordingGroup']
|
rg = config_recorder['recordingGroup']
|
||||||
|
|
||||||
|
# If an empty dict is passed in, then bad:
|
||||||
|
if not rg:
|
||||||
|
raise InvalidRecordingGroupException()
|
||||||
|
|
||||||
# Can't have both the resource types specified and the other flags as True.
|
# Can't have both the resource types specified and the other flags as True.
|
||||||
if rg.get('resourceTypes') and (
|
if rg.get('resourceTypes') and (
|
||||||
rg.get('allSupported', True) or
|
rg.get('allSupported', False) or
|
||||||
rg.get('includeGlobalResourceTypes', False)):
|
rg.get('includeGlobalResourceTypes', False)):
|
||||||
raise InvalidRecordingGroupException()
|
raise InvalidRecordingGroupException()
|
||||||
|
|
||||||
# If an empty dict is provided, then bad:
|
# Must supply resourceTypes if 'allSupported' is not supplied:
|
||||||
if not rg.get('resourceTypes', False) \
|
if not rg.get('allSupported') and not rg.get('resourceTypes'):
|
||||||
and not rg.get('resourceTypes') \
|
|
||||||
and not rg.get('includeGlobalResourceTypes', False):
|
|
||||||
raise InvalidRecordingGroupException()
|
raise InvalidRecordingGroupException()
|
||||||
|
|
||||||
# Validate that the list provided is correct:
|
# Validate that the list provided is correct:
|
||||||
|
@ -28,7 +28,11 @@ def test_put_configuration_recorder():
|
|||||||
{'allSupported': True, 'includeGlobalResourceTypes': True, 'resourceTypes': ['item']},
|
{'allSupported': True, 'includeGlobalResourceTypes': True, 'resourceTypes': ['item']},
|
||||||
{'allSupported': False, 'includeGlobalResourceTypes': True, 'resourceTypes': ['item']},
|
{'allSupported': False, 'includeGlobalResourceTypes': True, 'resourceTypes': ['item']},
|
||||||
{'allSupported': True, 'includeGlobalResourceTypes': False, 'resourceTypes': ['item']},
|
{'allSupported': True, 'includeGlobalResourceTypes': False, 'resourceTypes': ['item']},
|
||||||
{'allSupported': False, 'includeGlobalResourceTypes': False, 'resourceTypes': []}
|
{'allSupported': False, 'includeGlobalResourceTypes': False, 'resourceTypes': []},
|
||||||
|
{'includeGlobalResourceTypes': False, 'resourceTypes': []},
|
||||||
|
{'includeGlobalResourceTypes': True},
|
||||||
|
{'resourceTypes': []},
|
||||||
|
{}
|
||||||
]
|
]
|
||||||
|
|
||||||
for bg in bad_groups:
|
for bg in bad_groups:
|
||||||
|
Loading…
Reference in New Issue
Block a user