authentikate/scripts/setup-test-keys.sh
Javier Feliz 81728c1623
Some checks failed
tests / ci (push) Waiting to run
linter / quality (push) Has been cancelled
Bring up test coverage
2025-08-02 17:00:25 -04:00

55 lines
1.3 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.

#!/bin/bash
# Script to set up test RSA keys for CI/CD environments
# This ensures tests run with proper keys without affecting production keys
set -e
# Define the test key directory
TEST_KEY_DIR="storage/testing/oauth"
# Function to generate test keys
generate_test_keys() {
echo "Setting up test RSA keys..."
# Create test directory if it doesn't exist
mkdir -p "$TEST_KEY_DIR"
# Generate test keys using artisan command
php artisan app:generate-keys --path="$TEST_KEY_DIR"
echo "✅ Test keys generated in $TEST_KEY_DIR"
}
# Function to clean up test keys
cleanup_test_keys() {
echo "Cleaning up test RSA keys..."
if [ -d "$TEST_KEY_DIR" ]; then
rm -rf "$TEST_KEY_DIR"
echo "✅ Test keys cleaned up"
else
echo " No test keys found to clean up"
fi
}
# Main script logic
case "${1:-setup}" in
"setup")
generate_test_keys
;;
"cleanup")
cleanup_test_keys
;;
"reset")
cleanup_test_keys
generate_test_keys
;;
*)
echo "Usage: $0 [setup|cleanup|reset]"
echo " setup - Generate test keys (default)"
echo " cleanup - Remove test keys"
echo " reset - Remove and regenerate test keys"
exit 1
;;
esac