summaryrefslogtreecommitdiffstats
path: root/app/test/api/responders_test
diff options
context:
space:
mode:
Diffstat (limited to 'app/test/api/responders_test')
-rw-r--r--app/test/api/responders_test/resource/test_clique_types.py108
-rw-r--r--app/test/api/responders_test/resource/test_environment_configs.py311
-rw-r--r--app/test/api/responders_test/test_data/base.py71
-rw-r--r--app/test/api/responders_test/test_data/clique_types.py201
-rw-r--r--app/test/api/responders_test/test_data/environment_configs.py6
5 files changed, 417 insertions, 280 deletions
diff --git a/app/test/api/responders_test/resource/test_clique_types.py b/app/test/api/responders_test/resource/test_clique_types.py
index f5e331e..5e52cea 100644
--- a/app/test/api/responders_test/resource/test_clique_types.py
+++ b/app/test/api/responders_test/resource/test_clique_types.py
@@ -17,10 +17,17 @@ from unittest.mock import patch
class TestCliqueTypes(TestBase):
- def test_get_clique_types_list_without_env_name(self):
- self.validate_get_request(clique_types.URL,
- params={},
- expected_code=base.BAD_REQUEST_CODE)
+ @patch(base.RESPONDER_BASE_READ)
+ def test_get_all_clique_types_list(self, read):
+ self.validate_get_request(
+ clique_types.URL,
+ params={},
+ mocks={
+ read: clique_types.CLIQUE_TYPES
+ },
+ expected_code=base.SUCCESSFUL_CODE,
+ expected_response=clique_types.CLIQUE_TYPES_RESPONSE
+ )
def test_get_clique_types_with_invalid_filter(self):
self.validate_get_request(clique_types.URL,
@@ -53,6 +60,28 @@ class TestCliqueTypes(TestBase):
expected_code=base.SUCCESSFUL_CODE
)
+ def test_get_clique_type_with_insufficient_configuration(self):
+ self.validate_get_request(
+ clique_types.URL,
+ params={
+ "distribution_version": base.CORRECT_DIST_VER,
+ },
+ expected_code=base.BAD_REQUEST_CODE
+ )
+
+ @patch(base.RESPONDER_BASE_READ)
+ def test_get_clique_type_with_correct_configuration(self, read):
+ self.validate_get_request(
+ clique_types.URL,
+ params=clique_types.TEST_CONFIGURATION,
+ mocks={
+ read: clique_types.CLIQUE_TYPES_WITH_SPECIFIC_CONFIGURATION
+ },
+ expected_response=clique_types.
+ CLIQUE_TYPES_WITH_SPECIFIC_CONFIGURATION_RESPONSE,
+ expected_code=base.SUCCESSFUL_CODE
+ )
+
def test_get_clique_types_list_with_wrong_focal_point_type(self):
self.validate_get_request(clique_types.URL,
params={
@@ -204,9 +233,53 @@ class TestCliqueTypes(TestBase):
body=json.dumps(clique_types.NON_DICT_CLIQUE_TYPE),
expected_code=base.BAD_REQUEST_CODE)
- def test_post_clique_type_without_env_name(self):
+ @patch(base.RESPONDER_BASE_CHECK_ENVIRONMENT_NAME)
+ def test_post_clique_type_with_reserved_env_name(self, check_env_name):
+ self.validate_post_request(
+ clique_types.URL,
+ mocks={
+ check_env_name: True
+ },
+ body=json.dumps(clique_types.CLIQUE_TYPE_WITH_RESERVED_NAME),
+ expected_code=base.BAD_REQUEST_CODE
+ )
+
+ def test_post_clique_type_without_env_name_and_configuration(self):
+ self.validate_post_request(
+ clique_types.URL,
+ body=json.dumps(clique_types.CLIQUE_TYPE_WITHOUT_ENV_NAME_AND_CONF),
+ expected_code=base.BAD_REQUEST_CODE
+ )
+
+ def test_post_clique_type_with_both_env_name_and_configuration(self):
+ self.validate_post_request(
+ clique_types.URL,
+ body=json.dumps(
+ clique_types.CLIQUE_TYPE_WITH_BOTH_ENV_AND_CONF),
+ expected_code=base.BAD_REQUEST_CODE
+ )
+
+ @patch(base.RESPONDER_BASE_CHECK_ENVIRONMENT_NAME)
+ def test_post_clique_type_with_insufficient_configuration(self, check_env_name):
+ self.validate_post_request(
+ clique_types.URL,
+ mocks={
+ check_env_name: True
+ },
+ body=json.dumps(clique_types.CLIQUE_TYPE_WITH_INSUFFICIENT_CONF),
+ expected_code=base.BAD_REQUEST_CODE
+ )
+
+ @patch(base.RESPONDER_BASE_READ)
+ def test_post_clique_type_with_duplicate_configuration(self, read):
+ data = clique_types.CLIQUE_TYPES_WITH_SPECIFIC_CONFIGURATION[0]
+ resp = clique_types.CLIQUE_TYPES_WITH_SPECIFIC_CONFIGURATION_RESPONSE
+ test_data = self.get_updated_data(data, deleted_keys=['id'])
self.validate_post_request(clique_types.URL,
- body=json.dumps(clique_types.CLIQUE_TYPE_WITHOUT_ENVIRONMENT),
+ body=json.dumps(test_data),
+ mocks={
+ read: resp,
+ },
expected_code=base.BAD_REQUEST_CODE)
@patch(base.RESPONDER_BASE_CHECK_ENVIRONMENT_NAME)
@@ -231,6 +304,17 @@ class TestCliqueTypes(TestBase):
CLIQUE_TYPE_WITH_WRONG_FOCAL_POINT_TYPE),
expected_code=base.BAD_REQUEST_CODE)
+ @patch(base.RESPONDER_BASE_READ)
+ def test_post_clique_type_with_duplicate_focal_point_type(self, read):
+ test_data = self.get_updated_data(clique_types.CLIQUE_TYPE,
+ updates={'name': 'test-name'})
+ self.validate_post_request(clique_types.URL,
+ body=json.dumps(test_data),
+ mocks={
+ read: [clique_types.CLIQUE_TYPE],
+ },
+ expected_code=base.BAD_REQUEST_CODE)
+
def test_post_clique_type_without_link_types(self):
self.validate_post_request(clique_types.URL,
body=json.dumps(
@@ -255,6 +339,18 @@ class TestCliqueTypes(TestBase):
body=json.dumps(clique_types.CLIQUE_TYPE_WITHOUT_NAME),
expected_code=base.BAD_REQUEST_CODE)
+ def test_post_clique_type_with_wrong_mechanism_drivers(self):
+ self.validate_post_request(clique_types.URL,
+ body=json.dumps(clique_types.
+ CLIQUE_TYPE_WITH_WRONG_MECH_DRIVERS),
+ expected_code=base.BAD_REQUEST_CODE)
+
+ def test_post_clique_type_with_wrong_type_drivers(self):
+ self.validate_post_request(clique_types.URL,
+ body=json.dumps(clique_types.
+ CLIQUE_TYPE_WITH_WRONG_TYPE_DRIVERS),
+ expected_code=base.BAD_REQUEST_CODE)
+
@patch(base.RESPONDER_BASE_CHECK_ENVIRONMENT_NAME)
@patch(base.RESPONDER_BASE_WRITE)
def test_post_clique_type(self, write, check_environment_name):
diff --git a/app/test/api/responders_test/resource/test_environment_configs.py b/app/test/api/responders_test/resource/test_environment_configs.py
index 6356f06..4405f2b 100644
--- a/app/test/api/responders_test/resource/test_environment_configs.py
+++ b/app/test/api/responders_test/resource/test_environment_configs.py
@@ -9,7 +9,9 @@
###############################################################################
import json
+from api.responders.resource.environment_configs import EnvironmentConfigs
from test.api.responders_test.test_data import base
+from test.api.responders_test.test_data.base import CONSTANTS_BY_NAMES
from test.api.test_base import TestBase
from test.api.responders_test.test_data import environment_configs
from utils.constants import EnvironmentFeatures
@@ -23,35 +25,25 @@ class TestEnvironmentConfigs(TestBase):
def test_get_environment_configs_list(self, read):
self.validate_get_request(environment_configs.URL,
params={},
- mocks={
- read: environment_configs.ENV_CONFIGS
- },
+ mocks={read: environment_configs.ENV_CONFIGS},
expected_code=base.SUCCESSFUL_CODE,
expected_response=environment_configs.
- ENV_CONFIGS_RESPONSE
- )
+ ENV_CONFIGS_RESPONSE)
def test_get_environment_configs_list_with_invalid_filters(self):
self.validate_get_request(environment_configs.URL,
- params={
- "unknown": "unknown"
- },
+ params={"unknown": "unknown"},
expected_code=base.BAD_REQUEST_CODE)
@patch(base.RESPONDER_BASE_READ)
def test_get_environment_configs_list_with_name(self, read):
+ mocks = {read: environment_configs.ENV_CONFIGS_WITH_SPECIFIC_NAME}
self.validate_get_request(environment_configs.URL,
- params={
- "name": environment_configs.NAME
- },
- mocks={
- read: environment_configs.
- ENV_CONFIGS_WITH_SPECIFIC_NAME
- },
+ params={"name": environment_configs.NAME},
+ mocks=mocks,
expected_code=base.SUCCESSFUL_CODE,
expected_response=environment_configs.
- ENV_CONFIGS_WITH_SPECIFIC_NAME[0]
- )
+ ENV_CONFIGS_WITH_SPECIFIC_NAME[0])
@patch(base.RESPONDER_BASE_READ)
def test_get_environment_configs_list_with_unknown_name(self, read):
@@ -82,193 +74,151 @@ class TestEnvironmentConfigs(TestBase):
@patch(base.RESPONDER_BASE_READ)
def test_get_environment_configs_list_with_distribution(self, read):
+ config = environment_configs.ENV_CONFIGS_WITH_SPECIFIC_DISTRIBUTION
+ config_response = \
+ environment_configs.ENV_CONFIGS_WITH_SPECIFIC_DISTRIBUTION_RESPONSE
self.validate_get_request(environment_configs.URL,
params={
"distribution":
environment_configs.
CORRECT_DISTRIBUTION
},
- mocks={
- read: environment_configs.
- ENV_CONFIGS_WITH_SPECIFIC_DISTRIBUTION
- },
+ mocks={read: config},
expected_code=base.SUCCESSFUL_CODE,
- expected_response=environment_configs.
- ENV_CONFIGS_WITH_SPECIFIC_DISTRIBUTION_RESPONSE)
+ expected_response=config_response)
def test_get_environment_configs_list_with_wrong_mechanism_driver(self):
+ config = environment_configs.WRONG_MECHANISM_DRIVER
self.validate_get_request(environment_configs.URL,
- params={
- "mechanism_drivers":
- environment_configs.WRONG_MECHANISM_DRIVER
- },
+ params={"mechanism_drivers": config},
expected_code=base.BAD_REQUEST_CODE)
@patch(base.RESPONDER_BASE_READ)
def test_get_environment_configs_list_with_mechanism_driver(self, read):
+ mechanism = environment_configs.CORRECT_MECHANISM_DRIVER
+ config = environment_configs.ENV_CONFIGS_WITH_SPECIFIC_MECHANISM_DRIVER
+ config_response = environment_configs.\
+ ENV_CONFIGS_WITH_SPECIFIC_MECHANISM_DRIVER_RESPONSE
self.validate_get_request(environment_configs.URL,
- params={
- "mechanism_drivers":
- environment_configs.CORRECT_MECHANISM_DRIVER
- },
- mocks={
- read: environment_configs.
- ENV_CONFIGS_WITH_SPECIFIC_MECHANISM_DRIVER
- },
+ params={"mechanism_drivers": mechanism},
+ mocks={read: config},
expected_code=base.SUCCESSFUL_CODE,
- expected_response=environment_configs.
- ENV_CONFIGS_WITH_SPECIFIC_MECHANISM_DRIVER_RESPONSE
- )
+ expected_response=config_response)
def test_get_environment_configs_list_with_wrong_type_driver(self):
+ driver = environment_configs.WRONG_TYPE_DRIVER
self.validate_get_request(environment_configs.URL,
- params={
- "type_drivers":
- environment_configs.WRONG_TYPE_DRIVER
- },
+ params={"type_drivers": driver},
expected_code=base.BAD_REQUEST_CODE)
@patch(base.RESPONDER_BASE_READ)
def test_get_environment_configs_list_with_type_driver(self, read):
+ driver = environment_configs.CORRECT_TYPE_DRIVER
+ config = environment_configs.ENV_CONFIGS_WITH_SPECIFIC_TYPE_DRIVER
+ config_response = environment_configs.\
+ ENV_CONFIGS_WITH_SPECIFIC_TYPE_DRIVER_RESPONSE
self.validate_get_request(environment_configs.URL,
- params={
- "type_drivers":
- environment_configs.CORRECT_TYPE_DRIVER
- },
- mocks={
- read: environment_configs.
- ENV_CONFIGS_WITH_SPECIFIC_TYPE_DRIVER
- },
+ params={"type_drivers": driver},
+ mocks={read: config},
expected_code=base.SUCCESSFUL_CODE,
- expected_response=environment_configs.
- ENV_CONFIGS_WITH_SPECIFIC_TYPE_DRIVER_RESPONSE
+ expected_response=config_response
)
@patch(base.RESPONDER_BASE_READ)
def test_get_environment_configs_list_with_user(self, read):
+ config = environment_configs.ENV_CONFIGS_WITH_SPECIFIC_USER
+ config_response = \
+ environment_configs.ENV_CONFIGS_WITH_SPECIFIC_USER_RESPONSE
self.validate_get_request(environment_configs.URL,
- params={
- "user": environment_configs.USER
- },
- mocks={
- read: environment_configs.
- ENV_CONFIGS_WITH_SPECIFIC_USER
- },
+ params={"user": environment_configs.USER},
+ mocks={read: config},
expected_code=base.SUCCESSFUL_CODE,
- expected_response=environment_configs.
- ENV_CONFIGS_WITH_SPECIFIC_USER_RESPONSE
- )
+ expected_response=config_response)
def test_get_environment_configs_list_with_non_bool_listen(self):
self.validate_get_request(environment_configs.URL,
- params={
- "listen": environment_configs.NON_BOOL_LISTEN
- },
+ params={"listen": environment_configs.
+ NON_BOOL_LISTEN},
expected_code=base.BAD_REQUEST_CODE)
@patch(base.RESPONDER_BASE_READ)
def test_get_environment_configs_list_with_bool_listen(self, read):
+ config = environment_configs.ENV_CONFIGS_WITH_SPECIFIC_LISTEN
+ config_response = \
+ environment_configs.ENV_CONFIGS_WITH_SPECIFIC_LISTEN_RESPONSE
self.validate_get_request(environment_configs.URL,
- params={
- "listen": environment_configs.BOOL_LISTEN
- },
- mocks={
- read: environment_configs.
- ENV_CONFIGS_WITH_SPECIFIC_LISTEN
- },
+ params={"listen": environment_configs.
+ BOOL_LISTEN},
+ mocks={read: config},
expected_code=base.SUCCESSFUL_CODE,
- expected_response=environment_configs.
- ENV_CONFIGS_WITH_SPECIFIC_LISTEN_RESPONSE
- )
+ expected_response=config_response)
def test_get_environment_configs_list_with_non_bool_scanned(self):
self.validate_get_request(environment_configs.URL,
- params={
- "scanned": environment_configs.
- NON_BOOL_SCANNED
- },
+ params={"scanned": environment_configs.
+ NON_BOOL_SCANNED},
expected_code=base.BAD_REQUEST_CODE)
@patch(base.RESPONDER_BASE_READ)
def test_get_environment_configs_list_with_bool_scanned(self, read):
+ config = environment_configs.ENV_CONFIGS_WITH_SPECIFIC_SCANNED
+ config_response = \
+ environment_configs.ENV_CONFIGS_WITH_SPECIFIC_SCANNED_RESPONSE
self.validate_get_request(environment_configs.URL,
- params={
- "scanned": environment_configs.BOOL_SCANNED
- },
- mocks={
- read: environment_configs.
- ENV_CONFIGS_WITH_SPECIFIC_SCANNED
- },
+ params={"scanned": environment_configs.
+ BOOL_SCANNED},
+ mocks={read: config},
expected_code=base.SUCCESSFUL_CODE,
- expected_response=environment_configs.
- ENV_CONFIGS_WITH_SPECIFIC_SCANNED_RESPONSE
+ expected_response=config_response
)
- def test_get_environment_configs_list_with_non_bool_monitoring_setup_done(self):
+ def test_get_env_configs_list_with_non_bool_monitoring_setup_done(self):
self.validate_get_request(environment_configs.URL,
- params={
- "listen": environment_configs.
- NON_BOOL_MONITORING_SETUP_DONE
- },
+ params={"listen": environment_configs.
+ NON_BOOL_MONITORING_SETUP_DONE},
expected_code=base.BAD_REQUEST_CODE)
@patch(base.RESPONDER_BASE_READ)
- def test_get_environment_configs_list_with_bool_monitoring_setup_done(self, read):
+ def test_get_environment_configs_list_with_bool_monitoring_setup_done(self,
+ read):
+ config = environment_configs.\
+ ENV_CONFIGS_WITH_SPECIFIC_MONITORING_SETUP_DONE
+ config_response = environment_configs.\
+ ENV_CONFIGS_WITH_SPECIFIC_MONITORING_SETUP_DONE_RESPONSE
self.validate_get_request(environment_configs.URL,
- params={
- "scanned": environment_configs.
- BOOL_MONITORING_SETUP_DONE
- },
- mocks={
- read: environment_configs.
- ENV_CONFIGS_WITH_SPECIFIC_MONITORING_SETUP_DONE
- },
+ params={"scanned": environment_configs.
+ BOOL_MONITORING_SETUP_DONE},
+ mocks={read: config},
expected_code=base.SUCCESSFUL_CODE,
- expected_response=environment_configs.
- ENV_CONFIGS_WITH_SPECIFIC_MONITORING_SETUP_DONE_RESPONSE
- )
+ expected_response=config_response)
def test_get_environment_configs_list_with_non_int_page(self):
self.validate_get_request(environment_configs.URL,
- params={
- "page": base.NON_INT_PAGE
- },
+ params={"page": base.NON_INT_PAGE},
expected_code=base.BAD_REQUEST_CODE)
@patch(base.RESPONDER_BASE_READ)
def test_get_environment_configs_list_with_int_page(self, read):
+ config_response = environment_configs.ENV_CONFIGS_RESPONSE
self.validate_get_request(environment_configs.URL,
- params={
- "page": base.INT_PAGE
- },
- mocks={
- read: environment_configs.ENV_CONFIGS
- },
+ params={"page": base.INT_PAGE},
+ mocks={read: environment_configs.ENV_CONFIGS},
expected_code=base.SUCCESSFUL_CODE,
- expected_response=environment_configs.
- ENV_CONFIGS_RESPONSE
- )
+ expected_response=config_response)
def test_get_environment_configs_list_with_non_int_page_size(self):
self.validate_get_request(environment_configs.URL,
- params={
- "page_size": base.NON_INT_PAGESIZE
- },
+ params={"page_size": base.NON_INT_PAGESIZE},
expected_code=base.BAD_REQUEST_CODE)
@patch(base.RESPONDER_BASE_READ)
def test_get_environment_configs_list_with_int_page_size(self, read):
+ config_response = environment_configs.ENV_CONFIGS_RESPONSE
self.validate_get_request(environment_configs.URL,
- params={
- "page_size": base.INT_PAGESIZE
- },
- mocks={
- read: environment_configs.ENV_CONFIGS
- },
+ params={"page_size": base.INT_PAGESIZE},
+ mocks={read: environment_configs.ENV_CONFIGS},
expected_code=base.SUCCESSFUL_CODE,
- expected_response=environment_configs.
- ENV_CONFIGS_RESPONSE
- )
+ expected_response=config_response)
def test_post_environment_config_without_app_path(self):
test_data = self.get_updated_data(environment_configs.ENV_CONFIG,
@@ -292,8 +242,9 @@ class TestEnvironmentConfigs(TestBase):
expected_code=base.BAD_REQUEST_CODE)
def test_post_environment_config_with_wrong_distribution(self):
+ dist = environment_configs.WRONG_DISTRIBUTION
test_data = self.get_updated_data(environment_configs.ENV_CONFIG,
- updates={"distribution": environment_configs.WRONG_DISTRIBUTION})
+ updates={"distribution": dist})
self.validate_post_request(environment_configs.URL,
body=json.dumps(test_data),
expected_code=base.BAD_REQUEST_CODE)
@@ -306,8 +257,9 @@ class TestEnvironmentConfigs(TestBase):
expected_code=base.BAD_REQUEST_CODE)
def test_post_environment_config_with_wrong_listen(self):
+ listen_val = environment_configs.NON_BOOL_LISTEN
test_data = self.get_updated_data(environment_configs.ENV_CONFIG,
- updates={"listen": environment_configs.NON_BOOL_LISTEN})
+ updates={"listen": listen_val})
self.validate_post_request(environment_configs.URL,
body=json.dumps(test_data),
expected_code=base.BAD_REQUEST_CODE)
@@ -320,10 +272,10 @@ class TestEnvironmentConfigs(TestBase):
expected_code=base.BAD_REQUEST_CODE)
def test_post_environment_config_with_wrong_mechanism_driver(self):
+ mechanism = environment_configs.WRONG_MECHANISM_DRIVER
test_data = self.get_updated_data(environment_configs.ENV_CONFIG,
updates={
- "mechanism_drivers":
- [environment_configs.WRONG_MECHANISM_DRIVER]
+ "mechanism_drivers": [mechanism]
})
self.validate_post_request(environment_configs.URL,
body=json.dumps(test_data),
@@ -344,19 +296,17 @@ class TestEnvironmentConfigs(TestBase):
expected_code=base.BAD_REQUEST_CODE)
def test_post_environment_config_with_wrong_scanned(self):
+ scanned_val = environment_configs.NON_BOOL_SCANNED
test_data = self.get_updated_data(environment_configs.ENV_CONFIG,
- updates={
- "scanned": environment_configs.NON_BOOL_SCANNED
- })
+ updates={"scanned": scanned_val})
self.validate_post_request(environment_configs.URL,
body=json.dumps(test_data),
expected_code=base.BAD_REQUEST_CODE)
def test_post_environment_config_with_wrong_last_scanned(self):
+ scanned_val = base.WRONG_FORMAT_TIME
test_data = self.get_updated_data(environment_configs.ENV_CONFIG,
- updates={
- "last_scanned": base.WRONG_FORMAT_TIME
- })
+ updates={"last_scanned": scanned_val})
self.validate_post_request(environment_configs.URL,
body=json.dumps(test_data),
expected_code=base.BAD_REQUEST_CODE)
@@ -376,16 +326,81 @@ class TestEnvironmentConfigs(TestBase):
expected_code=base.BAD_REQUEST_CODE)
def test_post_environment_config_with_wrong_type_drivers(self):
+ driver = environment_configs.WRONG_TYPE_DRIVER
+ test_data = self.get_updated_data(environment_configs.ENV_CONFIG,
+ updates={"type_drivers": [driver]})
+ self.validate_post_request(environment_configs.URL,
+ body=json.dumps(test_data),
+ expected_code=base.BAD_REQUEST_CODE)
+
+ def test_post_environment_config_with_duplicate_configurations(self):
+ test_data = self.get_updated_data(environment_configs.ENV_CONFIG)
+ test_data["configuration"].append({
+ "name": "OpenStack"
+ })
+ self.validate_post_request(environment_configs.URL,
+ body=json.dumps(test_data),
+ expected_code=base.BAD_REQUEST_CODE)
+
+ def test_post_environment_config_with_empty_configuration(self):
+ test_data = self.get_updated_data(environment_configs.ENV_CONFIG)
+ test_data["configuration"].append({})
+ self.validate_post_request(environment_configs.URL,
+ body=json.dumps(test_data),
+ expected_code=base.BAD_REQUEST_CODE)
+
+ def test_post_environment_config_with_unknown_configuration(self):
+ test_data = self.get_updated_data(environment_configs.ENV_CONFIG)
+ test_data["configuration"].append({
+ "name": "Unknown configuration",
+ })
+ self.validate_post_request(environment_configs.URL,
+ body=json.dumps(test_data),
+ expected_code=base.BAD_REQUEST_CODE)
+
+ def test_post_environment_config_without_required_configurations(self):
+ for env_type in CONSTANTS_BY_NAMES["environment_types"]:
+ required_conf_list = (
+ EnvironmentConfigs.REQUIRED_CONFIGURATIONS_NAMES.get(env_type,
+ [])
+ )
+ if required_conf_list:
+ test_data = \
+ self.get_updated_data(environment_configs.ENV_CONFIG)
+ test_data['environment_type'] = env_type
+ test_data['configuration'] = [
+ c
+ for c in test_data['configuration']
+ if c['name'] != required_conf_list[0]
+ ]
+
+ self.validate_post_request(environment_configs.URL,
+ body=json.dumps(test_data),
+ expected_code=base.BAD_REQUEST_CODE)
+
+ def test_post_environment_config_with_incomplete_configuration(self):
test_data = self.get_updated_data(environment_configs.ENV_CONFIG,
updates={
- "type_drivers": [environment_configs.WRONG_TYPE_DRIVER]
+ "configuration": [{
+ "host": "10.56.20.239",
+ "name": "mysql",
+ "user": "root"
+ }, {
+ "name": "OpenStack",
+ "host": "10.56.20.239",
+ }, {
+ "host": "10.56.20.239",
+ "name": "CLI",
+ "user": "root"
+ }]
})
self.validate_post_request(environment_configs.URL,
body=json.dumps(test_data),
expected_code=base.BAD_REQUEST_CODE)
- def mock_validate_env_config_with_supported_envs(self, scanning,
- monitoring, listening):
+ @staticmethod
+ def mock_validate_env_config_with_supported_envs(scanning, monitoring,
+ listening):
InventoryMgr.is_feature_supported_in_env = \
lambda self, matches, feature: {
EnvironmentFeatures.SCANNING: scanning,
@@ -396,11 +411,12 @@ class TestEnvironmentConfigs(TestBase):
@patch(base.RESPONDER_BASE_WRITE)
def test_post_environment_config(self, write):
self.mock_validate_env_config_with_supported_envs(True, True, True)
+ post_body = json.dumps(environment_configs.ENV_CONFIG)
self.validate_post_request(environment_configs.URL,
mocks={
write: None
},
- body=json.dumps(environment_configs.ENV_CONFIG),
+ body=post_body,
expected_code=base.CREATED_CODE)
def test_post_unsupported_environment_config(self):
@@ -421,10 +437,11 @@ class TestEnvironmentConfigs(TestBase):
"listening": False
}
]
+ mock_validate = self.mock_validate_env_config_with_supported_envs
+ config = environment_configs.ENV_CONFIG
for test_case in test_cases:
- self.mock_validate_env_config_with_supported_envs(test_case["scanning"],
- test_case["monitoring"],
- test_case["listening"])
+ mock_validate(test_case["scanning"], test_case["monitoring"],
+ test_case["listening"])
self.validate_post_request(environment_configs.URL,
- body=json.dumps(environment_configs.ENV_CONFIG),
+ body=json.dumps(config),
expected_code=base.BAD_REQUEST_CODE)
diff --git a/app/test/api/responders_test/test_data/base.py b/app/test/api/responders_test/test_data/base.py
index b99d5bb..6d2422a 100644
--- a/app/test/api/responders_test/test_data/base.py
+++ b/app/test/api/responders_test/test_data/base.py
@@ -16,14 +16,14 @@ UNAUTHORIZED_CODE = "401"
CREATED_CODE = "201"
ENV_NAME = "Mirantis-Liberty-API"
-UNKNOWN_ENV = "Unkown-Environment"
+UNKNOWN_ENV = "Unknown-Environment"
NON_INT_PAGE = 1.4
INT_PAGE = 1
NON_INT_PAGESIZE = 2.4
INT_PAGESIZE = 2
WRONG_LINK_TYPE = "instance-host"
-CORRECT_LINK_TYPE= "instance-vnic"
+CORRECT_LINK_TYPE = "instance-vnic"
WRONG_LINK_STATE = "wrong"
CORRECT_LINK_STATE = "up"
@@ -41,7 +41,7 @@ WRONG_TYPE_DRIVER = "wrong_type"
CORRECT_TYPE_DRIVER = "local"
WRONG_MECHANISM_DRIVER = "wrong-mechanism-dirver"
-CORRECT_MECHANISM_DRIVER = "ovs"
+CORRECT_MECHANISM_DRIVER = "OVS"
WRONG_LOG_LEVEL = "wrong-log-level"
CORRECT_LOG_LEVEL = "critical"
@@ -71,16 +71,32 @@ NON_DICT_OBJ = ""
CONSTANTS_BY_NAMES = {
"link_types": [
"instance-vnic",
- "otep-vconnector",
- "otep-host_pnic",
+ "vnic-instance",
+ "vnic-vconnector",
+ "vconnector-vnic",
+ "vconnector-vedge",
+ "vedge-vconnector",
+ "vedge-host_pnic",
+ "host_pnic-vedge",
"host_pnic-network",
+ "network-host_pnic",
"vedge-otep",
- "vnic-vconnector",
+ "otep-vedge",
+ "otep-vconnector",
+ "vconnector-otep",
+ "otep-host_pnic",
+ "host_pnic-otep",
"vconnector-host_pnic",
- "vconnector-vedge",
+ "host_pnic-vconnector",
"vnic-vedge",
- "vedge-host_pnic",
- "vservice-vnic"
+ "vedge-vnic",
+ "vservice-vnic",
+ "vnic-vservice",
+ "switch_pnic-host_pnic",
+ "host_pnic-switch_pnic",
+ "switch_pnic-switch_pnic",
+ "switch_pnic-switch",
+ "switch-switch_pnic"
],
"link_states": [
"up",
@@ -117,9 +133,9 @@ CONSTANTS_BY_NAMES = {
"flat"
],
"mechanism_drivers": [
- "ovs",
- "vpp",
- "LinuxBridge",
+ "OVS",
+ "VPP",
+ "LXB",
"Arista",
"Nexus"
],
@@ -155,6 +171,10 @@ CONSTANTS_BY_NAMES = {
"Mirantis",
"RDO"
],
+ "distribution_versions": [
+ "8.0",
+ "9.0"
+ ],
"environment_operational_status": [
"stopped",
"running",
@@ -168,6 +188,30 @@ CONSTANTS_BY_NAMES = {
],
"environment_monitoring_types": [
"Sensu"
+ ],
+ "scans_statuses": [
+ "draft",
+ "pending",
+ "running",
+ "completed",
+ "completed_with_errors",
+ "failed",
+ "aborted"
+ ],
+ "configuration_targets": [
+ "AMQP",
+ "CLI",
+ "ACI",
+ "mysql",
+ "OpenStack",
+ "Monitoring",
+ "Kubernetes"
+ ],
+ "environment_types": [
+ "OpenStack",
+ "Kubernetes",
+ "VMware",
+ "Bare-metal"
]
}
@@ -175,7 +219,8 @@ CONSTANTS_BY_NAMES = {
RESPONDER_BASE_PATH = "api.responders.responder_base.ResponderBase"
RESPONDER_BASE_GET_OBJECTS_LIST = RESPONDER_BASE_PATH + ".get_objects_list"
RESPONDER_BASE_GET_OBJECT_BY_ID = RESPONDER_BASE_PATH + ".get_object_by_id"
-RESPONDER_BASE_CHECK_ENVIRONMENT_NAME = RESPONDER_BASE_PATH + ".check_environment_name"
+RESPONDER_BASE_CHECK_ENVIRONMENT_NAME = \
+ RESPONDER_BASE_PATH + ".check_environment_name"
RESPONDER_BASE_READ = RESPONDER_BASE_PATH + ".read"
RESPONDER_BASE_WRITE = RESPONDER_BASE_PATH + ".write"
RESPONDER_BASE_AGGREGATE = RESPONDER_BASE_PATH + ".aggregate"
diff --git a/app/test/api/responders_test/test_data/clique_types.py b/app/test/api/responders_test/test_data/clique_types.py
index ae962ce..0791bdf 100644
--- a/app/test/api/responders_test/test_data/clique_types.py
+++ b/app/test/api/responders_test/test_data/clique_types.py
@@ -8,13 +8,18 @@
# http://www.apache.org/licenses/LICENSE-2.0 #
###############################################################################
from test.api.responders_test.test_data import base
-
+from test.api.responders_test.test_data.base import WRONG_MECHANISM_DRIVER, \
+ CORRECT_MECHANISM_DRIVER, CORRECT_TYPE_DRIVER, WRONG_TYPE_DRIVER, \
+ CORRECT_DISTRIBUTION, CORRECT_DIST_VER
URL = "/clique_types"
WRONG_ID = base.WRONG_OBJECT_ID
NONEXISTENT_ID = "58ca73ae3a8a836d10ff3b44"
CORRECT_ID = base.CORRECT_OBJECT_ID
+SAMPLE_IDS = ['58ca73ae3a8a836d10ff3b80', '58ca73ae3a8a836d10ff3b81']
+
+RESERVED_ENV_NAME = 'ANY'
WRONG_FOCAL_POINT_TYPE = base.WRONG_OBJECT_TYPE
CORRECT_FOCAL_POINT_POINT_TYPE = base.CORRECT_OBJECT_TYPE
@@ -23,25 +28,52 @@ WRONG_LINK_TYPE = base.WRONG_LINK_TYPE
NONEXISTENT_LINK_TYPE = "otep-host_pnic"
CORRECT_LINK_TYPE = base.CORRECT_LINK_TYPE
+CLIQUE_TYPE = {
+ "environment": "Mirantis-Liberty-API",
+ "name": "instance_vconnector_clique",
+ "link_types": [
+ "instance-vnic",
+ "vnic-vconnector"
+ ],
+ "focal_point_type": "instance"
+}
+
+TEST_CONFIGURATION = {
+ "distribution": CORRECT_DISTRIBUTION,
+ "distribution_version": CORRECT_DIST_VER,
+ "mechanism_drivers": CORRECT_MECHANISM_DRIVER,
+ "type_drivers": CORRECT_TYPE_DRIVER
+}
+
+
+def get_payload(update: dict = None, delete: list = None):
+ payload = CLIQUE_TYPE.copy()
+ if update:
+ payload.update(update)
+ if delete:
+ for k in delete:
+ del payload[k]
+ return payload
+
+
CLIQUE_TYPES_WITH_SPECIFIC_ID = [
- {
- "environment": "Mirantis-Liberty-API",
- "focal_point_type": "host_pnic",
- "id": CORRECT_ID
- }
+ get_payload(update={'id': CORRECT_ID})
+]
+
+CLIQUE_TYPES_WITH_SPECIFIC_CONFIGURATION = [
+ get_payload(update={'id': SAMPLE_IDS[0],
+ **TEST_CONFIGURATION},
+ delete=['environment'])
]
+CLIQUE_TYPES_WITH_SPECIFIC_CONFIGURATION_RESPONSE = {
+ "clique_types": CLIQUE_TYPES_WITH_SPECIFIC_CONFIGURATION
+}
+
CLIQUE_TYPES_WITH_SPECIFIC_FOCAL_POINT_TYPE = [
- {
- "environment": "Mirantis-Liberty-API",
- "focal_point_type": CORRECT_FOCAL_POINT_POINT_TYPE,
- "id": "58ca73ae3a8a836d10ff3b80"
- },
- {
- "environment": "Mirantis-Liberty-API",
- "focal_point_type": CORRECT_FOCAL_POINT_POINT_TYPE,
- "id": "58ca73ae3a8a836d10ff3b81"
- }
+ get_payload(update={'id': _id,
+ 'focal_point_type': CORRECT_FOCAL_POINT_POINT_TYPE})
+ for _id in SAMPLE_IDS
]
CLIQUE_TYPES_WITH_SPECIFIC_FOCAL_POINT_TYPE_RESPONSE = {
@@ -49,20 +81,9 @@ CLIQUE_TYPES_WITH_SPECIFIC_FOCAL_POINT_TYPE_RESPONSE = {
}
CLIQUE_TYPES_WITH_SPECIFIC_LINK_TYPE = [
- {
- "environment": "Mirantis-Liberty-API",
- "link_types": [
- CORRECT_LINK_TYPE
- ],
- "id": "58ca73ae3a8a836d10ff3b80"
- },
- {
- "environment": "Mirantis-Liberty-API",
- "link_types": [
- CORRECT_LINK_TYPE
- ],
- "id": "58ca73ae3a8a836d10ff3b81"
- }
+ get_payload(update={'id': _id,
+ 'link_types': [CORRECT_LINK_TYPE]})
+ for _id in SAMPLE_IDS
]
CLIQUE_TYPES_WITH_SPECIFIC_LINK_TYPE_RESPONSE = {
@@ -70,16 +91,7 @@ CLIQUE_TYPES_WITH_SPECIFIC_LINK_TYPE_RESPONSE = {
}
CLIQUE_TYPES = [
- {
- "environment": "Mirantis-Liberty-API",
- "focal_point_type": "vnic",
- "id": "58ca73ae3a8a836d10ff3b80"
- },
- {
- "environment": "Mirantis-Liberty-API",
- "focal_point_type": "vnic",
- "id": "58ca73ae3a8a836d10ff3b81"
- }
+ get_payload(update={'id': _id}) for _id in SAMPLE_IDS
]
CLIQUE_TYPES_RESPONSE = {
@@ -88,83 +100,48 @@ CLIQUE_TYPES_RESPONSE = {
NON_DICT_CLIQUE_TYPE = base.NON_DICT_OBJ
-CLIQUE_TYPE_WITHOUT_ENVIRONMENT = {
- "name": "instance_vconnector_clique",
- "link_types": [
- "instance-vnic",
- "vnic-vconnector"
- ],
- "focal_point_type": "instance"
-}
+CLIQUE_TYPE_WITH_RESERVED_NAME = get_payload(
+ update={'environment': RESERVED_ENV_NAME}
+)
-CLIQUE_TYPE_WITH_UNKNOWN_ENVIRONMENT = {
- "environment": base.UNKNOWN_ENV,
- "id": "589a3969761b0555a3ef6093",
- "name": "instance_vconnector_clique",
- "link_types": [
- "instance-vnic",
- "vnic-vconnector"
- ],
- "focal_point_type": "instance"
-}
+CLIQUE_TYPE_WITHOUT_ENV_NAME_AND_CONF = get_payload(
+ delete=['environment']
+)
-CLIQUE_TYPE_WITHOUT_FOCAL_POINT_TYPE = {
- "environment": "Mirantis-Liberty-API",
- "name": "instance_vconnector_clique",
- "link_types": [
- "instance-vnic",
- "vnic-vconnector"
- ]
-}
+CLIQUE_TYPE_WITH_BOTH_ENV_AND_CONF = get_payload(
+ update=TEST_CONFIGURATION
+)
-CLIQUE_TYPE_WITH_WRONG_FOCAL_POINT_TYPE = {
- "environment": "Mirantis-Liberty-API",
- "name": "instance_vconnector_clique",
- "link_types": [
- "instance-vnic",
- "vnic-vconnector"
- ],
- "focal_point_type": WRONG_FOCAL_POINT_TYPE
-}
+CLIQUE_TYPE_WITH_INSUFFICIENT_CONF = get_payload(
+ update={'distribution_version': CORRECT_DIST_VER}
+)
-CLIQUE_TYPE_WITHOUT_LINK_TYPES = {
- "environment": "Mirantis-Liberty-API",
- "name": "instance_vconnector_clique",
- "focal_point_type": "instance"
-}
+CLIQUE_TYPE_WITH_UNKNOWN_ENVIRONMENT = get_payload(
+ update={'environment': base.UNKNOWN_ENV}
+)
-CLIQUE_TYPE_WITH_NON_LIST_LINK_TYPES = {
- "environment": "Mirantis-Liberty-API",
- "name": "instance_vconnector_clique",
- "link_types": "instance-vnic",
- "focal_point_type": "instance"
-}
+CLIQUE_TYPE_WITHOUT_FOCAL_POINT_TYPE = get_payload(delete=['focal_point_type'])
-CLIQUE_TYPE_WITH_WRONG_LINK_TYPE = {
- "environment": "Mirantis-Liberty-API",
- "name": "instance_vconnector_clique",
- "link_types": [
- WRONG_LINK_TYPE,
- "vnic-vconnector"
- ],
- "focal_point_type": "instance"
-}
+CLIQUE_TYPE_WITH_WRONG_FOCAL_POINT_TYPE = get_payload(
+ update={'focal_point_type': WRONG_FOCAL_POINT_TYPE}
+)
-CLIQUE_TYPE_WITHOUT_NAME = {
- "environment": "Mirantis-Liberty-API",
- "link_types": [
- "instance-vnic",
- "vnic-vconnector",
- ],
- "focal_point_type": "instance"
-}
+CLIQUE_TYPE_WITHOUT_LINK_TYPES = get_payload(delete=['link_types'])
-CLIQUE_TYPE = {
- "environment": "Mirantis-Liberty-API",
- "name": "instance_vconnector_clique",
- "link_types": [
- "instance-vnic",
- "vnic-vconnector"
- ],
- "focal_point_type": "instance"
-}
+CLIQUE_TYPE_WITH_NON_LIST_LINK_TYPES = get_payload(
+ update={'link_types': "instance-vnic"}
+)
+
+CLIQUE_TYPE_WITH_WRONG_LINK_TYPE = get_payload(
+ update={'link_types': [WRONG_LINK_TYPE, "vnic-vconnector"]}
+)
+
+CLIQUE_TYPE_WITHOUT_NAME = get_payload(delete=['name'])
+
+CLIQUE_TYPE_WITH_WRONG_MECH_DRIVERS = get_payload(
+ update={'mechanism_drivers': WRONG_MECHANISM_DRIVER}
+)
+
+CLIQUE_TYPE_WITH_WRONG_TYPE_DRIVERS = get_payload(
+ update={'type_drivers': WRONG_TYPE_DRIVER}
+) \ No newline at end of file
diff --git a/app/test/api/responders_test/test_data/environment_configs.py b/app/test/api/responders_test/test_data/environment_configs.py
index 4cea105..3e976ec 100644
--- a/app/test/api/responders_test/test_data/environment_configs.py
+++ b/app/test/api/responders_test/test_data/environment_configs.py
@@ -201,6 +201,7 @@ ENV_CONFIG = {
"provision": "None",
"env_type": "development",
"name": "Monitoring",
+ "install_monitoring_client": True,
"api_port": "4567",
"rabbitmq_port": "5671",
"rabbitmq_pass": "sensuaccess",
@@ -218,12 +219,13 @@ ENV_CONFIG = {
"last_scanned": "2017-03-16T11:14:54Z",
"listen": True,
"mechanism_drivers": [
- "ovs"
+ "OVS"
],
"name": "Mirantis-Liberty",
"operational": "running",
"scanned": True,
"type": "environment",
"type_drivers": "vxlan",
- "user": "WS7j8oTbWPf3LbNne"
+ "user": "WS7j8oTbWPf3LbNne",
+ "environment_type": "OpenStack"
}