-
Notifications
You must be signed in to change notification settings - Fork 786
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #312 from guardicore/master
Back-merge Master into Develop
- Loading branch information
Showing
17 changed files
with
820 additions
and
482 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
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
59 changes: 59 additions & 0 deletions
59
monkey/common/cloud/test_filter_instance_data_from_aws_response.py
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,59 @@ | ||
from unittest import TestCase | ||
from aws_service import filter_instance_data_from_aws_response | ||
|
||
import json | ||
|
||
|
||
__author__ = 'shay.nehmad' | ||
|
||
|
||
class TestFilter_instance_data_from_aws_response(TestCase): | ||
def test_filter_instance_data_from_aws_response(self): | ||
json_response_full = """ | ||
{ | ||
"InstanceInformationList": [ | ||
{ | ||
"ActivationId": "string", | ||
"AgentVersion": "string", | ||
"AssociationOverview": { | ||
"DetailedStatus": "string", | ||
"InstanceAssociationStatusAggregatedCount": { | ||
"string" : 6 | ||
} | ||
}, | ||
"AssociationStatus": "string", | ||
"ComputerName": "string", | ||
"IamRole": "string", | ||
"InstanceId": "string", | ||
"IPAddress": "string", | ||
"IsLatestVersion": "True", | ||
"LastAssociationExecutionDate": 6, | ||
"LastPingDateTime": 6, | ||
"LastSuccessfulAssociationExecutionDate": 6, | ||
"Name": "string", | ||
"PingStatus": "string", | ||
"PlatformName": "string", | ||
"PlatformType": "string", | ||
"PlatformVersion": "string", | ||
"RegistrationDate": 6, | ||
"ResourceType": "string" | ||
} | ||
], | ||
"NextToken": "string" | ||
} | ||
""" | ||
|
||
json_response_empty = """ | ||
{ | ||
"InstanceInformationList": [], | ||
"NextToken": "string" | ||
} | ||
""" | ||
|
||
self.assertEqual(filter_instance_data_from_aws_response(json.loads(json_response_empty)), []) | ||
self.assertEqual( | ||
filter_instance_data_from_aws_response(json.loads(json_response_full)), | ||
[{'instance_id': u'string', | ||
'ip_address': u'string', | ||
'name': u'string', | ||
'os': u'string'}]) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
from monkey_island.cc.environment.environment import load_env_from_file, AWS | ||
import logging | ||
|
||
from monkey_island.cc.report_exporter_manager import ReportExporterManager | ||
from monkey_island.cc.resources.aws_exporter import AWSExporter | ||
from monkey_island.cc.services.remote_run_aws import RemoteRunAwsService | ||
|
||
__author__ = 'maor.rayzin' | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def populate_exporter_list(): | ||
|
||
manager = ReportExporterManager() | ||
if is_aws_exporter_required(): | ||
RemoteRunAwsService.init() | ||
if RemoteRunAwsService.is_running_on_aws(): | ||
manager.add_exporter_to_list(AWSExporter) | ||
|
||
if len(manager.get_exporters_list()) != 0: | ||
logger.debug( | ||
"Populated exporters list with the following exporters: {0}".format(str(manager.get_exporters_list()))) | ||
|
||
def is_aws_exporter_required(): | ||
if str(load_env_from_file()) == AWS: | ||
return True | ||
else: | ||
return False |
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
Oops, something went wrong.