Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,67 @@ jobs:
run: make yaegi_test
env:
GOPATH: ${{ github.workspace }}/go

integration:
name: Integration Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v5

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Install PowerShell and Pester
run: |
# Set non-interactive mode to avoid prompts
export DEBIAN_FRONTEND=noninteractive

sudo apt-get update
sudo apt-get install -y wget apt-transport-https software-properties-common

# Download and install Microsoft signing key and repository
wget -q "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb"

# Use dpkg with force-confdef and force-confold to handle config conflicts automatically
sudo dpkg --force-confdef --force-confold -i packages-microsoft-prod.deb

sudo apt-get update
sudo apt-get install -y powershell

# Install Pester testing framework
pwsh -c "Install-Module -Name Pester -Force -Scope CurrentUser -SkipPublisherCheck"

- name: Run Integration Tests
shell: pwsh
run: |
# Run the integration test script (skip cleanup for log collection on failure)
./Test-Integration.ps1 -HttpTimeoutSeconds 60 -SkipDockerCleanup

- name: Show logs on failure
if: failure()
run: |
echo "=== Docker container status ==="
docker ps -a
echo "=== CrowdSec logs ==="
docker logs crowdsec-test 2>/dev/null || echo "No CrowdSec container logs"
echo "=== Traefik logs ==="
docker logs traefik-test 2>/dev/null || echo "No Traefik container logs"
echo "=== Traefik Access Logs ==="
docker exec traefik-test cat /var/log/traefik/access.log 2>/dev/null || echo "No current Traefik access logs"
echo "=== Traefik Access Logs Backup (from test runs) ==="
docker exec traefik-test cat /var/log/traefik/access.log.bak 2>/dev/null || echo "No Traefik access logs backup"
echo "=== Whoami logs ==="
docker logs whoami-test 2>/dev/null || echo "No Whoami container logs"

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: test-results.xml
if-no-files-found: ignore

- name: Cleanup
if: always()
run: docker compose -f docker-compose.test.yml down -v --remove-orphans
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,20 @@ docker exec crowdsec cscli decisions add --ip 10.0.0.10 -d 10m -t captcha # this
docker exec crowdsec cscli decisions remove --ip 10.0.0.10 -t captcha
```

### Testing

#### Go Unit Tests

```bash
go test ./...
```

#### Integration Tests

```bash
./Test-Integration.ps1
```

### Examples

#### 1. Behind another proxy service (ex: clouflare) [examples/behind-proxy/README.md](https://github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin/blob/main/examples/behind-proxy/README.md)
Expand Down
Loading
Loading