Example #1
0
 def test_ssd_information_type(self):
     object_item_1_json = {'objectAssertions': {'systemSupplementalDescriptions': [{}]}}
     object_item_2_json = {'objectAssertions': {'systemSupplementalDescriptions': [{'informationType': 'other'}]}}
     ties_json = {'version': '0.1.8', 'objectItem': [object_item_1_json, object_item_2_json]}
     _0_dot_2_to_0_dot_3(ties_json, 'U')
     self.assertEqual(object_item_1_json['objectAssertions']['systemSupplementalDescriptions'][0]['informationType'], 'triageSupplemental')
     self.assertEqual(object_item_2_json['objectAssertions']['systemSupplementalDescriptions'][0]['informationType'], 'other')
Example #2
0
 def test_annotation_value_minimum_length(self):
     object_item_1_json = {'objectAssertions': {'annotations': [{'value': ''}]}}
     object_item_2_json = {'objectAssertions': {'annotations': [{'value': 'other'}]}}
     ties_json = {'version': '0.1.8', 'objectItem': [object_item_1_json, object_item_2_json]}
     _0_dot_2_to_0_dot_3(ties_json, 'U')
     self.assertEqual(object_item_1_json['objectAssertions']['annotations'][0]['value'], ' ')
     self.assertEqual(object_item_2_json['objectAssertions']['annotations'][0]['value'], 'other')
Example #3
0
 def test_object_item_expiration_date_bad_format(self):
     object_item_1_json = {'authorityInformation': {'expirationDate': '1970-01-01T:00:00:00Z'}}
     object_item_2_json = {'authorityInformation': {}}
     object_item_3_json = {}
     ties_json = {'version': '0.1.8', 'objectItem': [object_item_1_json, object_item_2_json, object_item_3_json]}
     _0_dot_2_to_0_dot_3(ties_json, 'U')
     self.assertEqual(object_item_1_json['authorityInformation']['expirationDate'], '1970-01-01T00:00:00Z')
     self.assertTrue('expirationDate' not in object_item_2_json['authorityInformation'])
     self.assertTrue('expirationDate' not in object_item_3_json['authorityInformation'])
Example #4
0
 def test_ssd_data_hash_rename(self):
     object_item_1_json = {'objectAssertions': {'systemSupplementalDescriptions': [{'dataHash': ''}]}}
     object_item_2_json = {'objectAssertions': {'systemSupplementalDescriptions': [{}]}}
     ties_json = {'version': '0.1.8', 'objectItem': [object_item_1_json, object_item_2_json]}
     _0_dot_2_to_0_dot_3(ties_json, 'U')
     self.assertTrue('dataHash' not in object_item_1_json['objectAssertions']['systemSupplementalDescriptions'][0])
     self.assertTrue('sha256DataHash' in object_item_1_json['objectAssertions']['systemSupplementalDescriptions'][0])
     self.assertTrue('dataHash' not in object_item_2_json['objectAssertions']['systemSupplementalDescriptions'][0])
     self.assertTrue('sha256DataHash' not in object_item_2_json['objectAssertions']['systemSupplementalDescriptions'][0])
Example #5
0
 def test_object_item_system_identifier_rename(self):
     object_item_1_json = {'systemIdentifier': ''}
     object_item_2_json = {}
     ties_json = {'version': '0.1.8', 'objectItem': [object_item_1_json, object_item_2_json]}
     _0_dot_2_to_0_dot_3(ties_json, 'U')
     self.assertTrue('systemIdentifier' not in object_item_1_json)
     self.assertTrue('systemId' in object_item_1_json)
     self.assertTrue('systemIdentifier' not in object_item_2_json)
     self.assertTrue('systemId' not in object_item_2_json)
Example #6
0
 def test_object_relationship_linkage_assertion_id_rename(self):
     object_item_1_json = {'objectRelationships': [{'linkageAssertId': ''}]}
     object_item_2_json = {'objectRelationships': [{}]}
     ties_json = {'version': '0.1.8', 'objectItem': [object_item_1_json, object_item_2_json]}
     _0_dot_2_to_0_dot_3(ties_json, 'U')
     self.assertTrue('linkageAssertId' not in object_item_1_json['objectRelationships'][0])
     self.assertTrue('linkageAssertionId' in object_item_1_json['objectRelationships'][0])
     self.assertTrue('linkageAssertId' not in object_item_2_json['objectRelationships'][0])
     self.assertTrue('linkageAssertionId' not in object_item_2_json['objectRelationships'][0])
Example #7
0
 def test_object_item_relative_uri_rename(self):
     object_item_1_json = {'relativeURI': ''}
     object_item_2_json = {}
     ties_json = {'version': '0.1.8', 'objectItem': [object_item_1_json, object_item_2_json]}
     _0_dot_2_to_0_dot_3(ties_json, 'U')
     self.assertTrue('relativeURI' not in object_item_1_json)
     self.assertTrue('relativeUri' in object_item_1_json)
     self.assertTrue('relativeURI' not in object_item_2_json)
     self.assertTrue('relativeUri' not in object_item_2_json)
Example #8
0
 def test_object_item_security_tag(self):
     object_item_1_json = {'authorityInformation': {'securityTag': 'UNCLASSIFIED'}}
     object_item_2_json = {'authorityInformation': {}}
     object_item_3_json = {}
     ties_json = {'version': '0.1.8', 'objectItem': [object_item_1_json, object_item_2_json, object_item_3_json]}
     _0_dot_2_to_0_dot_3(ties_json, 'U')
     self.assertEqual(object_item_1_json['authorityInformation']['securityTag'], 'UNCLASSIFIED')
     self.assertEqual(object_item_2_json['authorityInformation']['securityTag'], 'U')
     self.assertEqual(object_item_3_json['authorityInformation']['securityTag'], 'U')
Example #9
0
 def test_ssd_security_tag(self):
     object_item_1_json = {'objectAssertions': {'systemSupplementalDescriptions': [{'securityTag': 'UNCLASSIFIED'}]}}
     object_item_2_json = {'objectAssertions': {'systemSupplementalDescriptions': [{}]}}
     object_item_3_json = {'objectAssertions': {'systemSupplementalDescriptions': []}}
     object_item_4_json = {'objectAssertions': {}}
     object_item_5_json = {}
     ties_json = {'version': '0.1.8', 'objectItem': [object_item_1_json, object_item_2_json, object_item_3_json, object_item_4_json, object_item_5_json]}
     _0_dot_2_to_0_dot_3(ties_json, 'U')
     self.assertEqual(object_item_1_json['objectAssertions']['systemSupplementalDescriptions'][0]['securityTag'], 'UNCLASSIFIED')
     self.assertEqual(object_item_2_json['objectAssertions']['systemSupplementalDescriptions'][0]['securityTag'], 'U')
     self.assertEqual(len(object_item_3_json['objectAssertions']['systemSupplementalDescriptions']), 0)
     self.assertTrue('systemSupplementalDescriptions' not in object_item_4_json['objectAssertions'])
     self.assertTrue('objectAssertions' not in object_item_5_json)
Example #10
0
 def test_annotation_item_action_time_bad_format(self):
     object_item_1_json = {'objectAssertions': {'annotations': [{'itemActionTime': '1970-01-01T:00:00:00Z'}]}}
     object_item_2_json = {'objectAssertions': {'annotations': [{}]}}
     object_item_3_json = {'objectAssertions': {'annotations': []}}
     object_item_4_json = {'objectAssertions': {}}
     object_item_5_json = {}
     ties_json = {'version': '0.1.8', 'objectItem': [object_item_1_json, object_item_2_json, object_item_3_json, object_item_4_json, object_item_5_json]}
     _0_dot_2_to_0_dot_3(ties_json, 'U')
     self.assertEqual(object_item_1_json['objectAssertions']['annotations'][0]['itemActionTime'], '1970-01-01T00:00:00Z')
     self.assertTrue('itemActionTime' not in object_item_2_json['objectAssertions']['annotations'][0])
     self.assertEqual(len(object_item_3_json['objectAssertions']['annotations']), 0)
     self.assertTrue('annotations' not in object_item_4_json['objectAssertions'])
     self.assertTrue('objectAssertions' not in object_item_5_json)
Example #11
0
 def test_security_tag_none_0_dot_1_dot_8(self):
     ties_json = {'version': '0.1.8'}
     with self.assertRaises(ValueError):
         _0_dot_2_to_0_dot_3(ties_json, None)
Example #12
0
 def test_time_bad_format(self):
     ties_json = {'version': '0.1.8', 'time': '1970-01-01T:00:00:00Z'}
     _0_dot_2_to_0_dot_3(ties_json, 'U')
     self.assertEqual(ties_json['time'], '1970-01-01T00:00:00Z')
Example #13
0
 def test_object_item_rename(self):
     ties_json = {'version': '0.1.8', 'objectItem': []}
     _0_dot_2_to_0_dot_3(ties_json, 'U')
     self.assertTrue('objectItem' not in ties_json)
     self.assertTrue('objectItems' in ties_json)
Example #14
0
 def test_time_missing(self):
     ties_json = {'version': '0.1.8'}
     _0_dot_2_to_0_dot_3(ties_json, 'U')
     self.assertTrue('time' not in ties_json)
Example #15
0
 def test_security_tag_blank_0_dot_2(self):
     ties_json = {'version': '0.2', 'securityTag': ''}
     with self.assertRaises(ValueError):
         _0_dot_2_to_0_dot_3(ties_json, None)
Example #16
0
 def test_security_tag_missing(self):
     ties_json = {'version': '0.1.8'}
     _0_dot_2_to_0_dot_3(ties_json, 'U')
     self.assertEqual(ties_json['securityTag'], 'U')
Example #17
0
 def test_security_tag_not_missing(self):
     ties_json = {'version': '0.3', 'securityTag': 'UNCLASSIFIED'}
     _0_dot_2_to_0_dot_3(ties_json, 'U')
     self.assertEqual(ties_json['securityTag'], 'UNCLASSIFIED')