Navigation Menu

Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Remove sys.path from mq plugin tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pwnbus committed Aug 7, 2019
1 parent a04c49b commit e79c290
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 58 deletions.
3 changes: 0 additions & 3 deletions mq/plugins/parse_su.py
Expand Up @@ -3,10 +3,7 @@
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
# Copyright (c) 2017 Mozilla Corporation

import sys
import os
import re
sys.path.append(os.path.join(os.path.dirname(__file__), "../../lib"))


class message(object):
Expand Down
Empty file added tests/mq/plugins/__init__.py
Empty file.
5 changes: 1 addition & 4 deletions tests/mq/plugins/test_alert_information.py
Expand Up @@ -3,10 +3,7 @@
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
# Copyright (c) 2017 Mozilla Corporation

import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), "../../../mq/plugins"))
from alert_information import message
from mq.plugins.alert_information import message


class TestAlertInformationPlugin():
Expand Down
9 changes: 3 additions & 6 deletions tests/mq/plugins/test_broFixup.py
@@ -1,12 +1,9 @@
import os
import sys
from mozdef_util.utilities.toUTC import toUTC

import mock
import json

sys.path.append(os.path.join(os.path.dirname(__file__), "../../../mq/plugins"))
from broFixup import message
from mq.plugins.broFixup import message


class TestBroFixup(object):
Expand Down Expand Up @@ -73,7 +70,7 @@ def test_bro_wrongtype_log(self):
assert toUTC(MESSAGE['ts']).isoformat() == result['timestamp']
assert sorted(result['details'].keys()) == sorted(MESSAGE.keys())

@mock.patch('broFixup.node')
@mock.patch('mq.plugins.broFixup.node')
def test_mozdefhostname_mock_string(self, mock_path):
mock_path.return_value = 'samplehostname'
event = {
Expand All @@ -85,7 +82,7 @@ def test_mozdefhostname_mock_string(self, mock_path):
result, metadata = plugin.onMessage(event, self.metadata)
assert result['mozdefhostname'] == 'samplehostname'

@mock.patch('broFixup.node')
@mock.patch('mq.plugins.broFixup.node')
def test_mozdefhostname_mock_exception(self, mock_path):
mock_path.side_effect = ValueError
event = {
Expand Down
5 changes: 1 addition & 4 deletions tests/mq/plugins/test_cloudtrail.py
Expand Up @@ -3,10 +3,7 @@
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
# Copyright (c) 2017 Mozilla Corporation

import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), "../../../mq/plugins"))
from cloudtrail import message
from mq.plugins.cloudtrail import message


class TestCloudtrailPlugin():
Expand Down
5 changes: 1 addition & 4 deletions tests/mq/plugins/test_filterlog.py
Expand Up @@ -3,10 +3,7 @@
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
# Copyright (c) 2017 Mozilla Corporation

import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), "../../../mq/plugins"))
from filterlog import message
from mq.plugins.filterlog import message


class TestFilterlog():
Expand Down
6 changes: 1 addition & 5 deletions tests/mq/plugins/test_github_webhooks.py
@@ -1,8 +1,4 @@
import os
import sys

sys.path.append(os.path.join(os.path.dirname(__file__), '../../../mq/plugins'))
from github_webhooks import message
from mq.plugins.github_webhooks import message


class TestSuricataFixup(object):
Expand Down
5 changes: 1 addition & 4 deletions tests/mq/plugins/test_large_strings.py
Expand Up @@ -3,10 +3,7 @@
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
# Copyright (c) 2017 Mozilla Corporation

import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), "../../../mq/plugins"))
from large_strings import message
from mq.plugins.large_strings import message


class TestLargeStrings():
Expand Down
5 changes: 1 addition & 4 deletions tests/mq/plugins/test_lower_keys.py
Expand Up @@ -3,10 +3,7 @@
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
# Copyright (c) 2017 Mozilla Corporation

import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), "../../../mq/plugins"))
from lower_keys import message
from mq.plugins.lower_keys import message


class TestLowerKeysPlugin():
Expand Down
6 changes: 2 additions & 4 deletions tests/mq/plugins/test_parse_sshd.py
Expand Up @@ -3,12 +3,10 @@
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
# Copyright (c) 2017 Mozilla Corporation

import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), "../../../mq/plugins"))
from parse_sshd import message
import copy

from mq.plugins.parse_sshd import message

accept_message = {}
accept_message['utctimestamp'] = '2017-08-24T22:49:42+00:00'
accept_message['timestamp'] = '2017-08-24T22:49:42+00:00'
Expand Down
6 changes: 2 additions & 4 deletions tests/mq/plugins/test_parse_su.py
Expand Up @@ -3,12 +3,10 @@
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
# Copyright (c) 2017 Mozilla Corporation

import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), "../../../mq/plugins"))
from parse_su import message
import copy

from mq.plugins.parse_su import message

session_su = {}
session_su['utctimestamp'] = '2017-08-24T22:49:42+00:00'
session_su['timestamp'] = '2017-08-24T22:49:42+00:00'
Expand Down
11 changes: 5 additions & 6 deletions tests/mq/plugins/test_squidFixup.py
@@ -1,9 +1,8 @@
import mock
import os
import sys

from mozdef_util.utilities.toUTC import toUTC
sys.path.append(os.path.join(os.path.dirname(__file__), "../../../mq/plugins"))
from squidFixup import message

from mq.plugins.squidFixup import message


class TestSquidFixup(object):
Expand Down Expand Up @@ -64,7 +63,7 @@ def test_squid_wrongtype_log(self):
self.verify_defaults(result)
self.verify_metadata(metadata)

@mock.patch('squidFixup.node')
@mock.patch('mq.plugins.squidFixup.node')
def test_mozdefhostname_mock_string(self, mock_path):
mock_path.return_value = 'samplehostname'
event = {
Expand All @@ -76,7 +75,7 @@ def test_mozdefhostname_mock_string(self, mock_path):
result, metadata = plugin.onMessage(event, self.metadata)
assert result['mozdefhostname'] == 'samplehostname'

@mock.patch('squidFixup.node')
@mock.patch('mq.plugins.squidFixup.node')
def test_mozdefhostname_mock_exception(self, mock_path):
mock_path.side_effect = ValueError
event = {
Expand Down
9 changes: 3 additions & 6 deletions tests/mq/plugins/test_suricataFixup.py
@@ -1,13 +1,10 @@
import os
import sys
from mozdef_util.utilities.toUTC import toUTC

import json
import random
import string

sys.path.append(os.path.join(os.path.dirname(__file__), "../../../mq/plugins"))
from suricataFixup import message
from mozdef_util.utilities.toUTC import toUTC

from mq.plugins.suricataFixup import message


class TestSuricataFixup(object):
Expand Down
5 changes: 1 addition & 4 deletions tests/mq/plugins/test_vulnerability.py
@@ -1,7 +1,4 @@
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), "../../../mq/plugins"))
from vulnerability import message
from mq.plugins.vulnerability import message


class TestVulnerabilityMessageV1():
Expand Down

0 comments on commit e79c290

Please sign in to comment.