Skip to content

Commit b9ffda0

Browse files
authored
Merge pull request #6 from agentic-community/pr-3
Significant code refactor: docker compose, fgac
2 parents 3e2a8cd + 9d8e58f commit b9ffda0

File tree

80 files changed

+13488
-2818
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+13488
-2818
lines changed

.env.docker.template

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
name: 🧪 Test Suite
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
name: "🧪 Test (${{ matrix.python-version }})"
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
python-version: ["3.12"]
17+
fail-fast: false
18+
19+
steps:
20+
- name: 📥 Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: 🐍 Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
28+
- name: 📦 Cache dependencies
29+
uses: actions/cache@v3
30+
with:
31+
path: ~/.cache/pip
32+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
33+
restore-keys: |
34+
${{ runner.os }}-pip-
35+
36+
- name: 🔧 Install dependencies
37+
run: |
38+
python -m pip install --upgrade pip
39+
pip install -e .[dev]
40+
41+
- name: 🔍 Check dependencies
42+
run: |
43+
python scripts/test.py check
44+
45+
- name: 🧪 Run unit tests
46+
run: |
47+
python scripts/test.py unit
48+
49+
- name: 🔗 Run integration tests
50+
run: |
51+
python scripts/test.py integration
52+
53+
- name: 📊 Generate coverage report
54+
run: |
55+
python scripts/test.py coverage
56+
57+
- name: 📤 Upload coverage to Codecov
58+
uses: codecov/codecov-action@v3
59+
with:
60+
file: ./coverage.xml
61+
flags: unittests
62+
name: codecov-umbrella
63+
fail_ci_if_error: false
64+
65+
- name: 📄 Upload coverage reports
66+
uses: actions/upload-artifact@v3
67+
with:
68+
name: coverage-report-${{ matrix.python-version }}
69+
path: htmlcov/
70+
71+
- name: 📋 Upload test reports
72+
uses: actions/upload-artifact@v3
73+
if: always()
74+
with:
75+
name: test-reports-${{ matrix.python-version }}
76+
path: tests/reports/
77+
78+
lint:
79+
name: "🔍 Code Quality"
80+
runs-on: ubuntu-latest
81+
82+
steps:
83+
- name: 📥 Checkout code
84+
uses: actions/checkout@v4
85+
86+
- name: 🐍 Set up Python
87+
uses: actions/setup-python@v4
88+
with:
89+
python-version: "3.12"
90+
91+
- name: 📦 Install dependencies
92+
run: |
93+
python -m pip install --upgrade pip
94+
pip install bandit black isort flake8
95+
96+
- name: 🔒 Security check with bandit
97+
run: |
98+
bandit -r registry/ -f json -o bandit-report.json || true
99+
100+
- name: 📋 Upload security report
101+
uses: actions/upload-artifact@v3
102+
if: always()
103+
with:
104+
name: security-report
105+
path: bandit-report.json
106+
107+
domain-tests:
108+
name: "🏗️ Domain Tests"
109+
runs-on: ubuntu-latest
110+
strategy:
111+
matrix:
112+
domain: [auth, servers, search, health, core]
113+
fail-fast: false
114+
115+
steps:
116+
- name: 📥 Checkout code
117+
uses: actions/checkout@v4
118+
119+
- name: 🐍 Set up Python
120+
uses: actions/setup-python@v4
121+
with:
122+
python-version: "3.12"
123+
124+
- name: 📦 Install dependencies
125+
run: |
126+
python -m pip install --upgrade pip
127+
pip install -e .[dev]
128+
129+
- name: 🏗️ Test ${{ matrix.domain }} domain
130+
run: |
131+
python scripts/test.py ${{ matrix.domain }}
132+
133+
fast-feedback:
134+
name: "⚡ Fast Feedback"
135+
runs-on: ubuntu-latest
136+
if: github.event_name == 'pull_request'
137+
138+
steps:
139+
- name: 📥 Checkout code
140+
uses: actions/checkout@v4
141+
142+
- name: 🐍 Set up Python
143+
uses: actions/setup-python@v4
144+
with:
145+
python-version: "3.12"
146+
147+
- name: 📦 Install dependencies
148+
run: |
149+
python -m pip install --upgrade pip
150+
pip install -e .[dev]
151+
152+
- name: ⚡ Run fast tests
153+
run: |
154+
python scripts/test.py fast
155+
156+
summary:
157+
name: "📋 Test Summary"
158+
runs-on: ubuntu-latest
159+
needs: [test, lint, domain-tests]
160+
if: always()
161+
162+
steps:
163+
- name: 📋 Test Results Summary
164+
run: |
165+
echo "## 🧪 Test Results Summary" >> $GITHUB_STEP_SUMMARY
166+
echo "" >> $GITHUB_STEP_SUMMARY
167+
echo "| Job | Status |" >> $GITHUB_STEP_SUMMARY
168+
echo "|-----|--------|" >> $GITHUB_STEP_SUMMARY
169+
echo "| Main Tests | ${{ needs.test.result }} |" >> $GITHUB_STEP_SUMMARY
170+
echo "| Code Quality | ${{ needs.lint.result }} |" >> $GITHUB_STEP_SUMMARY
171+
echo "| Domain Tests | ${{ needs.domain-tests.result }} |" >> $GITHUB_STEP_SUMMARY
172+
echo "" >> $GITHUB_STEP_SUMMARY
173+
174+
if [[ "${{ needs.test.result }}" == "success" && "${{ needs.lint.result }}" == "success" && "${{ needs.domain-tests.result }}" == "success" ]]; then
175+
echo "✅ All tests passed! 🎉" >> $GITHUB_STEP_SUMMARY
176+
else
177+
echo "❌ Some tests failed. Please check the logs." >> $GITHUB_STEP_SUMMARY
178+
fi

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,6 @@ logs/
188188

189189
# Agent testing
190190
agents/test_results/
191+
agents/.env.user
192+
ssl_data/
193+
agents/.env.agent

Makefile

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
.PHONY: help test test-unit test-integration test-e2e test-fast test-coverage test-auth test-servers test-search test-health test-core install-dev lint format check-deps clean
2+
3+
# Default target
4+
help:
5+
@echo "🧪 MCP Registry Testing Commands"
6+
@echo ""
7+
@echo "Setup:"
8+
@echo " install-dev Install development dependencies"
9+
@echo " check-deps Check if test dependencies are installed"
10+
@echo ""
11+
@echo "Testing:"
12+
@echo " test Run full test suite with coverage"
13+
@echo " test-unit Run unit tests only"
14+
@echo " test-integration Run integration tests only"
15+
@echo " test-e2e Run end-to-end tests only"
16+
@echo " test-fast Run fast tests (exclude slow tests)"
17+
@echo " test-coverage Generate coverage reports"
18+
@echo ""
19+
@echo "Domain Testing:"
20+
@echo " test-auth Run authentication domain tests"
21+
@echo " test-servers Run server management domain tests"
22+
@echo " test-search Run search domain tests"
23+
@echo " test-health Run health monitoring domain tests"
24+
@echo " test-core Run core infrastructure tests"
25+
@echo ""
26+
@echo "Code Quality:"
27+
@echo " lint Run linting checks"
28+
@echo " format Format code"
29+
@echo " clean Clean up test artifacts"
30+
31+
# Installation
32+
install-dev:
33+
@echo "📦 Installing development dependencies..."
34+
pip install -e .[dev]
35+
36+
check-deps:
37+
@python scripts/test.py check
38+
39+
# Full test suite
40+
test:
41+
@python scripts/test.py full
42+
43+
# Test types
44+
test-unit:
45+
@python scripts/test.py unit
46+
47+
test-integration:
48+
@python scripts/test.py integration
49+
50+
test-e2e:
51+
@python scripts/test.py e2e
52+
53+
test-fast:
54+
@python scripts/test.py fast
55+
56+
test-coverage:
57+
@python scripts/test.py coverage
58+
59+
# Domain-specific tests
60+
test-auth:
61+
@python scripts/test.py auth
62+
63+
test-servers:
64+
@python scripts/test.py servers
65+
66+
test-search:
67+
@python scripts/test.py search
68+
69+
test-health:
70+
@python scripts/test.py health
71+
72+
test-core:
73+
@python scripts/test.py core
74+
75+
# Code quality
76+
lint:
77+
@echo "🔍 Running linting checks..."
78+
@python -m bandit -r registry/ -f json || true
79+
@echo "✅ Linting complete"
80+
81+
format:
82+
@echo "🎨 Formatting code..."
83+
@python -m black registry/ tests/ --diff --color
84+
@echo "✅ Code formatting complete"
85+
86+
# Cleanup
87+
clean:
88+
@echo "🧹 Cleaning up test artifacts..."
89+
@rm -rf htmlcov/
90+
@rm -rf tests/reports/
91+
@rm -rf .coverage
92+
@rm -rf coverage.xml
93+
@rm -rf .pytest_cache/
94+
@find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
95+
@find . -type f -name "*.pyc" -delete 2>/dev/null || true
96+
@echo "✅ Cleanup complete"
97+
98+
# Development workflow
99+
dev-test: clean install-dev test-fast
100+
@echo "🚀 Development test cycle complete!"
101+
102+
# CI/CD workflow
103+
ci-test: clean check-deps test test-coverage
104+
@echo "🏗️ CI/CD test cycle complete!"

agents/agent_w_auth.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,37 +143,37 @@ def load_env_config(use_session_cookie: bool) -> Dict[str, Optional[str]]:
143143

144144
# Choose .env file based on authentication mode
145145
env_file_name = '.env.user' if use_session_cookie else '.env.agent'
146-
146+
logger.info(f"Using .env file: {env_file_name}")
147147
if DOTENV_AVAILABLE:
148148
file_found = False
149149
file_path = None
150150

151151
# Try to load from .env file in the current directory
152152
env_file = os.path.join(os.path.dirname(__file__), env_file_name)
153153
if os.path.exists(env_file):
154-
load_dotenv(env_file)
154+
logger.info(f"Found .env file: {env_file}")
155+
load_dotenv(env_file, override=True)
155156
file_found = True
156157
file_path = env_file
157158
logger.info(f"Loading environment variables from {env_file}")
159+
logger.info(f"user pool id {os.environ.get('COGNITO_USER_POOL_ID')}")
158160
else:
159161
# Try to load from .env file in the parent directory
160162
env_file = os.path.join(os.path.dirname(__file__), '..', env_file_name)
161163
if os.path.exists(env_file):
162-
load_dotenv(env_file)
163-
file_found = True
164-
file_path = env_file
164+
logger.info(f"Found .env file in parent directory: {env_file}")
165+
load_dotenv(env_file, override=True)
165166
logger.info(f"Loading environment variables from {env_file}")
166167
else:
167168
# Try to load from current working directory
168169
env_file = os.path.join(os.getcwd(), env_file_name)
169170
if os.path.exists(env_file):
170-
load_dotenv(env_file)
171-
file_found = True
172-
file_path = env_file
171+
logger.info(f"Found .env file in current working directory: {env_file}")
172+
load_dotenv(env_file, override=True)
173173
logger.info(f"Loading environment variables from {env_file}")
174174
else:
175175
# Fallback to default .env loading
176-
load_dotenv()
176+
load_dotenv(override=True)
177177
logger.info("Loading environment variables from default .env file")
178178

179179
# Print banner showing which file is being used
@@ -201,6 +201,7 @@ def parse_arguments() -> argparse.Namespace:
201201
"""
202202
# First, determine authentication mode to choose correct .env file
203203
use_session_cookie = get_auth_mode_from_args()
204+
logger.info(f"Using session cookie authentication: {use_session_cookie}")
204205

205206
# Load environment configuration using the appropriate .env file
206207
env_config = load_env_config(use_session_cookie)
@@ -514,6 +515,7 @@ async def main():
514515
"""
515516
# Parse command line arguments
516517
args = parse_arguments()
518+
logger.info(f"Parsed command line arguments successfully, args={args}")
517519

518520
# Display configuration
519521
server_url = args.mcp_registry_url
@@ -540,6 +542,7 @@ async def main():
540542
else:
541543
# Generate Cognito M2M authentication token
542544
logger.info(f"Cognito User Pool ID: {redact_sensitive_value(args.user_pool_id)}")
545+
logger.info(f"Cognito User Pool ID: {args.user_pool_id}")
543546
logger.info(f"Cognito Client ID: {redact_sensitive_value(args.client_id)}")
544547
logger.info(f"AWS Region: {args.region}")
545548

0 commit comments

Comments
 (0)