Small improvements: aws test removed and path parsing changed to use path library in environment_config.py

This commit is contained in:
VakarisZ 2020-06-22 15:17:01 +03:00
parent 79bf05d320
commit 90b05a184b
3 changed files with 2 additions and 28 deletions

View File

@ -49,7 +49,7 @@ class EnvironmentConfig:
@staticmethod
def get_config_file_path() -> str:
return os.path.join(MONKEY_ISLAND_ABS_PATH, 'cc/server_config.json')
return os.path.join(MONKEY_ISLAND_ABS_PATH, 'cc', 'server_config.json')
def to_dict(self) -> Dict:
config_dict = {'server_config': self.server_config,

View File

@ -1,26 +0,0 @@
from monkey_island.cc.environment import EnvironmentConfig, UserCreds
from monkey_island.cc.resources.auth.auth_user import User
from monkey_island.cc.testing.IslandTestCase import IslandTestCase
from monkey_island.cc.environment.aws import AwsEnvironment
import hashlib
class TestAwsEnvironment(IslandTestCase):
def test_get_auth_users(self):
env = AwsEnvironment(EnvironmentConfig("", "", UserCreds()))
# This is "injecting" the instance id to the env. This is the UTs aren't always executed on the same AWS machine
# (might not be an AWS machine at all).
# Perhaps it would have been more elegant to create a Mock, but not worth it for
# this small test.
env._instance_id = "i-666"
hash_obj = hashlib.sha3_512()
hash_obj.update(b"i-666")
auth_users = env.get_auth_users()
assert isinstance(auth_users, list)
assert len(auth_users) == 1
auth_user = auth_users[0]
assert isinstance(auth_user, User)
assert auth_user.id == 1
assert auth_user.username == "monkey"
assert auth_user.secret == hash_obj.hexdigest()

View File

@ -57,7 +57,7 @@ class TestEnvironmentConfig(TestCase):
def test_get_server_config_file_path(self):
if platform.system() == "Windows":
server_file_path = MONKEY_ISLAND_ABS_PATH + "\cc/server_config.json"
server_file_path = MONKEY_ISLAND_ABS_PATH + "\cc\server_config.json"
else:
server_file_path = MONKEY_ISLAND_ABS_PATH + "/cc/server_config.json"
self.assertEqual(EnvironmentConfig.get_config_file_path(), server_file_path)