#NEWLINE# def testNewArtifactLoaded( self ) : #NEWLINE# #INDENT# 'Simulate a new artifact being loaded into the store via the UI.' #NEWLINE# cmd_artifact = 'name: "TestCmdArtifact"\ndoc: "Test command artifact for dpkg."\nsources:\n- type: "COMMAND"\n  attributes:\n    cmd: "/usr/bin/dpkg"\n    args: ["--list"]\nlabels: [ "Software" ]\nsupported_os: [ "Linux" ]\n' #NEWLINE# no_datastore_artifact = 'name: "NotInDatastore"\ndoc: "Test command artifact for dpkg."\nsources:\n- type: "COMMAND"\n  attributes:\n    cmd: "/usr/bin/dpkg"\n    args: ["--list"]\nlabels: [ "Software" ]\nsupported_os: [ "Linux" ]\n' #NEWLINE# collect_flow = collectors . ArtifactCollectorFlow ( None , token = self . token ) #NEWLINE# artifact_registry . REGISTRY . GetArtifact ( 'TestCmdArtifact' ) #NEWLINE# artifact_registry . REGISTRY . ClearRegistry ( ) #NEWLINE# artifact_registry . REGISTRY . _dirty = False #NEWLINE# with self . assertRaises ( artifact_registry . ArtifactNotRegisteredError ) : #NEWLINE# #INDENT# artifact_registry . REGISTRY . GetArtifact ( 'TestCmdArtifact' ) #NEWLINE# #UNINDENT# with self . assertRaises ( artifact_registry . ArtifactNotRegisteredError ) : #NEWLINE# #INDENT# artifact_registry . REGISTRY . GetArtifact ( 'NotInDatastore' ) #NEWLINE# #UNINDENT# for artifact_val in artifact_registry . REGISTRY . ArtifactsFromYaml ( cmd_artifact ) : #NEWLINE# #INDENT# with aff4 . FACTORY . Open ( 'aff4:/artifact_store' , aff4_type = 'RDFValueCollection' , token = self . token , mode = 'rw' ) as artifact_coll : #NEWLINE# #INDENT# artifact_coll . Add ( no_datastore_artifact ) #NEWLINE# #UNINDENT# #UNINDENT# for artifact_val in artifact_registry . REGISTRY . ArtifactsFromYaml ( no_datastore_artifact ) : #NEWLINE# #INDENT# artifact_registry . REGISTRY . RegisterArtifact ( artifact_val , source = 'datastore' , overwrite_if_exists = False ) #NEWLINE# #UNINDENT# self . assertTrue ( collect_flow . _GetArtifactFromName ( 'TestCmdArtifact' ) ) #NEWLINE# with self . assertRaises ( artifact_registry . ArtifactNotRegisteredError ) : #NEWLINE# #INDENT# artifact_registry . REGISTRY . GetArtifact ( 'NotInDatastore' )