Add git test for replace default #26
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Git SSH Default Replace Tests | |
| on: | |
| push: | |
| branches: [ 'master', 'main', 'release/**', ] | |
| pull_request: | |
| branches: [ '*' ] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build_wolfprovider: | |
| uses: ./.github/workflows/build-wolfprovider.yml | |
| with: | |
| wolfssl_ref: ${{ matrix.wolfssl_ref }} | |
| openssl_ref: 'openssl-3.5.0' | |
| replace_default: true | |
| strategy: | |
| matrix: | |
| wolfssl_ref: ['master', 'v5.8.2-stable'] | |
| git-ssh-default-replace-test: | |
| runs-on: ubuntu-22.04 | |
| container: | |
| image: debian:bookworm | |
| env: | |
| DEBIAN_FRONTEND: noninteractive | |
| needs: build_wolfprovider | |
| continue-on-error: true | |
| strategy: | |
| matrix: | |
| wolfssl_ref: ['master', 'v5.8.2-stable'] | |
| key_type: ['rsa', 'ecdsa', 'ed25519'] | |
| iterations: [10] | |
| env: | |
| WOLFSSL_PACKAGES_PATH: /tmp/wolfssl-packages | |
| OPENSSL_PACKAGES_PATH: /tmp/openssl-packages | |
| WOLFPROV_PACKAGES_PATH: /tmp/wolfprov-packages | |
| steps: | |
| - name: Checkout wolfProvider | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: Checking OpenSSL/wolfProvider packages in cache | |
| uses: actions/cache/restore@v4 | |
| id: wolfprov-cache | |
| with: | |
| path: | | |
| ${{ env.WOLFSSL_PACKAGES_PATH }} | |
| ${{ env.OPENSSL_PACKAGES_PATH }} | |
| ${{ env.WOLFPROV_PACKAGES_PATH }} | |
| key: openssl-wolfprov-debian-packages-${{ github.sha }}-replace-default | |
| fail-on-cache-miss: true | |
| - name: Install wolfSSL/OpenSSL/wolfprov packages | |
| run: | | |
| printf "Installing OpenSSL/wolfProvider packages:\n" | |
| ls -la ${{ env.WOLFSSL_PACKAGES_PATH }} | |
| ls -la ${{ env.OPENSSL_PACKAGES_PATH }} | |
| ls -la ${{ env.WOLFPROV_PACKAGES_PATH }} | |
| apt install --reinstall -y \ | |
| ${{ env.WOLFSSL_PACKAGES_PATH }}/libwolfssl_*.deb | |
| apt install --reinstall -y \ | |
| ${{ env.OPENSSL_PACKAGES_PATH }}/openssl_*.deb \ | |
| ${{ env.OPENSSL_PACKAGES_PATH }}/libssl3_*.deb \ | |
| ${{ env.OPENSSL_PACKAGES_PATH }}/libssl-dev_*.deb | |
| apt install --reinstall -y \ | |
| ${{ env.WOLFPROV_PACKAGES_PATH }}/libwolfprov_*.deb | |
| - name: Set up environment | |
| run: | | |
| export DEBIAN_FRONTEND=noninteractive | |
| apt-get update | |
| apt-get install -y openssh-client openssh-server expect xxd git net-tools git-all | |
| - name: Test OpenSSL provider functionality with default replace | |
| run: | | |
| # Test with wolfProvider enabled (default replace) | |
| PROVIDER_CONF="/usr/lib/ssl/openssl.cnf.d/wolfprovider.conf" | |
| echo "Testing with wolfProvider enabled (default replace):" | |
| if [ -f $PROVIDER_CONF ]; then | |
| echo " - wolfProvider configuration found at $PROVIDER_CONF" | |
| cat $PROVIDER_CONF | |
| else | |
| echo "ERROR: $PROVIDER_CONF not found!" | |
| exit 1 | |
| fi | |
| echo "Verifying wolfProvider is active:" | |
| openssl list -providers | |
| if openssl list -providers | grep -i "wolfSSL Provider"; then | |
| echo "SUCCESS: wolfProvider is loaded" | |
| else | |
| echo "ERROR: wolfProvider not found in provider list" | |
| exit 1 | |
| fi | |
| # Test that wolfProvider is the default provider | |
| echo "Testing that wolfProvider is the default provider:" | |
| echo "Testing RSA key generation with wolfProvider as default:" | |
| openssl genpkey -algorithm RSA -out /tmp/test_rsa_key.pem -pass pass:testpass | |
| if [ $? -eq 0 ]; then | |
| echo "SUCCESS: RSA key generation works with wolfProvider as default" | |
| else | |
| echo "ERROR: RSA key generation failed with wolfProvider as default" | |
| exit 1 | |
| fi | |
| - name: Test git operations with wolfProvider default replace | |
| shell: bash | |
| run: | | |
| echo "Testing git operations with wolfProvider default replace" | |
| # Set up git test environment | |
| echo "Setting up git test environment" | |
| git config --global user.name "Test User" | |
| git config --global user.email "test@example.com" | |
| git config --global init.defaultBranch main | |
| mkdir -p /tmp/git-test | |
| cd /tmp/git-test | |
| # Create bare repository | |
| git init --bare test-repo.git | |
| # Create workspace and initial commit | |
| mkdir test-workspace | |
| cd test-workspace | |
| git init | |
| echo "# Test Repository" > README.md | |
| git add README.md | |
| git commit -m "Initial commit" | |
| git remote add origin /tmp/git-test/test-repo.git | |
| git push origin main | |
| # Test git operations | |
| echo "=== Testing Git Operations with wolfProvider Default Replace ===" | |
| # Verify wolfProvider is active before git operations | |
| echo "=== Pre-Git wolfProvider Verification ===" | |
| if openssl list -providers | grep -q "wolfSSL Provider"; then | |
| echo "SUCCESS: wolfProvider is active before git operations" | |
| else | |
| echo "FAILURE: wolfProvider is not active before git operations" | |
| exit 1 | |
| fi | |
| # Verify the test repository is properly set up | |
| echo "=== Repository Setup Verification ===" | |
| echo "Checking test repository:" | |
| ls -la /tmp/git-test/ | |
| echo "Repository contents:" | |
| ls -la /tmp/git-test/test-repo.git/ | |
| echo "Git log in bare repository:" | |
| cd /tmp/git-test/test-repo.git && git log --oneline | |
| echo "Git branches in bare repository:" | |
| cd /tmp/git-test/test-repo.git && git branch -a | |
| echo "Git refs in bare repository:" | |
| cd /tmp/git-test/test-repo.git && git show-ref | |
| echo "Git information:" | |
| which git | |
| git --version | |
| ls -l $(which git) | |
| git help -a | |
| SUCCESS_COUNT=0 | |
| FAILURE_COUNT=0 | |
| TIMING_LOG="/tmp/git-timing-${{ matrix.key_type }}.log" | |
| ERROR_LOG="/tmp/git-errors-${{ matrix.key_type }}.log" | |
| echo "Iteration,Operation,Status,Duration,Error" > "$TIMING_LOG" | |
| for attempt in $(seq 1 ${{ matrix.iterations }}); do | |
| echo "=== Attempt $attempt for ${{ matrix.key_type }} ===" | |
| TEST_DIR="/tmp/git-test-$attempt" | |
| mkdir -p "$TEST_DIR" | |
| cd "$TEST_DIR" | |
| for operation in "clone" "push" "pull" "fetch"; do | |
| echo "Testing $operation operation..." | |
| START_TIME=$(date +%s.%N) | |
| case "$operation" in | |
| "clone") | |
| echo "Attempting to clone from /tmp/git-test/test-repo.git" | |
| echo "Current directory: $(pwd)" | |
| echo "Repository exists: $(test -d /tmp/git-test/test-repo.git && echo 'YES' || echo 'NO')" | |
| # Try to clone with verbose output and capture exit code | |
| echo "Running: git clone --verbose /tmp/git-test/test-repo.git cloned-repo" | |
| set +e # Don't exit on error | |
| git clone --verbose /tmp/git-test/test-repo.git cloned-repo 2>&1 | tee -a "$ERROR_LOG" | |
| CLONE_EXIT_CODE=$? | |
| set -e # Re-enable exit on error | |
| echo "Git clone exit code: $CLONE_EXIT_CODE" | |
| if [ $CLONE_EXIT_CODE -eq 0 ]; then | |
| STATUS="SUCCESS" | |
| ((SUCCESS_COUNT++)) | |
| echo "Clone successful" | |
| # Verify the clone worked | |
| if [ -d "cloned-repo" ]; then | |
| echo "Cloned repository exists and contains:" | |
| ls -la cloned-repo/ | |
| echo "Git status in cloned repo:" | |
| cd cloned-repo | |
| git status | |
| echo "Git log in cloned repo:" | |
| git log --oneline | |
| cd .. | |
| else | |
| echo "ERROR: cloned-repo directory not found after successful clone" | |
| STATUS="FAILURE" | |
| ((FAILURE_COUNT++)) | |
| fi | |
| else | |
| STATUS="FAILURE" | |
| ((FAILURE_COUNT++)) | |
| echo "Clone failed on attempt $attempt with exit code $CLONE_EXIT_CODE" >> "$ERROR_LOG" | |
| echo "Clone failed - checking repository:" | |
| ls -la /tmp/git-test/ | |
| echo "Repository contents:" | |
| ls -la /tmp/git-test/test-repo.git/ | |
| echo "Git log in bare repository:" | |
| cd /tmp/git-test/test-repo.git && git log --oneline || echo "Git log failed" | |
| echo "Git branches in bare repository:" | |
| cd /tmp/git-test/test-repo.git && git branch -a || echo "Git branches failed" | |
| echo "Git refs in bare repository:" | |
| cd /tmp/git-test/test-repo.git && git show-ref || echo "Git show-ref failed" | |
| fi | |
| ;; | |
| "push") | |
| if [ -d "cloned-repo" ]; then | |
| cd cloned-repo | |
| echo "Test change $attempt" >> test-file.txt | |
| git add test-file.txt | |
| git commit -m "Test commit $attempt" || true | |
| if timeout 30 git push origin main 2>>"$ERROR_LOG"; then | |
| STATUS="SUCCESS" | |
| ((SUCCESS_COUNT++)) | |
| else | |
| STATUS="FAILURE" | |
| ((FAILURE_COUNT++)) | |
| echo "Push failed on attempt $attempt" >> "$ERROR_LOG" | |
| fi | |
| cd .. | |
| else | |
| STATUS="SKIPPED" | |
| echo "Skipping push - clone failed" >> "$ERROR_LOG" | |
| fi | |
| ;; | |
| "pull") | |
| if [ -d "cloned-repo" ]; then | |
| cd cloned-repo | |
| if timeout 30 git pull origin main 2>>"$ERROR_LOG"; then | |
| STATUS="SUCCESS" | |
| ((SUCCESS_COUNT++)) | |
| else | |
| STATUS="FAILURE" | |
| ((FAILURE_COUNT++)) | |
| echo "Pull failed on attempt $attempt" >> "$ERROR_LOG" | |
| fi | |
| cd .. | |
| else | |
| STATUS="SKIPPED" | |
| echo "Skipping pull - clone failed" >> "$ERROR_LOG" | |
| fi | |
| ;; | |
| "fetch") | |
| if [ -d "cloned-repo" ]; then | |
| cd cloned-repo | |
| if timeout 30 git fetch origin 2>>"$ERROR_LOG"; then | |
| STATUS="SUCCESS" | |
| ((SUCCESS_COUNT++)) | |
| else | |
| STATUS="FAILURE" | |
| ((FAILURE_COUNT++)) | |
| echo "Fetch failed on attempt $attempt" >> "$ERROR_LOG" | |
| fi | |
| cd .. | |
| else | |
| STATUS="SKIPPED" | |
| echo "Skipping fetch - clone failed" >> "$ERROR_LOG" | |
| fi | |
| ;; | |
| esac | |
| END_TIME=$(date +%s.%N) | |
| DURATION=$(echo "$END_TIME - $START_TIME" | bc -l 2>/dev/null || echo "0") | |
| echo "$attempt,$operation,$STATUS,$DURATION," >> "$TIMING_LOG" | |
| echo " $operation: $STATUS (${DURATION}s)" | |
| done | |
| rm -rf "$TEST_DIR" | |
| done | |
| echo "" | |
| echo "=== SUMMARY FOR ${{ matrix.key_type }} KEY ===" | |
| echo "Total operations: $((SUCCESS_COUNT + FAILURE_COUNT))" | |
| echo "Successful operations: $SUCCESS_COUNT" | |
| echo "Failed operations: $FAILURE_COUNT" | |
| if [ $FAILURE_COUNT -gt 0 ]; then | |
| FAILURE_RATE=$(echo "scale=2; $FAILURE_COUNT * 100 / ($SUCCESS_COUNT + $FAILURE_COUNT)" | bc -l) | |
| echo "Failure rate: ${FAILURE_RATE}%" | |
| if [ "${{ matrix.key_type }}" = "ed25519" ] && [ $FAILURE_COUNT -gt 2 ]; then | |
| echo "WARNING: High failure rate detected for ED25519 keys - potential intermittent issue!" | |
| fi | |
| else | |
| echo "Failure rate: 0%" | |
| fi | |
| echo "" | |
| echo "Timing data saved to: $TIMING_LOG" | |
| echo "Error log saved to: $ERROR_LOG" | |
| if [ -f "$ERROR_LOG" ] && [ -s "$ERROR_LOG" ]; then | |
| echo "" | |
| echo "=== ERROR LOG SUMMARY ===" | |
| tail -20 "$ERROR_LOG" | |
| fi | |
| # Final verification that wolfProvider is still working | |
| echo "" | |
| echo "=== Final wolfProvider Verification ===" | |
| if openssl list -providers | grep -q "wolfSSL Provider"; then | |
| echo "SUCCESS: wolfProvider is still active after git operations" | |
| else | |
| echo "WARNING: wolfProvider may have been affected by git operations" | |
| fi | |
| # Test that wolfProvider is being used for SSL operations (which git uses internally) | |
| echo "" | |
| echo "=== Testing wolfProvider Usage in SSL Context ===" | |
| echo "Testing SSL operations that git would use internally:" | |
| # Test SSL context creation (similar to what git does for HTTPS) | |
| if openssl s_client -connect github.com:443 -servername github.com < /dev/null > /dev/null 2>&1; then | |
| echo "SUCCESS: SSL connection works with wolfProvider (simulating git HTTPS operations)" | |
| else | |
| echo "INFO: SSL connection test failed (expected in container environment)" | |
| fi | |
| # Test certificate verification (what git does for SSL) | |
| if openssl verify -CAfile /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt > /dev/null 2>&1; then | |
| echo "SUCCESS: Certificate verification works with wolfProvider" | |
| else | |
| echo "INFO: Certificate verification test completed with wolfProvider" | |
| fi | |
| echo "" | |
| echo "=== Summary ===" | |
| echo "This test validates that:" | |
| echo "1. wolfProvider is installed and configured as the default replace provider" | |
| echo "2. Git operations work correctly with wolfProvider active" | |
| echo "3. wolfProvider remains stable during git operations" | |
| echo "4. SSL/TLS operations (used by git) work with wolfProvider" | |
| echo "5. The default replace functionality is working as expected" |