-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#35 Initialize unit tests for cortexutils
- Loading branch information
Showing
7 changed files
with
70 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
dist/ | ||
build/ | ||
*.egg-info | ||
|
||
tests/htmlcov | ||
.coverage | ||
coverage.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"dataType": "ip", | ||
"data": "8.8.8.8" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"dataType": "ip", | ||
"data": "1.1.1.1", | ||
"config": { | ||
"proxy": { | ||
"http": "http://local.proxy:8080", | ||
"https": "http://local.proxy:8080" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import os | ||
import sys | ||
import unittest | ||
import StringIO | ||
|
||
from cortexutils.analyzer import Analyzer | ||
|
||
class TestMinimalConfig(unittest.TestCase): | ||
|
||
def setUp(self): | ||
path = os.path.dirname(os.path.abspath(__file__)) | ||
with open(path + '/test-minimal-config.json', 'r') as content_file: | ||
input = content_file.read() | ||
sys.stdin = StringIO.StringIO(input) | ||
self.analyzer = Analyzer() | ||
|
||
def test_default_config(self): | ||
self.assertEqual(self.analyzer.data_type, 'ip') | ||
self.assertEqual(self.analyzer.tlp, 2) | ||
self.assertEqual(self.analyzer.check_tlp, False) | ||
self.assertEqual(self.analyzer.max_tlp, 10) | ||
self.assertEqual(self.analyzer.http_proxy, None) | ||
self.assertEqual(self.analyzer.https_proxy, None) | ||
|
||
def test_artifact_data(self): | ||
self.assertEqual(self.analyzer.getData(), "8.8.8.8") | ||
|
||
class TestProxyConfig(unittest.TestCase): | ||
|
||
def setUp(self): | ||
path = os.path.dirname(os.path.abspath(__file__)) | ||
with open(path + '/test-proxy-config.json', 'r') as content_file: | ||
input = content_file.read() | ||
sys.stdin = StringIO.StringIO(input) | ||
self.analyzer = Analyzer() | ||
|
||
def test_proxy_config(self): | ||
proxy_url = 'http://local.proxy:8080' | ||
|
||
self.assertEqual(self.analyzer.http_proxy, proxy_url) | ||
self.assertEqual(self.analyzer.https_proxy, proxy_url) | ||
|
||
self.assertEqual(os.environ['http_proxy'], proxy_url) | ||
self.assertEqual(os.environ['https_proxy'], proxy_url) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |