From 3bdb55e30f66ee992c49ddb12b6287e973f41f92 Mon Sep 17 00:00:00 2001 From: Ryan Deivert Date: Wed, 7 Jun 2017 17:48:56 -0700 Subject: [PATCH] updating unit tests --- test/unit/conf/logs.json | 32 +++++++++++-------- .../test_json_parser.py | 20 +++++++----- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/test/unit/conf/logs.json b/test/unit/conf/logs.json index 8acc813f8..2ba616861 100644 --- a/test/unit/conf/logs.json +++ b/test/unit/conf/logs.json @@ -4,14 +4,17 @@ "schema": { "key1": [], "key2": "string", - "key3": "integer" + "key3": "integer", + "key9": "boolean", + "key10": {}, + "key11": "float" }, "configuration": { - "optional_top_level_keys": { - "key9": "boolean", - "key10": {}, - "key11": "float" - } + "optional_top_level_keys": [ + "key9", + "key10", + "key11" + ] } }, "test_log_type_json_2": { @@ -35,23 +38,24 @@ "test_log_type_json_nested_osquery": { "parser": "json", "schema": { - "name": "string", - "hostIdentifier": "string", + "action": "string", "calendarTime": "string", - "unixTime": "integer", "columns": {}, - "action": "string", "decorations": { "role": "string", "env": "string", "cluster": "string", "number": "integer" - } + }, + "hostIdentifier": "string", + "log_type": "string", + "name": "string", + "unixTime": "integer" }, "configuration": { - "optional_top_level_keys": { - "log_type": "string" - } + "optional_top_level_keys": [ + "log_type" + ] } }, "test_log_type_json_nested_with_data": { diff --git a/test/unit/stream_alert_rule_processor/test_json_parser.py b/test/unit/stream_alert_rule_processor/test_json_parser.py index 213d32340..fc604645e 100644 --- a/test/unit/stream_alert_rule_processor/test_json_parser.py +++ b/test/unit/stream_alert_rule_processor/test_json_parser.py @@ -144,17 +144,21 @@ def test_basic_json(self): def test_optional_keys_json(self): """Parse JSON with optional top level keys""" schema = { - 'name': 'string', + 'columns': {}, 'host': 'string', - 'columns': {} + 'host-id': 'integer', + 'ids': [], + 'name': 'string', + 'results': {}, + 'valid': 'boolean' } options = { - 'optional_top_level_keys': { - 'ids': [], - 'results': {}, - 'host-id': 'integer', - 'valid': 'boolean' - } + 'optional_top_level_keys': [ + 'host-id', + 'ids', + 'results', + 'valid' + ] } data = json.dumps({ 'name': 'unit-test',