mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 17:22:49 +01:00
31 lines
1023 B
Python
31 lines
1023 B
Python
from unittest.mock import patch, MagicMock
|
|
import helpers
|
|
import os
|
|
import unittest
|
|
|
|
|
|
class TestHelpersMethods(unittest.TestCase):
|
|
|
|
def test_checkSupportedType(self):
|
|
with patch('sys.exit', new=MagicMock()) as mock:
|
|
meta = {"supportedTypes": ["ip", "foo"]}
|
|
result = helpers.checkSupportedType(meta, "ip")
|
|
self.assertTrue(result)
|
|
mock.assert_not_called()
|
|
|
|
result = helpers.checkSupportedType(meta, "bar")
|
|
self.assertFalse(result)
|
|
mock.assert_called_once_with(126)
|
|
|
|
def test_loadMetadata(self):
|
|
dir = os.path.dirname(os.path.realpath(__file__))
|
|
input = dir + '/urlhaus/urlhaus.py'
|
|
data = helpers.loadMetadata(input)
|
|
self.assertEqual(data["name"], "Urlhaus")
|
|
|
|
def test_parseArtifact(self):
|
|
input = '{"value":"foo","artifactType":"bar"}'
|
|
data = helpers.parseArtifact(input)
|
|
self.assertEqual(data["artifactType"], "bar")
|
|
self.assertEqual(data["value"], "foo")
|