algo/tests/test-local-config.sh
Dan Guido cddb5df395
Add comprehensive pre-commit hooks for code quality (#14831)
* Add comprehensive pre-commit hooks for code quality

- Set up pre-commit framework with hooks for Python, YAML, Ansible, and shell
- Configure ruff for Python linting and formatting
- Add yamllint for YAML validation
- Include ansible-lint and syntax checks
- Add shellcheck for shell scripts
- Create development documentation
- Auto-fix trailing whitespace and file endings

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Remove redundant DEVELOPMENT.md and update CONTRIBUTING.md

- Removed docs/DEVELOPMENT.md as it was redundant with existing documentation
- Added pre-commit hooks setup instruction to CONTRIBUTING.md for contributors
- Consolidated development guidance into a single location

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-09-15 10:03:46 -04:00

68 lines
1.6 KiB
Bash
Executable file

#!/bin/bash
# Simple test that verifies Algo can generate configurations without errors
set -e
echo "Testing Algo configuration generation..."
# Generate SSH key if it doesn't exist
if [ ! -f ~/.ssh/id_rsa ]; then
ssh-keygen -f ~/.ssh/id_rsa -t rsa -N ''
fi
# Create a minimal test configuration
cat > test-config.cfg << 'EOF'
users:
- test-user
cloud_providers:
local:
server: localhost
endpoint: 127.0.0.1
wireguard_enabled: true
ipsec_enabled: false
dns_adblocking: false
ssh_tunneling: false
store_pki: true
tests: true
algo_provider: local
algo_server_name: test-server
algo_ondemand_cellular: false
algo_ondemand_wifi: false
algo_ondemand_wifi_exclude: ""
algo_dns_adblocking: false
algo_ssh_tunneling: false
wireguard_PersistentKeepalive: 0
wireguard_network: 10.19.49.0/24
wireguard_network_ipv6: fd9d:bc11:4020::/48
wireguard_port: 51820
dns_encryption: false
subjectAltName_type: IP
subjectAltName: 127.0.0.1
IP_subject_alt_name: 127.0.0.1
algo_server: localhost
algo_user: ubuntu
ansible_ssh_user: ubuntu
algo_ssh_port: 22
endpoint: 127.0.0.1
server: localhost
ssh_user: ubuntu
CA_password: "test-password-123"
p12_export_password: "test-export-password"
EOF
# Run Ansible in check mode to verify templates work
echo "Running Ansible in check mode..."
uv run ansible-playbook main.yml \
-i "localhost," \
-c local \
-e @test-config.cfg \
-e "provider=local" \
--check \
--diff \
--tags "configuration" \
--skip-tags "restart_services,tests,assert,cloud,facts_install"
echo "Configuration generation test passed!"
# Clean up
rm -f test-config.cfg