Add a deprecation warning for the "objects" property of
observed-data. Add a unit test to ensure we get the warning.master
							parent
							
								
									9404cf4560
								
							
						
					
					
						commit
						27beec4060
					
				|  | @ -1375,3 +1375,18 @@ def test_new_version_with_related_objects(): | |||
|     new_version = data.new_version(last_observed="2017-12-12T12:00:00Z") | ||||
|     assert new_version.last_observed.year == 2017 | ||||
|     assert new_version.objects['domain'].resolves_to_refs[0] == 'src_ip' | ||||
| 
 | ||||
| 
 | ||||
| def test_objects_deprecation(): | ||||
|     with pytest.deprecated_call(): | ||||
|         stix2.v21.ObservedData( | ||||
|             first_observed="2016-03-12T12:00:00Z", | ||||
|             last_observed="2016-03-12T12:00:00Z", | ||||
|             number_observed=1, | ||||
|             objects={ | ||||
|                 "0": { | ||||
|                     "type": "file", | ||||
|                     "name": "foo", | ||||
|                 }, | ||||
|             }, | ||||
|         ) | ||||
|  |  | |||
|  | @ -2,6 +2,7 @@ | |||
| 
 | ||||
| from collections import OrderedDict | ||||
| import itertools | ||||
| import warnings | ||||
| 
 | ||||
| from six.moves.urllib.parse import quote_plus | ||||
| 
 | ||||
|  | @ -573,6 +574,13 @@ class ObservedData(STIXDomainObject): | |||
|         self.__allow_custom = kwargs.get('allow_custom', False) | ||||
|         self._properties['objects'].allow_custom = kwargs.get('allow_custom', False) | ||||
| 
 | ||||
|         if "objects" in kwargs: | ||||
|             warnings.warn( | ||||
|                 "The 'objects' property of observed-data is deprecated in " | ||||
|                 "STIX 2.1.", | ||||
|                 DeprecationWarning, | ||||
|             ) | ||||
| 
 | ||||
|         super(ObservedData, self).__init__(*args, **kwargs) | ||||
| 
 | ||||
|     def _check_object_constraints(self): | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Michael Chisholm
						Michael Chisholm