<s> import unittest <EOL> from stix . test import EntityTestCase , assert_warnings <EOL> from stix . test import data_marking_test <EOL> from stix . test . common import related_test , identity_test , kill_chains_test <EOL> from stix . core import STIXPackage <EOL> import stix . ttp as ttp <EOL> from stix . ttp import ( <EOL> resource , infrastructure , exploit_targets , malware_instance , exploit , <EOL> attack_pattern , behavior <EOL> ) <EOL> class ExploitTargetsTests ( EntityTestCase , unittest . TestCase ) : <EOL> klass = exploit_targets . ExploitTargets <EOL> _full_dict = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ <EOL> related_test . RelatedExploitTargetTests . _full_dict <EOL> ] <EOL> } <EOL> class PersonasTests ( EntityTestCase , unittest . TestCase ) : <EOL> klass = resource . Personas <EOL> _full_dict = [ <EOL> identity_test . IdentityTests . _full_dict <EOL> ] <EOL> class InfrastructureTests ( EntityTestCase , unittest . TestCase ) : <EOL> klass = infrastructure . Infrastructure <EOL> _full_dict = { <EOL> '<STR_LIT:title>' : '<STR_LIT>' , <EOL> '<STR_LIT:description>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ '<STR_LIT:foo>' , '<STR_LIT:bar>' ] , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : <NUM_LIT:2> , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : [ <EOL> { <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } <EOL> ] <EOL> } <EOL> } <EOL> class ResourcesTests ( EntityTestCase , unittest . TestCase ) : <EOL> klass = ttp . Resource <EOL> _full_dict = { <EOL> '<STR_LIT>' : PersonasTests . _full_dict , <EOL> '<STR_LIT>' : [ <EOL> { <EOL> '<STR_LIT:title>' : "<STR_LIT>" <EOL> } <EOL> ] , <EOL> '<STR_LIT>' : InfrastructureTests . _full_dict <EOL> } <EOL> class MalwareInstanceTests ( EntityTestCase , unittest . TestCase ) : <EOL> klass = malware_instance . MalwareInstance <EOL> _full_dict = _full_dict = { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:title>' : '<STR_LIT>' , <EOL> '<STR_LIT:description>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ '<STR_LIT:foo>' , '<STR_LIT:bar>' ] <EOL> } <EOL> class MalwareInstancesTests ( EntityTestCase , unittest . TestCase ) : <EOL> klass = behavior . MalwareInstances <EOL> _full_dict = [ <EOL> MalwareInstanceTests . _full_dict <EOL> ] <EOL> class ExploitTests ( EntityTestCase , unittest . TestCase ) : <EOL> klass = exploit . Exploit <EOL> _full_dict = { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:title>' : '<STR_LIT>' , <EOL> '<STR_LIT:description>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> class ExploitsTests ( EntityTestCase , unittest . TestCase ) : <EOL> klass = behavior . Exploits <EOL> _full_dict = [ <EOL> ExploitTests . _full_dict <EOL> ] <EOL> class AttackPatternTests ( EntityTestCase , unittest . TestCase ) : <EOL> klass = attack_pattern . AttackPattern <EOL> _full_dict = { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:title>' : '<STR_LIT>' , <EOL> '<STR_LIT:description>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> def idref_test ( self ) : <EOL> ap = attack_pattern . AttackPattern ( ) <EOL> ap . id_ = '<STR_LIT:foo>' <EOL> self . assertEqual ( ap . id_ , '<STR_LIT:foo>' ) <EOL> ap . idref = '<STR_LIT:bar>' <EOL> self . assertEqual ( ap . idref , '<STR_LIT:bar>' ) <EOL> self . assertEqual ( ap . id_ , None ) <EOL> class AttackPatternsTests ( EntityTestCase , unittest . TestCase ) : <EOL> klass = behavior . AttackPatterns <EOL> _full_dict = [ <EOL> AttackPatternTests . _full_dict <EOL> ] <EOL> class BehaviorTests ( EntityTestCase , unittest . TestCase ) : <EOL> klass = behavior . Behavior <EOL> _full_dict = { <EOL> '<STR_LIT>' : MalwareInstancesTests . _full_dict , <EOL> '<STR_LIT>' : ExploitsTests . _full_dict , <EOL> '<STR_LIT>' : AttackPatternsTests . _full_dict <EOL> } <EOL> class TTPTests ( EntityTestCase , unittest . TestCase ) : <EOL> klass = ttp . TTP <EOL> _full_dict = { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:version>' : '<STR_LIT>' , <EOL> '<STR_LIT:title>' : "<STR_LIT>" , <EOL> '<STR_LIT:description>' : "<STR_LIT>" , <EOL> '<STR_LIT>' : "<STR_LIT>" , <EOL> '<STR_LIT>' : ResourcesTests . _full_dict , <EOL> '<STR_LIT>' : data_marking_test . MarkingTests . _full_dict , <EOL> '<STR_LIT>' : ExploitTargetsTests . _full_dict , <EOL> '<STR_LIT>' : BehaviorTests . _full_dict , <EOL> '<STR_LIT>' : related_test . RelatedPackageRefsTests . _full_dict , <EOL> '<STR_LIT>' : kill_chains_test . KillChainPhasesReferenceTests . _full_dict <EOL> } <EOL> def test_add_description ( self ) : <EOL> o1 = self . klass ( ) <EOL> o2 = self . klass ( ) <EOL> o1 . add_description ( "<STR_LIT>" ) <EOL> o2 . descriptions . add ( "<STR_LIT>" ) <EOL> self . assertEqual ( <EOL> o1 . descriptions . to_dict ( ) , <EOL> o2 . descriptions . to_dict ( ) <EOL> ) <EOL> def test_add_short_description ( self ) : <EOL> o1 = self . klass ( ) <EOL> o2 = self . klass ( ) <EOL> o1 . add_short_description ( "<STR_LIT>" ) <EOL> o2 . short_descriptions . add ( "<STR_LIT>" ) <EOL> self . assertEqual ( <EOL> o1 . short_descriptions . to_dict ( ) , <EOL> o2 . short_descriptions . to_dict ( ) <EOL> ) <EOL> @ assert_warnings <EOL> def test_deprecated_related_packages ( self ) : <EOL> t = ttp . TTP ( ) <EOL> t . related_packages . append ( STIXPackage ( ) ) <EOL> self . assertEqual ( len ( t . related_packages ) , <NUM_LIT:1> ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
