mcp-proxy-adapter 2.0.1__py3-none-any.whl โ 6.9.50__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mcp-proxy-adapter might be problematic. Click here for more details.
- mcp_proxy_adapter/__init__.py +47 -0
- mcp_proxy_adapter/__main__.py +13 -0
- mcp_proxy_adapter/api/__init__.py +0 -0
- mcp_proxy_adapter/api/app.py +66 -0
- mcp_proxy_adapter/api/core/__init__.py +18 -0
- mcp_proxy_adapter/api/core/app_factory.py +400 -0
- mcp_proxy_adapter/api/core/lifespan_manager.py +55 -0
- mcp_proxy_adapter/api/core/registration_context.py +356 -0
- mcp_proxy_adapter/api/core/registration_manager.py +307 -0
- mcp_proxy_adapter/api/core/registration_tasks.py +84 -0
- mcp_proxy_adapter/api/core/ssl_context_factory.py +88 -0
- mcp_proxy_adapter/api/handlers.py +181 -0
- mcp_proxy_adapter/api/middleware/__init__.py +21 -0
- mcp_proxy_adapter/api/middleware/base.py +54 -0
- mcp_proxy_adapter/api/middleware/command_permission_middleware.py +73 -0
- mcp_proxy_adapter/api/middleware/error_handling.py +76 -0
- mcp_proxy_adapter/api/middleware/factory.py +147 -0
- mcp_proxy_adapter/api/middleware/logging.py +31 -0
- mcp_proxy_adapter/api/middleware/performance.py +51 -0
- mcp_proxy_adapter/api/middleware/protocol_middleware.py +140 -0
- mcp_proxy_adapter/api/middleware/transport_middleware.py +87 -0
- mcp_proxy_adapter/api/middleware/unified_security.py +223 -0
- mcp_proxy_adapter/api/middleware/user_info_middleware.py +132 -0
- mcp_proxy_adapter/api/openapi/__init__.py +21 -0
- mcp_proxy_adapter/api/openapi/command_integration.py +105 -0
- mcp_proxy_adapter/api/openapi/openapi_generator.py +40 -0
- mcp_proxy_adapter/api/openapi/openapi_registry.py +62 -0
- mcp_proxy_adapter/api/openapi/schema_loader.py +116 -0
- mcp_proxy_adapter/api/schemas.py +270 -0
- mcp_proxy_adapter/api/tool_integration.py +131 -0
- mcp_proxy_adapter/api/tools.py +163 -0
- mcp_proxy_adapter/cli/__init__.py +12 -0
- mcp_proxy_adapter/cli/commands/__init__.py +15 -0
- mcp_proxy_adapter/cli/commands/client.py +100 -0
- mcp_proxy_adapter/cli/commands/config_generate.py +105 -0
- mcp_proxy_adapter/cli/commands/config_validate.py +94 -0
- mcp_proxy_adapter/cli/commands/generate.py +259 -0
- mcp_proxy_adapter/cli/commands/server.py +174 -0
- mcp_proxy_adapter/cli/commands/sets.py +132 -0
- mcp_proxy_adapter/cli/commands/testconfig.py +177 -0
- mcp_proxy_adapter/cli/examples/__init__.py +8 -0
- mcp_proxy_adapter/cli/examples/http_basic.py +82 -0
- mcp_proxy_adapter/cli/examples/https_token.py +96 -0
- mcp_proxy_adapter/cli/examples/mtls_roles.py +103 -0
- mcp_proxy_adapter/cli/main.py +63 -0
- mcp_proxy_adapter/cli/parser.py +338 -0
- mcp_proxy_adapter/cli/validators.py +231 -0
- mcp_proxy_adapter/client/jsonrpc_client/__init__.py +9 -0
- mcp_proxy_adapter/client/jsonrpc_client/client.py +42 -0
- mcp_proxy_adapter/client/jsonrpc_client/command_api.py +45 -0
- mcp_proxy_adapter/client/jsonrpc_client/proxy_api.py +224 -0
- mcp_proxy_adapter/client/jsonrpc_client/queue_api.py +60 -0
- mcp_proxy_adapter/client/jsonrpc_client/transport.py +108 -0
- mcp_proxy_adapter/client/proxy.py +123 -0
- mcp_proxy_adapter/commands/__init__.py +66 -0
- mcp_proxy_adapter/commands/auth_validation_command.py +69 -0
- mcp_proxy_adapter/commands/base.py +389 -0
- mcp_proxy_adapter/commands/builtin_commands.py +30 -0
- mcp_proxy_adapter/commands/catalog/__init__.py +20 -0
- mcp_proxy_adapter/commands/catalog/catalog_loader.py +34 -0
- mcp_proxy_adapter/commands/catalog/catalog_manager.py +122 -0
- mcp_proxy_adapter/commands/catalog/catalog_syncer.py +149 -0
- mcp_proxy_adapter/commands/catalog/command_catalog.py +43 -0
- mcp_proxy_adapter/commands/catalog/dependency_manager.py +37 -0
- mcp_proxy_adapter/commands/catalog_manager.py +97 -0
- mcp_proxy_adapter/commands/cert_monitor_command.py +552 -0
- mcp_proxy_adapter/commands/certificate_management_command.py +562 -0
- mcp_proxy_adapter/commands/command_registry.py +298 -0
- mcp_proxy_adapter/commands/config_command.py +102 -0
- mcp_proxy_adapter/commands/dependency_container.py +40 -0
- mcp_proxy_adapter/commands/dependency_manager.py +143 -0
- mcp_proxy_adapter/commands/echo_command.py +48 -0
- mcp_proxy_adapter/commands/health_command.py +142 -0
- mcp_proxy_adapter/commands/help_command.py +175 -0
- mcp_proxy_adapter/commands/hooks.py +172 -0
- mcp_proxy_adapter/commands/key_management_command.py +484 -0
- mcp_proxy_adapter/commands/load_command.py +123 -0
- mcp_proxy_adapter/commands/plugins_command.py +246 -0
- mcp_proxy_adapter/commands/protocol_management_command.py +216 -0
- mcp_proxy_adapter/commands/proxy_registration_command.py +319 -0
- mcp_proxy_adapter/commands/queue_commands.py +750 -0
- mcp_proxy_adapter/commands/registration_status_command.py +76 -0
- mcp_proxy_adapter/commands/registry/__init__.py +18 -0
- mcp_proxy_adapter/commands/registry/command_info.py +103 -0
- mcp_proxy_adapter/commands/registry/command_loader.py +207 -0
- mcp_proxy_adapter/commands/registry/command_manager.py +119 -0
- mcp_proxy_adapter/commands/registry/command_registry.py +217 -0
- mcp_proxy_adapter/commands/reload_command.py +136 -0
- mcp_proxy_adapter/commands/result.py +157 -0
- mcp_proxy_adapter/commands/role_test_command.py +99 -0
- mcp_proxy_adapter/commands/roles_management_command.py +502 -0
- mcp_proxy_adapter/commands/security_command.py +472 -0
- mcp_proxy_adapter/commands/settings_command.py +113 -0
- mcp_proxy_adapter/commands/ssl_setup_command.py +306 -0
- mcp_proxy_adapter/commands/token_management_command.py +500 -0
- mcp_proxy_adapter/commands/transport_management_command.py +129 -0
- mcp_proxy_adapter/commands/unload_command.py +92 -0
- mcp_proxy_adapter/config.py +32 -0
- mcp_proxy_adapter/core/__init__.py +8 -0
- mcp_proxy_adapter/core/app_factory.py +560 -0
- mcp_proxy_adapter/core/app_runner.py +318 -0
- mcp_proxy_adapter/core/auth_validator.py +508 -0
- mcp_proxy_adapter/core/certificate/__init__.py +20 -0
- mcp_proxy_adapter/core/certificate/certificate_creator.py +372 -0
- mcp_proxy_adapter/core/certificate/certificate_extractor.py +185 -0
- mcp_proxy_adapter/core/certificate/certificate_utils.py +249 -0
- mcp_proxy_adapter/core/certificate/certificate_validator.py +481 -0
- mcp_proxy_adapter/core/certificate/ssl_context_manager.py +65 -0
- mcp_proxy_adapter/core/certificate_utils.py +249 -0
- mcp_proxy_adapter/core/client.py +608 -0
- mcp_proxy_adapter/core/client_manager.py +271 -0
- mcp_proxy_adapter/core/client_security.py +411 -0
- mcp_proxy_adapter/core/config/__init__.py +18 -0
- mcp_proxy_adapter/core/config/config.py +237 -0
- mcp_proxy_adapter/core/config/config_factory.py +22 -0
- mcp_proxy_adapter/core/config/config_loader.py +66 -0
- mcp_proxy_adapter/core/config/feature_manager.py +31 -0
- mcp_proxy_adapter/core/config/simple_config.py +204 -0
- mcp_proxy_adapter/core/config/simple_config_generator.py +131 -0
- mcp_proxy_adapter/core/config/simple_config_validator.py +476 -0
- mcp_proxy_adapter/core/config_converter.py +252 -0
- mcp_proxy_adapter/core/config_validator.py +211 -0
- mcp_proxy_adapter/core/crl_utils.py +362 -0
- mcp_proxy_adapter/core/errors.py +276 -0
- mcp_proxy_adapter/core/job_manager.py +54 -0
- mcp_proxy_adapter/core/logging.py +250 -0
- mcp_proxy_adapter/core/mtls_asgi.py +140 -0
- mcp_proxy_adapter/core/mtls_asgi_app.py +187 -0
- mcp_proxy_adapter/core/mtls_proxy.py +229 -0
- mcp_proxy_adapter/core/mtls_server.py +154 -0
- mcp_proxy_adapter/core/protocol_manager.py +232 -0
- mcp_proxy_adapter/core/proxy/__init__.py +19 -0
- mcp_proxy_adapter/core/proxy/auth_manager.py +26 -0
- mcp_proxy_adapter/core/proxy/proxy_registration_manager.py +160 -0
- mcp_proxy_adapter/core/proxy/registration_client.py +186 -0
- mcp_proxy_adapter/core/proxy/ssl_manager.py +101 -0
- mcp_proxy_adapter/core/proxy_client.py +184 -0
- mcp_proxy_adapter/core/proxy_registration.py +80 -0
- mcp_proxy_adapter/core/role_utils.py +103 -0
- mcp_proxy_adapter/core/security_adapter.py +343 -0
- mcp_proxy_adapter/core/security_factory.py +96 -0
- mcp_proxy_adapter/core/security_integration.py +342 -0
- mcp_proxy_adapter/core/server_adapter.py +251 -0
- mcp_proxy_adapter/core/server_engine.py +217 -0
- mcp_proxy_adapter/core/settings.py +260 -0
- mcp_proxy_adapter/core/signal_handler.py +107 -0
- mcp_proxy_adapter/core/ssl_utils.py +161 -0
- mcp_proxy_adapter/core/transport_manager.py +153 -0
- mcp_proxy_adapter/core/unified_config_adapter.py +471 -0
- mcp_proxy_adapter/core/utils.py +101 -0
- mcp_proxy_adapter/core/validation/__init__.py +21 -0
- mcp_proxy_adapter/core/validation/config_validator.py +219 -0
- mcp_proxy_adapter/core/validation/file_validator.py +131 -0
- mcp_proxy_adapter/core/validation/protocol_validator.py +205 -0
- mcp_proxy_adapter/core/validation/security_validator.py +140 -0
- mcp_proxy_adapter/core/validation/validation_result.py +27 -0
- mcp_proxy_adapter/custom_openapi.py +58 -0
- mcp_proxy_adapter/examples/__init__.py +16 -0
- mcp_proxy_adapter/examples/basic_framework/__init__.py +9 -0
- mcp_proxy_adapter/examples/basic_framework/commands/__init__.py +4 -0
- mcp_proxy_adapter/examples/basic_framework/hooks/__init__.py +4 -0
- mcp_proxy_adapter/examples/basic_framework/main.py +52 -0
- mcp_proxy_adapter/examples/bugfix_certificate_config.py +261 -0
- mcp_proxy_adapter/examples/cert_manager_bugfix.py +203 -0
- mcp_proxy_adapter/examples/check_config.py +413 -0
- mcp_proxy_adapter/examples/client_usage_example.py +164 -0
- mcp_proxy_adapter/examples/commands/__init__.py +5 -0
- mcp_proxy_adapter/examples/config_builder.py +234 -0
- mcp_proxy_adapter/examples/config_cli.py +282 -0
- mcp_proxy_adapter/examples/create_test_configs.py +174 -0
- mcp_proxy_adapter/examples/debug_request_state.py +130 -0
- mcp_proxy_adapter/examples/debug_role_chain.py +191 -0
- mcp_proxy_adapter/examples/demo_client.py +287 -0
- mcp_proxy_adapter/examples/full_application/__init__.py +12 -0
- mcp_proxy_adapter/examples/full_application/commands/__init__.py +8 -0
- mcp_proxy_adapter/examples/full_application/commands/custom_echo_command.py +45 -0
- mcp_proxy_adapter/examples/full_application/commands/dynamic_calculator_command.py +52 -0
- mcp_proxy_adapter/examples/full_application/commands/echo_command.py +32 -0
- mcp_proxy_adapter/examples/full_application/commands/help_command.py +54 -0
- mcp_proxy_adapter/examples/full_application/commands/list_command.py +57 -0
- mcp_proxy_adapter/examples/full_application/hooks/__init__.py +5 -0
- mcp_proxy_adapter/examples/full_application/hooks/application_hooks.py +29 -0
- mcp_proxy_adapter/examples/full_application/hooks/builtin_command_hooks.py +27 -0
- mcp_proxy_adapter/examples/full_application/main.py +311 -0
- mcp_proxy_adapter/examples/full_application/proxy_endpoints.py +161 -0
- mcp_proxy_adapter/examples/full_application/run_mtls.py +252 -0
- mcp_proxy_adapter/examples/full_application/run_simple.py +152 -0
- mcp_proxy_adapter/examples/full_application/test_minimal_server.py +45 -0
- mcp_proxy_adapter/examples/full_application/test_server.py +163 -0
- mcp_proxy_adapter/examples/full_application/test_simple_server.py +62 -0
- mcp_proxy_adapter/examples/generate_config.py +502 -0
- mcp_proxy_adapter/examples/proxy_registration_example.py +335 -0
- mcp_proxy_adapter/examples/queue_demo_simple.py +632 -0
- mcp_proxy_adapter/examples/queue_integration_example.py +578 -0
- mcp_proxy_adapter/examples/queue_server_demo.py +82 -0
- mcp_proxy_adapter/examples/queue_server_example.py +85 -0
- mcp_proxy_adapter/examples/queue_server_simple.py +173 -0
- mcp_proxy_adapter/examples/required_certificates.py +208 -0
- mcp_proxy_adapter/examples/run_example.py +77 -0
- mcp_proxy_adapter/examples/run_full_test_suite.py +619 -0
- mcp_proxy_adapter/examples/run_proxy_server.py +153 -0
- mcp_proxy_adapter/examples/run_security_tests_fixed.py +435 -0
- mcp_proxy_adapter/examples/security_test/__init__.py +18 -0
- mcp_proxy_adapter/examples/security_test/auth_manager.py +14 -0
- mcp_proxy_adapter/examples/security_test/ssl_context_manager.py +28 -0
- mcp_proxy_adapter/examples/security_test/test_client.py +159 -0
- mcp_proxy_adapter/examples/security_test/test_result.py +22 -0
- mcp_proxy_adapter/examples/security_test_client.py +72 -0
- mcp_proxy_adapter/examples/setup/__init__.py +24 -0
- mcp_proxy_adapter/examples/setup/certificate_manager.py +215 -0
- mcp_proxy_adapter/examples/setup/config_generator.py +12 -0
- mcp_proxy_adapter/examples/setup/config_validator.py +118 -0
- mcp_proxy_adapter/examples/setup/environment_setup.py +62 -0
- mcp_proxy_adapter/examples/setup/test_files_generator.py +10 -0
- mcp_proxy_adapter/examples/setup/test_runner.py +89 -0
- mcp_proxy_adapter/examples/setup_test_environment.py +235 -0
- mcp_proxy_adapter/examples/simple_protocol_test.py +125 -0
- mcp_proxy_adapter/examples/test_chk_hostname_automated.py +211 -0
- mcp_proxy_adapter/examples/test_config.py +205 -0
- mcp_proxy_adapter/examples/test_config_builder.py +110 -0
- mcp_proxy_adapter/examples/test_examples.py +308 -0
- mcp_proxy_adapter/examples/test_framework_complete.py +267 -0
- mcp_proxy_adapter/examples/test_mcp_server.py +187 -0
- mcp_proxy_adapter/examples/test_protocol_examples.py +337 -0
- mcp_proxy_adapter/examples/universal_client.py +674 -0
- mcp_proxy_adapter/examples/update_config_certificates.py +135 -0
- mcp_proxy_adapter/examples/validate_generator_compatibility.py +385 -0
- mcp_proxy_adapter/examples/validate_generator_compatibility_simple.py +61 -0
- mcp_proxy_adapter/integrations/__init__.py +25 -0
- mcp_proxy_adapter/integrations/queuemgr_integration.py +462 -0
- mcp_proxy_adapter/main.py +311 -0
- mcp_proxy_adapter/openapi.py +375 -0
- mcp_proxy_adapter/schemas/base_schema.json +114 -0
- mcp_proxy_adapter/schemas/openapi_schema.json +314 -0
- mcp_proxy_adapter/schemas/roles.json +37 -0
- mcp_proxy_adapter/schemas/roles_schema.json +162 -0
- mcp_proxy_adapter/version.py +5 -0
- mcp_proxy_adapter-6.9.50.dist-info/METADATA +1088 -0
- mcp_proxy_adapter-6.9.50.dist-info/RECORD +242 -0
- {mcp_proxy_adapter-2.0.1.dist-info โ mcp_proxy_adapter-6.9.50.dist-info}/WHEEL +1 -1
- mcp_proxy_adapter-6.9.50.dist-info/entry_points.txt +14 -0
- mcp_proxy_adapter-6.9.50.dist-info/top_level.txt +1 -0
- adapters/__init__.py +0 -16
- analyzers/__init__.py +0 -14
- analyzers/docstring_analyzer.py +0 -199
- analyzers/type_analyzer.py +0 -151
- cli/__init__.py +0 -12
- cli/__main__.py +0 -79
- cli/command_runner.py +0 -233
- dispatchers/__init__.py +0 -14
- dispatchers/base_dispatcher.py +0 -85
- dispatchers/json_rpc_dispatcher.py +0 -198
- generators/__init__.py +0 -14
- generators/endpoint_generator.py +0 -172
- generators/openapi_generator.py +0 -254
- generators/rest_api_generator.py +0 -207
- mcp_proxy_adapter-2.0.1.dist-info/METADATA +0 -272
- mcp_proxy_adapter-2.0.1.dist-info/RECORD +0 -28
- mcp_proxy_adapter-2.0.1.dist-info/licenses/LICENSE +0 -21
- mcp_proxy_adapter-2.0.1.dist-info/top_level.txt +0 -7
- openapi_schema/__init__.py +0 -38
- openapi_schema/command_registry.py +0 -312
- openapi_schema/rest_schema.py +0 -510
- openapi_schema/rpc_generator.py +0 -307
- openapi_schema/rpc_schema.py +0 -416
- validators/__init__.py +0 -14
- validators/base_validator.py +0 -23
- validators/docstring_validator.py +0 -75
- validators/metadata_validator.py +0 -76
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Author: Vasiliy Zdanovskiy
|
|
3
|
+
email: vasilyvz@gmail.com
|
|
4
|
+
|
|
5
|
+
Test runner for MCP Proxy Adapter test environment setup.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import time
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import bool
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _test_basic_connectivity() -> bool:
|
|
18
|
+
"""Test basic network connectivity."""
|
|
19
|
+
try:
|
|
20
|
+
import socket
|
|
21
|
+
|
|
22
|
+
# Test if we can create a socket
|
|
23
|
+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
|
24
|
+
s.settimeout(1)
|
|
25
|
+
# This is a basic connectivity test
|
|
26
|
+
print("โ
Basic connectivity test passed")
|
|
27
|
+
return True
|
|
28
|
+
|
|
29
|
+
except Exception as e:
|
|
30
|
+
print(f"โ Basic connectivity test failed: {e}")
|
|
31
|
+
return False
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _test_configuration_validation() -> bool:
|
|
35
|
+
"""Test configuration validation."""
|
|
36
|
+
try:
|
|
37
|
+
from .config_validator import ConfigurationValidator
|
|
38
|
+
|
|
39
|
+
validator = ConfigurationValidator()
|
|
40
|
+
|
|
41
|
+
# Test valid configuration
|
|
42
|
+
valid_config = {
|
|
43
|
+
"protocols": {"enabled": True, "allowed_protocols": ["https"]},
|
|
44
|
+
"security": {"ssl": {"enabled": True}}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
is_valid, errors, warnings = validator.validate_config(valid_config, "test")
|
|
48
|
+
|
|
49
|
+
if is_valid:
|
|
50
|
+
print("โ
Configuration validation test passed")
|
|
51
|
+
return True
|
|
52
|
+
else:
|
|
53
|
+
print(f"โ Configuration validation test failed: {errors}")
|
|
54
|
+
return False
|
|
55
|
+
|
|
56
|
+
except Exception as e:
|
|
57
|
+
print(f"โ Configuration validation test failed: {e}")
|
|
58
|
+
return False
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _test_certificates() -> bool:
|
|
62
|
+
"""Test certificate files."""
|
|
63
|
+
try:
|
|
64
|
+
certs_dir = Path("certs")
|
|
65
|
+
keys_dir = Path("keys")
|
|
66
|
+
|
|
67
|
+
if not certs_dir.exists() or not keys_dir.exists():
|
|
68
|
+
print("โ ๏ธ Certificate directories not found, skipping certificate test")
|
|
69
|
+
return True
|
|
70
|
+
|
|
71
|
+
# Check for required certificate files
|
|
72
|
+
required_files = [
|
|
73
|
+
certs_dir / "ca_cert.pem",
|
|
74
|
+
certs_dir / "localhost_server.crt",
|
|
75
|
+
keys_dir / "server_key.pem"
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
missing_files = [f for f in required_files if not f.exists()]
|
|
79
|
+
|
|
80
|
+
if missing_files:
|
|
81
|
+
print(f"โ ๏ธ Missing certificate files: {missing_files}")
|
|
82
|
+
return False
|
|
83
|
+
|
|
84
|
+
print("โ
Certificate test passed")
|
|
85
|
+
return True
|
|
86
|
+
|
|
87
|
+
except Exception as e:
|
|
88
|
+
print(f"โ Certificate test failed: {e}")
|
|
89
|
+
return False
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Author: Vasiliy Zdanovskiy
|
|
4
|
+
email: vasilyvz@gmail.com
|
|
5
|
+
|
|
6
|
+
Enhanced script for setting up test environment for MCP Proxy Adapter.
|
|
7
|
+
Prepares the test environment with all necessary files, directories, and configurations.
|
|
8
|
+
Includes comprehensive documentation and validation for configuration settings.
|
|
9
|
+
|
|
10
|
+
This script accepts an output directory and copies required example files
|
|
11
|
+
and helper scripts into that directory, creating a ready-to-use workspace.
|
|
12
|
+
By default, the current working directory is used, so end-users can run
|
|
13
|
+
it in their project root after installing this framework in a virtual
|
|
14
|
+
environment.
|
|
15
|
+
|
|
16
|
+
Features:
|
|
17
|
+
- Comprehensive configuration documentation
|
|
18
|
+
- Validation of mutually exclusive settings
|
|
19
|
+
- Protocol-aware configuration generation
|
|
20
|
+
- Enhanced error handling and troubleshooting
|
|
21
|
+
"""
|
|
22
|
+
import os
|
|
23
|
+
import sys
|
|
24
|
+
import argparse
|
|
25
|
+
from pathlib import Path
|
|
26
|
+
|
|
27
|
+
# Import mcp_security_framework
|
|
28
|
+
try:
|
|
29
|
+
CertificateConfig,
|
|
30
|
+
CAConfig,
|
|
31
|
+
ServerCertConfig,
|
|
32
|
+
ClientCertConfig,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
SECURITY_FRAMEWORK_AVAILABLE = True
|
|
36
|
+
except ImportError:
|
|
37
|
+
SECURITY_FRAMEWORK_AVAILABLE = False
|
|
38
|
+
print("Warning: mcp_security_framework not available")
|
|
39
|
+
|
|
40
|
+
# Import setup modules
|
|
41
|
+
ConfigurationValidator,
|
|
42
|
+
create_test_files,
|
|
43
|
+
create_configuration_documentation,
|
|
44
|
+
generate_enhanced_configurations,
|
|
45
|
+
generate_certificates_with_framework,
|
|
46
|
+
test_proxy_registration,
|
|
47
|
+
run_full_test_suite,
|
|
48
|
+
setup_test_environment,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _get_package_paths() -> tuple[Path, Path]:
|
|
53
|
+
"""
|
|
54
|
+
Get paths to the package and examples directory.
|
|
55
|
+
|
|
56
|
+
Returns:
|
|
57
|
+
Tuple of (package_path, examples_path)
|
|
58
|
+
"""
|
|
59
|
+
# Get the directory containing this script
|
|
60
|
+
script_dir = Path(__file__).parent.absolute()
|
|
61
|
+
|
|
62
|
+
# Package path is the parent of examples
|
|
63
|
+
package_path = script_dir.parent
|
|
64
|
+
|
|
65
|
+
# Examples path
|
|
66
|
+
examples_path = script_dir
|
|
67
|
+
|
|
68
|
+
return package_path, examples_path
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def validate_output_directory(output_dir: Path) -> bool:
|
|
72
|
+
"""
|
|
73
|
+
Validate that the output directory is suitable for setup.
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
output_dir: Directory to validate
|
|
77
|
+
|
|
78
|
+
Returns:
|
|
79
|
+
True if valid, False otherwise
|
|
80
|
+
"""
|
|
81
|
+
try:
|
|
82
|
+
# Check if directory exists
|
|
83
|
+
if not output_dir.exists():
|
|
84
|
+
print(f"๐ Creating output directory: {output_dir}")
|
|
85
|
+
output_dir.mkdir(parents=True, exist_ok=True)
|
|
86
|
+
return True
|
|
87
|
+
|
|
88
|
+
# Check if directory is writable
|
|
89
|
+
if not os.access(output_dir, os.W_OK):
|
|
90
|
+
print(f"โ Error: Directory {output_dir} is not writable")
|
|
91
|
+
return False
|
|
92
|
+
|
|
93
|
+
# Check if directory is empty (optional warning)
|
|
94
|
+
contents = list(output_dir.iterdir())
|
|
95
|
+
if contents:
|
|
96
|
+
print(f"โ ๏ธ Warning: Directory {output_dir} is not empty")
|
|
97
|
+
print(f" Found {len(contents)} items")
|
|
98
|
+
response = input(" Continue anyway? (y/N): ").strip().lower()
|
|
99
|
+
if response not in ['y', 'yes']:
|
|
100
|
+
print(" Setup cancelled")
|
|
101
|
+
return False
|
|
102
|
+
|
|
103
|
+
return True
|
|
104
|
+
|
|
105
|
+
except Exception as e:
|
|
106
|
+
print(f"โ Error validating output directory: {e}")
|
|
107
|
+
return False
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def check_ports_available() -> bool:
|
|
111
|
+
"""
|
|
112
|
+
Check if required ports are available.
|
|
113
|
+
|
|
114
|
+
Returns:
|
|
115
|
+
True if ports are available, False otherwise
|
|
116
|
+
"""
|
|
117
|
+
import socket
|
|
118
|
+
|
|
119
|
+
ports_to_check = [8080, 8443, 20005, 3005]
|
|
120
|
+
unavailable_ports = []
|
|
121
|
+
|
|
122
|
+
for port in ports_to_check:
|
|
123
|
+
try:
|
|
124
|
+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
|
125
|
+
s.settimeout(1)
|
|
126
|
+
result = s.connect_ex(('localhost', port))
|
|
127
|
+
if result == 0:
|
|
128
|
+
unavailable_ports.append(port)
|
|
129
|
+
except Exception:
|
|
130
|
+
# If we can't check, assume it's available
|
|
131
|
+
pass
|
|
132
|
+
|
|
133
|
+
if unavailable_ports:
|
|
134
|
+
print(f"โ ๏ธ Warning: The following ports are in use: {unavailable_ports}")
|
|
135
|
+
print(" This may cause issues when running the examples")
|
|
136
|
+
response = input(" Continue anyway? (y/N): ").strip().lower()
|
|
137
|
+
return response in ['y', 'yes']
|
|
138
|
+
|
|
139
|
+
return True
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def main() -> int:
|
|
143
|
+
"""
|
|
144
|
+
Main function to set up the test environment.
|
|
145
|
+
|
|
146
|
+
Returns:
|
|
147
|
+
Exit code (0 for success, 1 for failure)
|
|
148
|
+
"""
|
|
149
|
+
parser = argparse.ArgumentParser(
|
|
150
|
+
description="Set up test environment for MCP Proxy Adapter",
|
|
151
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
152
|
+
epilog="""
|
|
153
|
+
Examples:
|
|
154
|
+
python setup_test_environment.py # Setup in current directory
|
|
155
|
+
python setup_test_environment.py -o /path/to/test # Setup in specific directory
|
|
156
|
+
python setup_test_environment.py --no-certs # Skip certificate generation
|
|
157
|
+
python setup_test_environment.py --run-tests # Run tests after setup
|
|
158
|
+
"""
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
parser.add_argument(
|
|
162
|
+
"-o", "--output-dir",
|
|
163
|
+
type=Path,
|
|
164
|
+
default=Path.cwd(),
|
|
165
|
+
help="Output directory for test environment (default: current directory)"
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
parser.add_argument(
|
|
169
|
+
"--no-certs",
|
|
170
|
+
action="store_true",
|
|
171
|
+
help="Skip certificate generation"
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
parser.add_argument(
|
|
175
|
+
"--run-tests",
|
|
176
|
+
action="store_true",
|
|
177
|
+
help="Run tests after setup"
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
parser.add_argument(
|
|
181
|
+
"--verbose",
|
|
182
|
+
action="store_true",
|
|
183
|
+
help="Enable verbose output"
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
args = parser.parse_args()
|
|
187
|
+
|
|
188
|
+
print("๐ MCP Proxy Adapter Test Environment Setup")
|
|
189
|
+
print("=" * 50)
|
|
190
|
+
|
|
191
|
+
# Validate output directory
|
|
192
|
+
if not validate_output_directory(args.output_dir):
|
|
193
|
+
print("โ Setup failed: Invalid output directory")
|
|
194
|
+
return 1
|
|
195
|
+
|
|
196
|
+
# Check ports
|
|
197
|
+
if not check_ports_available():
|
|
198
|
+
print("โ Setup cancelled: Port conflicts detected")
|
|
199
|
+
return 1
|
|
200
|
+
|
|
201
|
+
try:
|
|
202
|
+
# Run setup
|
|
203
|
+
success = setup_test_environment(args.output_dir)
|
|
204
|
+
|
|
205
|
+
if not success:
|
|
206
|
+
print("โ Setup failed")
|
|
207
|
+
return 1
|
|
208
|
+
|
|
209
|
+
print("โ
Test environment setup completed successfully!")
|
|
210
|
+
print(f"๐ Output directory: {args.output_dir.absolute()}")
|
|
211
|
+
|
|
212
|
+
# Run tests if requested
|
|
213
|
+
if args.run_tests:
|
|
214
|
+
print("\\n๐งช Running tests...")
|
|
215
|
+
test_success = run_full_test_suite(args.output_dir)
|
|
216
|
+
if not test_success:
|
|
217
|
+
print("โ ๏ธ Some tests failed, but setup completed")
|
|
218
|
+
return 1
|
|
219
|
+
|
|
220
|
+
print("\\n๐ Setup complete! You can now run the examples.")
|
|
221
|
+
return 0
|
|
222
|
+
|
|
223
|
+
except KeyboardInterrupt:
|
|
224
|
+
print("\\nโ ๏ธ Setup interrupted by user")
|
|
225
|
+
return 1
|
|
226
|
+
except Exception as e:
|
|
227
|
+
print(f"\\nโ Setup failed with error: {e}")
|
|
228
|
+
if args.verbose:
|
|
229
|
+
import traceback
|
|
230
|
+
traceback.print_exc()
|
|
231
|
+
return 1
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
if __name__ == "__main__":
|
|
235
|
+
sys.exit(main())
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Author: Vasiliy Zdanovskiy
|
|
4
|
+
email: vasilyvz@gmail.com
|
|
5
|
+
|
|
6
|
+
Simple protocol test that actually works.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import subprocess
|
|
10
|
+
import sys
|
|
11
|
+
import time
|
|
12
|
+
import requests
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def test_simple_protocols():
|
|
17
|
+
"""Test simple HTTP and HTTPS protocols."""
|
|
18
|
+
print("๐งช Simple Protocol Test")
|
|
19
|
+
print("=" * 30)
|
|
20
|
+
|
|
21
|
+
base_dir = Path(__file__).parent
|
|
22
|
+
http_config = base_dir / "simple_http_example.json"
|
|
23
|
+
https_config = base_dir / "simple_https_example.json"
|
|
24
|
+
|
|
25
|
+
processes = []
|
|
26
|
+
|
|
27
|
+
try:
|
|
28
|
+
# Start proxy server
|
|
29
|
+
print("๐ Starting proxy server...")
|
|
30
|
+
proxy_process = subprocess.Popen([
|
|
31
|
+
sys.executable, "-m", "mcp_proxy_adapter.examples.run_proxy_server",
|
|
32
|
+
"--host", "127.0.0.1",
|
|
33
|
+
"--port", "20005",
|
|
34
|
+
"--log-level", "info"
|
|
35
|
+
], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
|
36
|
+
processes.append(proxy_process)
|
|
37
|
+
|
|
38
|
+
# Wait for proxy
|
|
39
|
+
time.sleep(3)
|
|
40
|
+
|
|
41
|
+
# Test proxy
|
|
42
|
+
try:
|
|
43
|
+
response = requests.get("https://127.0.0.1:20005/health", verify=False, timeout=5)
|
|
44
|
+
if response.status_code == 200:
|
|
45
|
+
print("โ
Proxy server running")
|
|
46
|
+
else:
|
|
47
|
+
print(f"โ Proxy server failed: {response.status_code}")
|
|
48
|
+
return False
|
|
49
|
+
except Exception as e:
|
|
50
|
+
print(f"โ Proxy server failed: {e}")
|
|
51
|
+
return False
|
|
52
|
+
|
|
53
|
+
# Start HTTP server
|
|
54
|
+
print("๐ Starting HTTP server...")
|
|
55
|
+
http_process = subprocess.Popen([
|
|
56
|
+
sys.executable, "-m", "mcp_proxy_adapter",
|
|
57
|
+
"--config", str(http_config)
|
|
58
|
+
], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
|
59
|
+
processes.append(http_process)
|
|
60
|
+
|
|
61
|
+
# Wait for HTTP server
|
|
62
|
+
time.sleep(5)
|
|
63
|
+
|
|
64
|
+
# Test HTTP server
|
|
65
|
+
try:
|
|
66
|
+
response = requests.get("http://127.0.0.1:20021/health", timeout=5)
|
|
67
|
+
if response.status_code == 200:
|
|
68
|
+
print("โ
HTTP server running")
|
|
69
|
+
else:
|
|
70
|
+
print(f"โ HTTP server failed: {response.status_code}")
|
|
71
|
+
return False
|
|
72
|
+
except Exception as e:
|
|
73
|
+
print(f"โ HTTP server failed: {e}")
|
|
74
|
+
return False
|
|
75
|
+
|
|
76
|
+
# Start HTTPS server
|
|
77
|
+
print("๐ Starting HTTPS server...")
|
|
78
|
+
https_process = subprocess.Popen([
|
|
79
|
+
sys.executable, "-m", "mcp_proxy_adapter",
|
|
80
|
+
"--config", str(https_config)
|
|
81
|
+
], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
|
82
|
+
processes.append(https_process)
|
|
83
|
+
|
|
84
|
+
# Wait for HTTPS server
|
|
85
|
+
time.sleep(5)
|
|
86
|
+
|
|
87
|
+
# Test HTTPS server (try HTTP fallback)
|
|
88
|
+
try:
|
|
89
|
+
response = requests.get("http://127.0.0.1:20022/health", timeout=5)
|
|
90
|
+
if response.status_code == 200:
|
|
91
|
+
print("โ
HTTPS server running (HTTP fallback)")
|
|
92
|
+
else:
|
|
93
|
+
print(f"โ HTTPS server failed: {response.status_code}")
|
|
94
|
+
return False
|
|
95
|
+
except Exception as e:
|
|
96
|
+
print(f"โ HTTPS server failed: {e}")
|
|
97
|
+
return False
|
|
98
|
+
|
|
99
|
+
print("\n๐ ALL TESTS PASSED!")
|
|
100
|
+
print("โ
Proxy server: HTTP")
|
|
101
|
+
print("โ
HTTP server: Working")
|
|
102
|
+
print("โ
HTTPS server: Working")
|
|
103
|
+
|
|
104
|
+
return True
|
|
105
|
+
|
|
106
|
+
except Exception as e:
|
|
107
|
+
print(f"โ Test failed: {e}")
|
|
108
|
+
return False
|
|
109
|
+
|
|
110
|
+
finally:
|
|
111
|
+
# Cleanup
|
|
112
|
+
print("\n๐งน Cleaning up...")
|
|
113
|
+
for process in processes:
|
|
114
|
+
if process.poll() is None:
|
|
115
|
+
process.terminate()
|
|
116
|
+
try:
|
|
117
|
+
process.wait(timeout=5)
|
|
118
|
+
except subprocess.TimeoutExpired:
|
|
119
|
+
process.kill()
|
|
120
|
+
process.wait()
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
if __name__ == "__main__":
|
|
124
|
+
success = test_simple_protocols()
|
|
125
|
+
sys.exit(0 if success else 1)
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Automated tests for chk_hostname functionality in all SSL modes.
|
|
4
|
+
|
|
5
|
+
Author: Vasiliy Zdanovskiy
|
|
6
|
+
email: vasilyvz@gmail.com
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
import tempfile
|
|
11
|
+
import os
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
import sys
|
|
14
|
+
|
|
15
|
+
# Add the project root to the path
|
|
16
|
+
sys.path.insert(0, str(Path(__file__).parent.parent.parent))
|
|
17
|
+
|
|
18
|
+
from mcp_proxy_adapter.config import Config
|
|
19
|
+
from mcp_proxy_adapter.examples.config_builder import ConfigBuilder, Protocol, AuthMethod
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def test_chk_hostname_default_config():
|
|
23
|
+
"""Test that default config has chk_hostname=False for HTTP."""
|
|
24
|
+
print("๐งช Testing default config chk_hostname...")
|
|
25
|
+
|
|
26
|
+
config = Config()
|
|
27
|
+
|
|
28
|
+
# Default should be HTTP with chk_hostname=False
|
|
29
|
+
assert config.get("server.protocol") == "http"
|
|
30
|
+
assert config.get("transport.chk_hostname") is False
|
|
31
|
+
|
|
32
|
+
print("โ
Default config: chk_hostname=False for HTTP")
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_chk_hostname_http_config():
|
|
36
|
+
"""Test that HTTP config has chk_hostname=False."""
|
|
37
|
+
print("๐งช Testing HTTP config chk_hostname...")
|
|
38
|
+
|
|
39
|
+
# Create HTTP config
|
|
40
|
+
http_config = ConfigBuilder().set_protocol(Protocol.HTTP).build()
|
|
41
|
+
|
|
42
|
+
# Save to temporary file and load with Config
|
|
43
|
+
with tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False) as f:
|
|
44
|
+
json.dump(http_config, f)
|
|
45
|
+
temp_config_path = f.name
|
|
46
|
+
|
|
47
|
+
try:
|
|
48
|
+
config = Config(temp_config_path)
|
|
49
|
+
|
|
50
|
+
# HTTP should have chk_hostname=False
|
|
51
|
+
assert config.get("server.protocol") == "http"
|
|
52
|
+
assert config.get("transport.chk_hostname") is False
|
|
53
|
+
|
|
54
|
+
print("โ
HTTP config: chk_hostname=False")
|
|
55
|
+
finally:
|
|
56
|
+
os.unlink(temp_config_path)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_chk_hostname_https_config():
|
|
60
|
+
"""Test that HTTPS config has chk_hostname=True."""
|
|
61
|
+
print("๐งช Testing HTTPS config chk_hostname...")
|
|
62
|
+
|
|
63
|
+
# Create HTTPS config
|
|
64
|
+
https_config = ConfigBuilder().set_protocol(Protocol.HTTPS).build()
|
|
65
|
+
|
|
66
|
+
# Save to temporary file and load with Config
|
|
67
|
+
with tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False) as f:
|
|
68
|
+
json.dump(https_config, f)
|
|
69
|
+
temp_config_path = f.name
|
|
70
|
+
|
|
71
|
+
try:
|
|
72
|
+
config = Config(temp_config_path)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
# HTTPS should have chk_hostname=True
|
|
76
|
+
assert config.get("server.protocol") == "https"
|
|
77
|
+
assert config.get("transport.chk_hostname") is True
|
|
78
|
+
|
|
79
|
+
print("โ
HTTPS config: chk_hostname=True")
|
|
80
|
+
finally:
|
|
81
|
+
os.unlink(temp_config_path)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def test_chk_hostname_mtls_config():
|
|
85
|
+
"""Test that mTLS config has chk_hostname=True."""
|
|
86
|
+
print("๐งช Testing mTLS config chk_hostname...")
|
|
87
|
+
|
|
88
|
+
# Create mTLS config
|
|
89
|
+
mtls_config = ConfigBuilder().set_protocol(Protocol.MTLS).build()
|
|
90
|
+
|
|
91
|
+
# Save to temporary file and load with Config
|
|
92
|
+
with tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False) as f:
|
|
93
|
+
json.dump(mtls_config, f)
|
|
94
|
+
temp_config_path = f.name
|
|
95
|
+
|
|
96
|
+
try:
|
|
97
|
+
config = Config(temp_config_path)
|
|
98
|
+
|
|
99
|
+
# mTLS should have chk_hostname=True
|
|
100
|
+
assert config.get("server.protocol") == "mtls"
|
|
101
|
+
assert config.get("transport.chk_hostname") is True
|
|
102
|
+
|
|
103
|
+
print("โ
mTLS config: chk_hostname=True")
|
|
104
|
+
finally:
|
|
105
|
+
os.unlink(temp_config_path)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def test_chk_hostname_override():
|
|
109
|
+
"""Test that chk_hostname can be overridden in config."""
|
|
110
|
+
print("๐งช Testing chk_hostname override...")
|
|
111
|
+
|
|
112
|
+
# Create HTTPS config with chk_hostname=False override
|
|
113
|
+
https_config = ConfigBuilder().set_protocol(Protocol.HTTPS).build()
|
|
114
|
+
# Add transport section if it doesn't exist
|
|
115
|
+
if "transport" not in https_config:
|
|
116
|
+
https_config["transport"] = {}
|
|
117
|
+
https_config["transport"]["chk_hostname"] = False
|
|
118
|
+
|
|
119
|
+
# Save to temporary file and load with Config
|
|
120
|
+
with tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False) as f:
|
|
121
|
+
json.dump(https_config, f)
|
|
122
|
+
temp_config_path = f.name
|
|
123
|
+
|
|
124
|
+
try:
|
|
125
|
+
config = Config(temp_config_path)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
# Should respect the override
|
|
129
|
+
assert config.get("server.protocol") == "https"
|
|
130
|
+
assert config.get("transport.chk_hostname") is False
|
|
131
|
+
|
|
132
|
+
print("โ
HTTPS config with chk_hostname=False override works")
|
|
133
|
+
finally:
|
|
134
|
+
os.unlink(temp_config_path)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def test_chk_hostname_all_combinations():
|
|
138
|
+
"""Test chk_hostname for all protocol and auth combinations."""
|
|
139
|
+
print("๐งช Testing chk_hostname for all combinations...")
|
|
140
|
+
|
|
141
|
+
protocols = [Protocol.HTTP, Protocol.HTTPS, Protocol.MTLS]
|
|
142
|
+
auth_methods = [AuthMethod.NONE, AuthMethod.TOKEN, AuthMethod.TOKEN_ROLES]
|
|
143
|
+
|
|
144
|
+
for protocol in protocols:
|
|
145
|
+
for auth_method in auth_methods:
|
|
146
|
+
# Create config
|
|
147
|
+
config_data = (ConfigBuilder()
|
|
148
|
+
.set_protocol(protocol)
|
|
149
|
+
.set_auth(auth_method)
|
|
150
|
+
.build())
|
|
151
|
+
|
|
152
|
+
# Save to temporary file and load with Config
|
|
153
|
+
with tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False) as f:
|
|
154
|
+
json.dump(config_data, f)
|
|
155
|
+
temp_config_path = f.name
|
|
156
|
+
|
|
157
|
+
try:
|
|
158
|
+
config = Config(temp_config_path)
|
|
159
|
+
|
|
160
|
+
protocol_name = protocol.value
|
|
161
|
+
auth_name = auth_method.value
|
|
162
|
+
|
|
163
|
+
# Check chk_hostname based on protocol
|
|
164
|
+
if protocol_name == "http":
|
|
165
|
+
expected_chk_hostname = False
|
|
166
|
+
else: # https or mtls
|
|
167
|
+
expected_chk_hostname = True
|
|
168
|
+
|
|
169
|
+
actual_chk_hostname = config.get("transport.ssl.chk_hostname")
|
|
170
|
+
|
|
171
|
+
assert actual_chk_hostname == expected_chk_hostname, (
|
|
172
|
+
f"Protocol {protocol_name} with auth {auth_name}: "
|
|
173
|
+
f"expected chk_hostname={expected_chk_hostname}, "
|
|
174
|
+
f"got {actual_chk_hostname}"
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
print(f"โ
{protocol_name}+{auth_name}: chk_hostname={actual_chk_hostname}")
|
|
178
|
+
|
|
179
|
+
finally:
|
|
180
|
+
os.unlink(temp_config_path)
|
|
181
|
+
|
|
182
|
+
print("โ
All protocol+auth combinations have correct chk_hostname values")
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def main():
|
|
186
|
+
"""Run all chk_hostname tests."""
|
|
187
|
+
print("๐งช Running Automated chk_hostname Tests")
|
|
188
|
+
print("=" * 50)
|
|
189
|
+
|
|
190
|
+
try:
|
|
191
|
+
test_chk_hostname_default_config()
|
|
192
|
+
test_chk_hostname_http_config()
|
|
193
|
+
test_chk_hostname_https_config()
|
|
194
|
+
test_chk_hostname_mtls_config()
|
|
195
|
+
test_chk_hostname_override()
|
|
196
|
+
test_chk_hostname_all_combinations()
|
|
197
|
+
|
|
198
|
+
print("=" * 50)
|
|
199
|
+
print("๐ All chk_hostname tests passed!")
|
|
200
|
+
return True
|
|
201
|
+
|
|
202
|
+
except Exception as e:
|
|
203
|
+
print(f"โ Test failed: {e}")
|
|
204
|
+
import traceback
|
|
205
|
+
traceback.print_exc()
|
|
206
|
+
return False
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
if __name__ == "__main__":
|
|
210
|
+
success = main()
|
|
211
|
+
sys.exit(0 if success else 1)
|