mikrotik-bot/test_vault.py
stakost 25d910cef7
All checks were successful
Build and Deploy MikroTik Bot / build-and-deploy (push) Successful in 26s
Fix Vault integration and ALLOWED_USER_IDS handling
2025-06-01 14:03:16 +03:00

40 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
from vault_client import VaultClient
import os
# Устанавливаем переменные окружения для тестирования
os.environ['VAULT_ADDR'] = 'http://10.10.30.121:8200'
os.environ['VAULT_ROLE_ID'] = 'ba8d3d21-263e-4d92-8ffe-ef803017cef5'
os.environ['VAULT_SECRET_ID'] = '6b3ecc3c-9436-7f04-022f-8b1ce0ac09ee'
os.environ['VAULT_SECRET_PATH'] = 'secret/data/mikrotik-bot'
def test_vault_secrets():
"""Тестирование получения секретов из Vault"""
print('🔍 Проверка получения секретов из Vault:')
print('=' * 50)
vault = VaultClient()
config = vault.get_config()
if not config:
print('Не удалось получить конфигурацию')
return False
success = True
for key, value in config.items():
if value:
masked_value = value[:10] + '...' if len(value) > 10 else value
print(f'{key}: {masked_value}')
else:
print(f'{key}: не найден')
success = False
return success
if __name__ == '__main__':
if test_vault_secrets():
print('\n🎉 Все секреты успешно получены!')
print('✅ Готов к production deployment')
else:
print('\n❌ Есть проблемы с получением секретов')