From 6a472b524f258b7831805dd14a9681929b0f0b52 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Tue, 16 Nov 2021 11:50:30 +0200 Subject: [PATCH] Common, UT: remove unused AWS cloud instance infrastructure. This infrastructure/classes store information about cloud instances monkeys are ran upon, but this data isn't used anywhere --- monkey/common/cloud/aws/aws_instance.py | 4 --- .../common/cloud/aws/test_aws_instance.py | 32 ------------------- 2 files changed, 36 deletions(-) diff --git a/monkey/common/cloud/aws/aws_instance.py b/monkey/common/cloud/aws/aws_instance.py index 09d112480..4bdc89bf3 100644 --- a/monkey/common/cloud/aws/aws_instance.py +++ b/monkey/common/cloud/aws/aws_instance.py @@ -4,7 +4,6 @@ import re import requests -from common.cloud.environment_names import Environment from common.cloud.instance import CloudInstance AWS_INSTANCE_METADATA_LOCAL_IP_ADDRESS = "169.254.169.254" @@ -22,9 +21,6 @@ class AwsInstance(CloudInstance): def is_instance(self): return self.instance_id is not None - def get_cloud_provider_name(self) -> Environment: - return Environment.AWS - def __init__(self): self.instance_id = None self.region = None diff --git a/monkey/tests/unit_tests/common/cloud/aws/test_aws_instance.py b/monkey/tests/unit_tests/common/cloud/aws/test_aws_instance.py index 74ef5dd15..04421920f 100644 --- a/monkey/tests/unit_tests/common/cloud/aws/test_aws_instance.py +++ b/monkey/tests/unit_tests/common/cloud/aws/test_aws_instance.py @@ -3,7 +3,6 @@ import requests import requests_mock from common.cloud.aws.aws_instance import AWS_LATEST_METADATA_URI_PREFIX, AwsInstance -from common.cloud.environment_names import Environment INSTANCE_ID_RESPONSE = "i-1234567890abcdef0" @@ -78,10 +77,6 @@ def test_is_instance_good_data(good_data_mock_instance): assert good_data_mock_instance.is_instance() -def test_get_cloud_provider_name_good_data(good_data_mock_instance): - assert good_data_mock_instance.get_cloud_provider_name() == Environment.AWS - - def test_get_instance_id_good_data(good_data_mock_instance): assert good_data_mock_instance.get_instance_id() == EXPECTED_INSTANCE_ID @@ -110,10 +105,6 @@ def test_is_instance_bad_region_data(bad_region_data_mock_instance): assert bad_region_data_mock_instance.is_instance() -def test_get_cloud_provider_name_bad_region_data(bad_region_data_mock_instance): - assert bad_region_data_mock_instance.get_cloud_provider_name() == Environment.AWS - - def test_get_instance_id_bad_region_data(bad_region_data_mock_instance): assert bad_region_data_mock_instance.get_instance_id() == EXPECTED_INSTANCE_ID @@ -142,10 +133,6 @@ def test_is_instance_bad_account_id_data(bad_account_id_data_mock_instance): assert bad_account_id_data_mock_instance.is_instance() -def test_get_cloud_provider_name_bad_account_id_data(bad_account_id_data_mock_instance): - assert bad_account_id_data_mock_instance.get_cloud_provider_name() == Environment.AWS - - def test_get_instance_id_bad_account_id_data(bad_account_id_data_mock_instance): assert bad_account_id_data_mock_instance.get_instance_id() == EXPECTED_INSTANCE_ID @@ -176,11 +163,6 @@ def test_is_instance_bad_instance_id_request(bad_instance_id_request_mock_instan assert bad_instance_id_request_mock_instance.is_instance() is False -@pytest.mark.parametrize("instance_id_exception", [requests.RequestException, IOError]) -def test_get_cloud_provider_name_bad_instance_id_request(bad_instance_id_request_mock_instance): - assert bad_instance_id_request_mock_instance.get_cloud_provider_name() == Environment.AWS - - @pytest.mark.parametrize("instance_id_exception", [requests.RequestException, IOError]) def test_get_instance_id_bad_instance_id_request(bad_instance_id_request_mock_instance): assert bad_instance_id_request_mock_instance.get_instance_id() is None @@ -214,11 +196,6 @@ def test_is_instance_bad_region_request(bad_region_request_mock_instance): assert bad_region_request_mock_instance.is_instance() -@pytest.mark.parametrize("region_exception", [requests.RequestException, IOError]) -def test_get_cloud_provider_name_bad_region_request(bad_region_request_mock_instance): - assert bad_region_request_mock_instance.get_cloud_provider_name() == Environment.AWS - - @pytest.mark.parametrize("region_exception", [requests.RequestException, IOError]) def test_get_instance_id_bad_region_request(bad_region_request_mock_instance): assert bad_region_request_mock_instance.get_instance_id() == EXPECTED_INSTANCE_ID @@ -252,11 +229,6 @@ def test_is_instance_bad_account_id_request(bad_account_id_request_mock_instance assert bad_account_id_request_mock_instance.is_instance() -@pytest.mark.parametrize("account_id_exception", [requests.RequestException, IOError]) -def test_get_cloud_provider_name_bad_account_id_request(bad_account_id_request_mock_instance): - assert bad_account_id_request_mock_instance.get_cloud_provider_name() == Environment.AWS - - @pytest.mark.parametrize("account_id_exception", [requests.RequestException, IOError]) def test_get_instance_id_bad_account_id_request(bad_account_id_request_mock_instance): assert bad_account_id_request_mock_instance.get_instance_id() == EXPECTED_INSTANCE_ID @@ -296,10 +268,6 @@ def test_is_instance_not_found_request(not_found_request_mock_instance): assert not_found_request_mock_instance.is_instance() is False -def test_get_cloud_provider_name_not_found_request(not_found_request_mock_instance): - assert not_found_request_mock_instance.get_cloud_provider_name() == Environment.AWS - - def test_get_instance_id_not_found_request(not_found_request_mock_instance): assert not_found_request_mock_instance.get_instance_id() is None