awslabs.terraform-mcp-server 0.0.1__tar.gz → 0.0.6__tar.gz
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 awslabs.terraform-mcp-server might be problematic. Click here for more details.
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/PKG-INFO +1 -1
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/pyproject.toml +8 -1
- awslabs_terraform_mcp_server-0.0.6/run_tests.sh +206 -0
- awslabs_terraform_mcp_server-0.0.6/tests/.gitignore +38 -0
- awslabs_terraform_mcp_server-0.0.6/tests/README.md +159 -0
- awslabs_terraform_mcp_server-0.0.6/tests/conftest.py +370 -0
- awslabs_terraform_mcp_server-0.0.6/tests/test_command_impl.py +466 -0
- awslabs_terraform_mcp_server-0.0.6/tests/test_execute_terraform_command.py +228 -0
- awslabs_terraform_mcp_server-0.0.6/tests/test_models.py +465 -0
- awslabs_terraform_mcp_server-0.0.6/tests/test_resources.py +126 -0
- awslabs_terraform_mcp_server-0.0.6/tests/test_run_checkov_scan.py +344 -0
- awslabs_terraform_mcp_server-0.0.6/tests/test_server.py +271 -0
- {awslabs_terraform_mcp_server-0.0.1/awslabs/terraform_mcp_server → awslabs_terraform_mcp_server-0.0.6}/tests/test_tool_implementations.py +5 -66
- awslabs_terraform_mcp_server-0.0.6/tests/test_utils.py +302 -0
- awslabs_terraform_mcp_server-0.0.6/tests/test_utils_additional.py +477 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/uv.lock +276 -92
- awslabs_terraform_mcp_server-0.0.1/awslabs/terraform_mcp_server/tests/run_tests.sh +0 -35
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/.gitignore +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/.pre-commit-config.yaml +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/.python-version +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/CHANGELOG.md +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/README.md +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/__init__.py +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/terraform_mcp_server/__init__.py +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/terraform_mcp_server/impl/resources/__init__.py +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/terraform_mcp_server/impl/resources/terraform_aws_provider_resources_listing.py +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/terraform_mcp_server/impl/resources/terraform_awscc_provider_resources_listing.py +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/terraform_mcp_server/impl/tools/__init__.py +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/terraform_mcp_server/impl/tools/execute_terraform_command.py +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/terraform_mcp_server/impl/tools/run_checkov_scan.py +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/terraform_mcp_server/impl/tools/search_aws_provider_docs.py +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/terraform_mcp_server/impl/tools/search_awscc_provider_docs.py +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/terraform_mcp_server/impl/tools/search_specific_aws_ia_modules.py +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/terraform_mcp_server/impl/tools/utils.py +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/terraform_mcp_server/models/__init__.py +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/terraform_mcp_server/models/models.py +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/terraform_mcp_server/scripts/generate_aws_provider_resources.py +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/terraform_mcp_server/scripts/generate_awscc_provider_resources.py +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/terraform_mcp_server/scripts/scrape_aws_terraform_best_practices.py +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/terraform_mcp_server/server.py +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/terraform_mcp_server/static/AWSCC_PROVIDER_RESOURCES.md +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/terraform_mcp_server/static/AWS_PROVIDER_RESOURCES.md +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/terraform_mcp_server/static/AWS_TERRAFORM_BEST_PRACTICES.md +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/terraform_mcp_server/static/MCP_INSTRUCTIONS.md +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/terraform_mcp_server/static/TERRAFORM_WORKFLOW_GUIDE.md +0 -0
- {awslabs_terraform_mcp_server-0.0.1 → awslabs_terraform_mcp_server-0.0.6}/awslabs/terraform_mcp_server/static/__init__.py +0 -0
- {awslabs_terraform_mcp_server-0.0.1/awslabs/terraform_mcp_server → awslabs_terraform_mcp_server-0.0.6}/tests/__init__.py +0 -0
- {awslabs_terraform_mcp_server-0.0.1/awslabs/terraform_mcp_server → awslabs_terraform_mcp_server-0.0.6}/tests/test_parameter_annotations.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "awslabs.terraform-mcp-server"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.6"
|
|
4
4
|
description = "An AWS Labs Model Context Protocol (MCP) server for terraform"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.10"
|
|
@@ -24,6 +24,10 @@ dev = [
|
|
|
24
24
|
"pre-commit>=4.1.0",
|
|
25
25
|
"ruff>=0.9.7",
|
|
26
26
|
"pyright>=1.1.399",
|
|
27
|
+
"pytest>=8.0.0",
|
|
28
|
+
"pytest-asyncio>=0.26.0",
|
|
29
|
+
"pytest-cov>=4.1.0",
|
|
30
|
+
"pytest-mock>=3.12.0",
|
|
27
31
|
]
|
|
28
32
|
|
|
29
33
|
[build-system]
|
|
@@ -83,3 +87,6 @@ update_changelog_on_bump = true
|
|
|
83
87
|
|
|
84
88
|
[tool.hatch.build.targets.wheel]
|
|
85
89
|
packages = ["awslabs"]
|
|
90
|
+
|
|
91
|
+
[tool.coverage.run]
|
|
92
|
+
source = ["awslabs"]
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
5
|
+
# with the License. A copy of the License is located at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
10
|
+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
11
|
+
# and limitations under the License.
|
|
12
|
+
|
|
13
|
+
# Script to run tests for the Terraform MCP Server
|
|
14
|
+
|
|
15
|
+
set -e
|
|
16
|
+
|
|
17
|
+
# Set the Python path to include the current directory and the parent directory
|
|
18
|
+
export PYTHONPATH=$PYTHONPATH:$(pwd):$(pwd)/..
|
|
19
|
+
|
|
20
|
+
# Check if we're in a virtual environment
|
|
21
|
+
if [ -z "$VIRTUAL_ENV" ]; then
|
|
22
|
+
echo "Warning: You are not running in a virtual environment."
|
|
23
|
+
echo "It's recommended to create and activate a virtual environment before running tests."
|
|
24
|
+
echo "You can create one with: python -m venv .venv"
|
|
25
|
+
echo "And activate it with: source .venv/bin/activate (Linux/Mac) or .venv\\Scripts\\activate (Windows)"
|
|
26
|
+
echo "Continuing without a virtual environment..."
|
|
27
|
+
echo ""
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
# Check if pytest and other dependencies are installed
|
|
31
|
+
echo "Checking for required packages..."
|
|
32
|
+
MISSING_PACKAGES=()
|
|
33
|
+
|
|
34
|
+
# Check for pytest and related packages
|
|
35
|
+
python -c "import pytest" 2>/dev/null
|
|
36
|
+
if [ $? -ne 0 ]; then
|
|
37
|
+
MISSING_PACKAGES+=("pytest pytest-asyncio pytest-cov")
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
# Check for pydantic package
|
|
41
|
+
python -c "import pydantic" 2>/dev/null
|
|
42
|
+
if [ $? -ne 0 ]; then
|
|
43
|
+
MISSING_PACKAGES+=("pydantic")
|
|
44
|
+
fi
|
|
45
|
+
|
|
46
|
+
# Check for requests package
|
|
47
|
+
python -c "import requests" 2>/dev/null
|
|
48
|
+
if [ $? -ne 0 ]; then
|
|
49
|
+
MISSING_PACKAGES+=("requests")
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
# Check for loguru package
|
|
53
|
+
python -c "import loguru" 2>/dev/null
|
|
54
|
+
if [ $? -ne 0 ]; then
|
|
55
|
+
MISSING_PACKAGES+=("loguru")
|
|
56
|
+
fi
|
|
57
|
+
|
|
58
|
+
# Check for beautifulsoup4 package
|
|
59
|
+
python -c "import bs4" 2>/dev/null
|
|
60
|
+
if [ $? -ne 0 ]; then
|
|
61
|
+
MISSING_PACKAGES+=("beautifulsoup4")
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
# Check for checkov package
|
|
65
|
+
python -c "import checkov" 2>/dev/null
|
|
66
|
+
if [ $? -ne 0 ]; then
|
|
67
|
+
MISSING_PACKAGES+=("checkov")
|
|
68
|
+
fi
|
|
69
|
+
|
|
70
|
+
# Install missing packages
|
|
71
|
+
if [ ${#MISSING_PACKAGES[@]} -gt 0 ]; then
|
|
72
|
+
echo "Installing missing packages: ${MISSING_PACKAGES[*]}"
|
|
73
|
+
|
|
74
|
+
# Try pip first (more reliable)
|
|
75
|
+
if command -v pip &> /dev/null; then
|
|
76
|
+
echo "Using pip to install packages..."
|
|
77
|
+
pip install ${MISSING_PACKAGES[*]} -v
|
|
78
|
+
# Try pip3 if pip is not available
|
|
79
|
+
elif command -v pip3 &> /dev/null; then
|
|
80
|
+
echo "Using pip3 to install packages..."
|
|
81
|
+
pip3 install ${MISSING_PACKAGES[*]} -v
|
|
82
|
+
# Try uv as a last resort
|
|
83
|
+
elif command -v uv &> /dev/null; then
|
|
84
|
+
echo "Using uv to install packages..."
|
|
85
|
+
uv pip install ${MISSING_PACKAGES[*]} -v
|
|
86
|
+
else
|
|
87
|
+
echo "Error: No package manager (pip, pip3, or uv) is available. Please install the missing packages manually."
|
|
88
|
+
exit 1
|
|
89
|
+
fi
|
|
90
|
+
|
|
91
|
+
# Verify installation with more verbose output
|
|
92
|
+
echo "Verifying package installations..."
|
|
93
|
+
for pkg in "pytest" "pydantic" "requests" "loguru" "bs4" "checkov"; do
|
|
94
|
+
echo "Checking for $pkg..."
|
|
95
|
+
python -c "import $pkg; print(f'$pkg installed successfully')" 2>/dev/null
|
|
96
|
+
if [ $? -ne 0 ]; then
|
|
97
|
+
echo "Failed to install $pkg. Trying to install it individually..."
|
|
98
|
+
pip install $pkg -v || pip3 install $pkg -v || echo "Failed to install $pkg. Please install it manually."
|
|
99
|
+
|
|
100
|
+
# Check again
|
|
101
|
+
python -c "import $pkg" 2>/dev/null
|
|
102
|
+
if [ $? -ne 0 ]; then
|
|
103
|
+
echo "Still failed to install $pkg. Please install it manually."
|
|
104
|
+
echo "You can try: pip install $pkg"
|
|
105
|
+
exit 1
|
|
106
|
+
fi
|
|
107
|
+
fi
|
|
108
|
+
done
|
|
109
|
+
fi
|
|
110
|
+
|
|
111
|
+
# Print debug information
|
|
112
|
+
echo "Debug information:"
|
|
113
|
+
echo "Python version: $(python --version)"
|
|
114
|
+
echo "Python path: $PYTHONPATH"
|
|
115
|
+
echo "Current directory: $(pwd)"
|
|
116
|
+
echo "Python executable: $(which python)"
|
|
117
|
+
echo "Pytest module location: $(python -c "import pytest; print(pytest.__file__)" 2>/dev/null || echo "Not found")"
|
|
118
|
+
|
|
119
|
+
# Check if terraform_mcp_server module can be imported
|
|
120
|
+
echo "Checking if terraform_mcp_server module can be imported..."
|
|
121
|
+
python -c "import awslabs.terraform_mcp_server; print('terraform_mcp_server module found')" 2>/dev/null
|
|
122
|
+
if [ $? -ne 0 ]; then
|
|
123
|
+
echo "Warning: terraform_mcp_server module cannot be imported. This may cause test failures."
|
|
124
|
+
echo "Installing the package in development mode..."
|
|
125
|
+
|
|
126
|
+
# Check if uv is available
|
|
127
|
+
if command -v uv &> /dev/null; then
|
|
128
|
+
uv pip install -e .
|
|
129
|
+
# Check if pip is available
|
|
130
|
+
elif command -v pip &> /dev/null; then
|
|
131
|
+
pip install -e .
|
|
132
|
+
else
|
|
133
|
+
echo "Neither uv nor pip is available. Creating a symbolic link instead..."
|
|
134
|
+
# Create a symbolic link to the module in the current directory
|
|
135
|
+
ln -sf $(pwd)/awslabs/terraform_mcp_server $(pwd)/terraform_mcp_server 2>/dev/null
|
|
136
|
+
fi
|
|
137
|
+
|
|
138
|
+
echo "Trying again..."
|
|
139
|
+
python -c "import awslabs.terraform_mcp_server; print('terraform_mcp_server module found')" 2>/dev/null
|
|
140
|
+
if [ $? -ne 0 ]; then
|
|
141
|
+
echo "Still cannot import terraform_mcp_server module. Tests may fail."
|
|
142
|
+
echo "Directory structure:"
|
|
143
|
+
ls -la
|
|
144
|
+
echo "awslabs directory:"
|
|
145
|
+
ls -la awslabs 2>/dev/null || echo "awslabs directory not found"
|
|
146
|
+
fi
|
|
147
|
+
fi
|
|
148
|
+
|
|
149
|
+
# Parse command line arguments
|
|
150
|
+
COVERAGE=0
|
|
151
|
+
REPORT=0
|
|
152
|
+
VERBOSE=0
|
|
153
|
+
SPECIFIC_TEST=""
|
|
154
|
+
|
|
155
|
+
while [[ $# -gt 0 ]]; do
|
|
156
|
+
key="$1"
|
|
157
|
+
case $key in
|
|
158
|
+
--coverage)
|
|
159
|
+
COVERAGE=1
|
|
160
|
+
shift
|
|
161
|
+
;;
|
|
162
|
+
--report)
|
|
163
|
+
REPORT=1
|
|
164
|
+
shift
|
|
165
|
+
;;
|
|
166
|
+
--verbose)
|
|
167
|
+
VERBOSE=1
|
|
168
|
+
shift
|
|
169
|
+
;;
|
|
170
|
+
*)
|
|
171
|
+
SPECIFIC_TEST="$1"
|
|
172
|
+
shift
|
|
173
|
+
;;
|
|
174
|
+
esac
|
|
175
|
+
done
|
|
176
|
+
|
|
177
|
+
# Set up the command
|
|
178
|
+
CMD="python -m pytest"
|
|
179
|
+
|
|
180
|
+
if [ $VERBOSE -eq 1 ]; then
|
|
181
|
+
CMD="$CMD -v"
|
|
182
|
+
fi
|
|
183
|
+
|
|
184
|
+
if [ $COVERAGE -eq 1 ]; then
|
|
185
|
+
CMD="$CMD --cov=awslabs.terraform_mcp_server"
|
|
186
|
+
|
|
187
|
+
if [ $REPORT -eq 1 ]; then
|
|
188
|
+
CMD="$CMD --cov-report=html"
|
|
189
|
+
fi
|
|
190
|
+
fi
|
|
191
|
+
|
|
192
|
+
if [ -n "$SPECIFIC_TEST" ]; then
|
|
193
|
+
CMD="$CMD $SPECIFIC_TEST"
|
|
194
|
+
else
|
|
195
|
+
CMD="$CMD tests/"
|
|
196
|
+
fi
|
|
197
|
+
|
|
198
|
+
# Run the tests
|
|
199
|
+
echo "Running: $CMD"
|
|
200
|
+
$CMD
|
|
201
|
+
|
|
202
|
+
# If coverage report was generated, print the path
|
|
203
|
+
if [ $COVERAGE -eq 1 ] && [ $REPORT -eq 1 ]; then
|
|
204
|
+
echo "Coverage report generated in htmlcov/ directory"
|
|
205
|
+
echo "Open htmlcov/index.html in your browser to view the report"
|
|
206
|
+
fi
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Pytest cache
|
|
2
|
+
__pycache__/
|
|
3
|
+
.pytest_cache/
|
|
4
|
+
|
|
5
|
+
# Coverage reports
|
|
6
|
+
.coverage
|
|
7
|
+
htmlcov/
|
|
8
|
+
|
|
9
|
+
# Temporary files
|
|
10
|
+
*.pyc
|
|
11
|
+
*.pyo
|
|
12
|
+
*.pyd
|
|
13
|
+
.Python
|
|
14
|
+
env/
|
|
15
|
+
build/
|
|
16
|
+
develop-eggs/
|
|
17
|
+
dist/
|
|
18
|
+
downloads/
|
|
19
|
+
eggs/
|
|
20
|
+
.eggs/
|
|
21
|
+
lib/
|
|
22
|
+
lib64/
|
|
23
|
+
parts/
|
|
24
|
+
sdist/
|
|
25
|
+
var/
|
|
26
|
+
*.egg-info/
|
|
27
|
+
.installed.cfg
|
|
28
|
+
*.egg
|
|
29
|
+
|
|
30
|
+
# Virtual environments
|
|
31
|
+
venv/
|
|
32
|
+
ENV/
|
|
33
|
+
|
|
34
|
+
# IDE files
|
|
35
|
+
.idea/
|
|
36
|
+
.vscode/
|
|
37
|
+
*.swp
|
|
38
|
+
*.swo
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# Terraform MCP Server Tests
|
|
2
|
+
|
|
3
|
+
This directory contains tests for the Terraform MCP Server.
|
|
4
|
+
|
|
5
|
+
## Test Structure
|
|
6
|
+
|
|
7
|
+
The tests are organized as follows:
|
|
8
|
+
|
|
9
|
+
- `conftest.py`: Contains pytest fixtures used across multiple test files
|
|
10
|
+
- `test_models.py`: Tests for the data models
|
|
11
|
+
- `test_server.py`: Tests for the MCP server functionality
|
|
12
|
+
- `test_command_impl.py`: Tests for the Terraform command execution implementation
|
|
13
|
+
- `test_execute_terraform_command.py`: Dedicated tests for the execute_terraform_command implementation
|
|
14
|
+
- `test_run_checkov_scan.py`: Dedicated tests for the run_checkov_scan implementation
|
|
15
|
+
- `test_resources.py`: Tests for the resource implementations
|
|
16
|
+
- `test_tool_implementations.py`: Tests for the tool implementations
|
|
17
|
+
- `test_utils.py` and `test_utils_additional.py`: Tests for utility functions
|
|
18
|
+
- `test_parameter_annotations.py`: Tests for parameter annotations
|
|
19
|
+
|
|
20
|
+
## Running Tests
|
|
21
|
+
|
|
22
|
+
To run the tests, you can use the following command from the root of the repository:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
cd mcp/src/terraform-mcp-server
|
|
26
|
+
pytest tests/
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or use the provided script:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
cd mcp/src/terraform-mcp-server
|
|
33
|
+
./run_tests.sh
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
To run a specific test file:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pytest tests/test_models.py
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
To run a specific test:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pytest tests/test_models.py::TestTerraformExecutionRequest::test_terraform_execution_request_creation
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Test Coverage
|
|
49
|
+
|
|
50
|
+
To run the tests with coverage:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
./run_tests.sh --coverage
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
To generate a coverage report:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
./run_tests.sh --coverage --report
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This will generate a coverage report in the `htmlcov` directory.
|
|
63
|
+
|
|
64
|
+
## Verbose Output
|
|
65
|
+
|
|
66
|
+
To run the tests with verbose output:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
./run_tests.sh --verbose
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Mocking
|
|
73
|
+
|
|
74
|
+
The tests use mocking to avoid making actual system calls. The mocks are defined in `conftest.py` and include:
|
|
75
|
+
|
|
76
|
+
- `mock_terraform_command_output`: Mock outputs for Terraform commands
|
|
77
|
+
- `mock_checkov_output`: Mock outputs for Checkov scans
|
|
78
|
+
- `mock_subprocess`: Mock for subprocess module
|
|
79
|
+
- `mock_os_path`: Mock for os.path module
|
|
80
|
+
- `mock_aws_provider_docs`: Mock AWS provider documentation data
|
|
81
|
+
- `mock_awscc_provider_docs`: Mock AWSCC provider documentation data
|
|
82
|
+
- `mock_aws_ia_modules`: Mock AWS-IA modules data
|
|
83
|
+
|
|
84
|
+
These mocks are used to simulate the behavior of the Terraform CLI, Checkov, and other external dependencies without making actual system calls.
|
|
85
|
+
|
|
86
|
+
## Test Files
|
|
87
|
+
|
|
88
|
+
### test_models.py
|
|
89
|
+
|
|
90
|
+
Tests for the data models used in the Terraform MCP server, including:
|
|
91
|
+
|
|
92
|
+
- `TerraformExecutionRequest`: Request model for Terraform command execution
|
|
93
|
+
- `TerraformExecutionResult`: Result model for Terraform command execution
|
|
94
|
+
- `CheckovScanRequest`: Request model for Checkov scan execution
|
|
95
|
+
- `CheckovScanResult`: Result model for Checkov scan execution
|
|
96
|
+
- `CheckovVulnerability`: Model for security vulnerabilities found by Checkov
|
|
97
|
+
- `TerraformAWSProviderDocsResult`: Model for AWS provider documentation results
|
|
98
|
+
- `TerraformAWSCCProviderDocsResult`: Model for AWSCC provider documentation results
|
|
99
|
+
- `ModuleSearchResult`: Model for Terraform module search results
|
|
100
|
+
- `SubmoduleInfo`: Model for Terraform submodule information
|
|
101
|
+
- `TerraformVariable`: Model for Terraform variable definitions
|
|
102
|
+
- `TerraformOutput`: Model for Terraform output definitions
|
|
103
|
+
|
|
104
|
+
### test_server.py
|
|
105
|
+
|
|
106
|
+
Tests for the MCP server functionality, including:
|
|
107
|
+
|
|
108
|
+
- Server initialization
|
|
109
|
+
- Tool registration
|
|
110
|
+
- Resource registration
|
|
111
|
+
- Command-line argument parsing
|
|
112
|
+
|
|
113
|
+
### test_command_impl.py
|
|
114
|
+
|
|
115
|
+
Tests for the Terraform command execution implementation, including:
|
|
116
|
+
|
|
117
|
+
- Successful command execution
|
|
118
|
+
- Error handling
|
|
119
|
+
- Security checks
|
|
120
|
+
- Output parsing
|
|
121
|
+
|
|
122
|
+
### test_resources.py
|
|
123
|
+
|
|
124
|
+
Tests for the resource implementations, including:
|
|
125
|
+
|
|
126
|
+
- AWS provider resources listing
|
|
127
|
+
- AWSCC provider resources listing
|
|
128
|
+
- Terraform development workflow guide
|
|
129
|
+
- AWS best practices
|
|
130
|
+
|
|
131
|
+
### test_tool_implementations.py
|
|
132
|
+
|
|
133
|
+
Tests for the tool implementations, including:
|
|
134
|
+
|
|
135
|
+
- AWS provider documentation search
|
|
136
|
+
- AWSCC provider documentation search
|
|
137
|
+
- AWS-IA modules search
|
|
138
|
+
|
|
139
|
+
### test_execute_terraform_command.py
|
|
140
|
+
|
|
141
|
+
Dedicated tests for the execute_terraform_command implementation, including:
|
|
142
|
+
|
|
143
|
+
- Testing the clean_output_text helper function
|
|
144
|
+
- Testing AWS region environment variable setting
|
|
145
|
+
- Testing exception handling
|
|
146
|
+
- Testing output error handling
|
|
147
|
+
- Testing JSON parsing error handling
|
|
148
|
+
- Testing complex output structures with nested values
|
|
149
|
+
|
|
150
|
+
### test_run_checkov_scan.py
|
|
151
|
+
|
|
152
|
+
Dedicated tests for the run_checkov_scan implementation, including:
|
|
153
|
+
|
|
154
|
+
- Testing the _clean_output_text function
|
|
155
|
+
- Testing JSON output parsing
|
|
156
|
+
- Testing with absolute and relative paths
|
|
157
|
+
- Testing security checks for dangerous patterns
|
|
158
|
+
- Testing CLI output parsing
|
|
159
|
+
- Testing error handling and exception handling
|