- Add explicit .env loading in config.py for Windows compatibility
- Add backend directory to sys.path in main.py to fix module imports
- Add start.bat and start-full.bat for Windows startup
- Add frontend/package-lock.json for dependency tracking
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implement business logic for Gitea server management:
- create_server(): Create servers with encrypted API tokens
- list_servers(): List all servers ordered by creation time
- get_server(): Retrieve server by ID
- update_server(): Update server configuration with token re-encryption
- delete_server(): Delete servers
- get_decrypted_token(): Decrypt API tokens for operations
Features:
- API token encryption using AES-256-GCM
- Automatic local_path generation based on server name
- SSH key validation before server creation
- Name uniqueness enforcement
- Timestamp tracking (created_at, updated_at)
- Repos directory auto-creation
Tests:
- 24 comprehensive test cases covering all scenarios
- Encryption verification tests
- Edge case handling (duplicates, not found, invalid references)
- All tests passing (63/63 total)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implemented SshKeyService class following TDD principles with comprehensive test coverage:
Service Methods:
- create_ssh_key(name, private_key, password) - Creates SSH key with AES-256-GCM encryption
- list_ssh_keys() - Lists all SSH keys (without decrypted keys)
- get_ssh_key(key_id) - Retrieves SSH key by ID
- delete_ssh_key(key_id) - Deletes key with usage validation
- get_decrypted_key(key_id) - Returns decrypted private key for Git operations
Features:
- Encrypts SSH private keys before storing using app.security.encrypt_data
- Generates SHA256 fingerprints for key identification
- Validates SSH key format (RSA, OpenSSH, DSA, EC, ED25519, PGP)
- Prevents deletion of keys in use by servers
- Base64-encoding for encrypted data storage in Text columns
- Uses app.config.settings.encrypt_key for encryption
Tests:
- 16 comprehensive test cases covering all service methods
- All tests passing (16/16)
- Tests for encryption/decryption, validation, usage checks, edge cases
Files:
- backend/app/services/ssh_key_service.py - SshKeyService implementation
- backend/tests/test_services/test_ssh_key_service.py - Test suite
- backend/tests/conftest.py - Fixed test encryption key length (32 bytes)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Created SshKey model with encrypted private key storage
- Created Server model with Gitea configuration and SshKey relationship
- Created Repo model with repository mirror info and Server relationship
- Created SyncLog model with sync operation logs and Repo relationship
- Updated models/__init__.py to export all models
- All models use Integer (Unix timestamp) for datetime fields
- Proper bidirectional relationships using back_populates
- Added comprehensive test suite for all models and relationships
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add SQLAlchemy database module with DeclarativeBase
- Implement engine and session factory management
- Add context manager for database sessions
- Add database initialization script
- Update models/__init__.py to import Base from database
- Fix Python 3.8 compatibility issues (use Optional instead of |)
- Ensure SQLite database file is created on init_db
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Implement AES-256-GCM encryption for sensitive data
- Implement decryption function
- Implement Bearer token authentication verification
- Add comprehensive tests for encryption/decryption roundtrip
- Add tests for API token verification (success and failure cases)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fixes from code review:
Critical:
- Replace module-level `settings = Settings()` with lazy initialization
via `get_settings()` function to avoid import failures when env vars
not set
Important:
- Remove unused `import os` from test_config.py
- Add tests for computed properties (db_path, ssh_keys_dir, repos_dir)
- Add field validation for encrypt_key:
* Validates base64 format
* Ensures decoded key is at least 32 bytes for AES-256
- Fix Python 3.8 compatibility (use Optional[Settings] instead of | union)
All tests pass (6/6).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add Settings class using pydantic-settings
- Load config from environment variables with GM_ prefix
- Support encrypt_key and api_token (required, no defaults for security)
- Provide defaults for data_dir, host, port
- Add computed properties for db_path, ssh_keys_dir, repos_dir
- Add tests for config defaults and environment variable overrides
- Add Base class to app.models to unblock conftest.py imports
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Create backend directory structure (app/models, app/schemas, app/services, app/api, app/tasks, tests)
- Create frontend directory structure (src/router, src/views, src/components, src/api, src/stores)
- Create data directories (ssh_keys, repos)
- Add requirements.txt with FastAPI, SQLAlchemy, Pydantic, and testing dependencies
- Add frontend package.json with Vue 3, Vue Router, Pinia, and Element Plus
- Add .env.example with configuration template
- Add .gitignore for Python, data directories, and frontend
- Add pytest conftest.py with test fixtures for database and environment
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>