Skip to content

Commit

Permalink
validation test
Browse files Browse the repository at this point in the history
  • Loading branch information
bhnedo committed Apr 15, 2017
1 parent eb60039 commit 23a3387
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/unit/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,38 @@
import os

__CONFIG_PATH__ = os.path.join(os.path.dirname(__file__), '..', 'fixtures', 'fibratus.yml')
__SCHEMA_FILE__ = os.path.join(os.path.dirname(__file__), '..', 'fixtures', 'schema.yml')


class TestYamlConfig():

def test_load_yaml(self):
config = YamlConfig(__CONFIG_PATH__)
config.load(False)
assert config.yaml

def test_load_validate(self):
config = YamlConfig(__CONFIG_PATH__)
config.default_schema_path = __SCHEMA_FILE__
config.load()

def test_load_yaml_not_found(self):
with patch('sys.exit') as sys_exit:
YamlConfig('C:\\fibratus.yml')
YamlConfig('C:\\fibratus.yml').load(False)
sys_exit.assert_called_once()

def test_outputs(self):
config = YamlConfig(__CONFIG_PATH__)
config.load(False)
outputs = config.outputs
assert outputs
assert isinstance(outputs, list)
assert len(outputs) > 0

def test_enum_outputs(self):
config = YamlConfig(__CONFIG_PATH__)
output_names = ['amqp', 'smtp', 'console', 'elasticsearch']
config.load(False)
output_names = ['amqp', 'smtp', 'console', 'elasticsearch', 'fs']
outputs = config.outputs
if outputs:
for output in outputs:
Expand All @@ -49,13 +58,15 @@ def test_enum_outputs(self):

def test_image_skips(self):
config = YamlConfig(__CONFIG_PATH__)
config.load(False)
image_skips = config.skips.images
assert image_skips
assert isinstance(image_skips, list)
assert 'smss.exe' in image_skips

def test_bindings(self):
config = YamlConfig(__CONFIG_PATH__)
config.load(False)
bindings = config.bindings
binding_names = ['yara']
assert bindings
Expand Down

0 comments on commit 23a3387

Please sign in to comment.