|
| 1 | +# GitHub Actions Workflows |
| 2 | + |
| 3 | +## SPNEGO Integration Tests |
| 4 | + |
| 5 | +**File**: `integration-tests.yml` |
| 6 | + |
| 7 | +### What It Does |
| 8 | + |
| 9 | +Runs end-to-end integration tests for SPNEGO proxy authentication using Docker containers for KDC and Squid proxy. |
| 10 | + |
| 11 | +### When It Runs |
| 12 | + |
| 13 | +**Push Events**: |
| 14 | +- `main` branch |
| 15 | +- `master` branch |
| 16 | +- `add-proxy-auth-support-tests` branch |
| 17 | + |
| 18 | +**Pull Requests** that modify: |
| 19 | +- Any Go files (`**.go`) |
| 20 | +- Go module files (`go.mod`, `go.sum`) |
| 21 | +- Test infrastructure (`pkg/testinfra/**`) |
| 22 | +- Integration tests (`integration/**`) |
| 23 | +- Proxy auth files (`proxy_auth*.go`) |
| 24 | +- This workflow file |
| 25 | + |
| 26 | +### Test Execution |
| 27 | + |
| 28 | +```bash |
| 29 | +go test -v -tags=integration -run TestSPNEGOProxy -timeout=15m ./integration/... |
| 30 | +``` |
| 31 | + |
| 32 | +**Tests Run**: |
| 33 | +- `TestSPNEGOProxy/SPNEGOAuthentication` - SPNEGO authenticator creation and validation |
| 34 | +- `TestSPNEGOProxy/SPNEGOWithPivnetClient` - Pivnet client with SPNEGO proxy (if `PIVNET_API_TOKEN` is set) |
| 35 | + |
| 36 | +### Environment Variables |
| 37 | + |
| 38 | +- `CGO_ENABLED=1` - Required for some dependencies |
| 39 | +- `TESTCONTAINERS_RYUK_DISABLED=true` - Disables Ryuk container reaper |
| 40 | +- `DOCKER_HOST=unix:///var/run/docker.sock` - Docker socket path |
| 41 | +- `PIVNET_API_TOKEN` - Optional secret for Pivnet API testing |
| 42 | + |
| 43 | +### Secrets Required |
| 44 | + |
| 45 | +#### Optional Secrets |
| 46 | + |
| 47 | +- `PIVNET_API_TOKEN` - Pivnet API token for testing with actual API |
| 48 | + - If not set, the Pivnet client test is skipped |
| 49 | + - To add: Go to repository Settings → Secrets and variables → Actions → New repository secret |
| 50 | + |
| 51 | +### Infrastructure |
| 52 | + |
| 53 | +The workflow uses Docker to spin up: |
| 54 | +1. **KDC Container** (`gcavalcante8808/krb5-server:latest`) |
| 55 | + - Kerberos Key Distribution Center |
| 56 | + - Creates test principals |
| 57 | + - Provides authentication service |
| 58 | + |
| 59 | +2. **Squid Proxy Container** (`ubuntu/squid:latest`) |
| 60 | + - Configured with SPNEGO authentication |
| 61 | + - Uses keytab from KDC |
| 62 | + - Proxies HTTP/HTTPS requests |
| 63 | + |
| 64 | +### Expected Behavior |
| 65 | + |
| 66 | +✅ **Success Cases**: |
| 67 | +- Infrastructure starts successfully (KDC + Proxy) |
| 68 | +- Principals are created |
| 69 | +- Configuration files are generated |
| 70 | +- Tests validate the setup |
| 71 | + |
| 72 | +⚠️ **Known Limitations**: |
| 73 | +- Kerberos authentication from GitHub Actions runner to containerized KDC may fail |
| 74 | +- This is expected due to container networking |
| 75 | +- Tests validate infrastructure and handle this gracefully with skip/pass |
| 76 | + |
| 77 | +### Artifacts |
| 78 | + |
| 79 | +On test failure, the following artifacts are uploaded: |
| 80 | +- Test logs from `/tmp/*.log` |
| 81 | +- Kerberos config files from `/tmp/*/krb5.conf` |
| 82 | +- Retained for 7 days |
| 83 | + |
| 84 | +### Local Testing |
| 85 | + |
| 86 | +To run the same tests locally: |
| 87 | + |
| 88 | +```bash |
| 89 | +# Basic run |
| 90 | +TESTCONTAINERS_RYUK_DISABLED=true go test -tags=integration -v -run TestSPNEGOProxy -timeout=15m ./integration/... |
| 91 | + |
| 92 | +# With Pivnet API token |
| 93 | +export PIVNET_API_TOKEN="your-token" |
| 94 | +TESTCONTAINERS_RYUK_DISABLED=true go test -tags=integration -v -run TestSPNEGOProxy -timeout=15m ./integration/... |
| 95 | +``` |
| 96 | + |
| 97 | +### Troubleshooting |
| 98 | + |
| 99 | +#### Workflow Fails to Start |
| 100 | + |
| 101 | +- Check if Docker is available in the runner |
| 102 | +- Verify `actions/checkout@v4` and `actions/setup-go@v5` are working |
| 103 | + |
| 104 | +#### Tests Timeout |
| 105 | + |
| 106 | +- Increase timeout in workflow (currently 15m) |
| 107 | +- Check Docker resource limits in GitHub Actions |
| 108 | + |
| 109 | +#### Image Pull Failures |
| 110 | + |
| 111 | +- Tests use public Docker images by default |
| 112 | +- If you need private registry, update `pkg/testinfra/config.go` |
| 113 | + |
| 114 | +#### Tests Skip Due to Container Networking |
| 115 | + |
| 116 | +- This is expected behavior |
| 117 | +- Tests validate infrastructure setup |
| 118 | +- Full Kerberos auth may not work in CI environment |
| 119 | + |
| 120 | +### Monitoring |
| 121 | + |
| 122 | +Check workflow status: |
| 123 | +- Repository → Actions tab |
| 124 | +- Look for "SPNEGO Integration Tests" workflow |
| 125 | +- Click on specific run to see logs |
| 126 | + |
| 127 | +### Maintenance |
| 128 | + |
| 129 | +#### Update Go Version |
| 130 | + |
| 131 | +The workflow uses `go-version-file: 'go.mod'` to automatically use the Go version specified in `go.mod`. |
| 132 | + |
| 133 | +#### Update Docker Images |
| 134 | + |
| 135 | +Update in `pkg/testinfra/config.go`: |
| 136 | +```go |
| 137 | +const ( |
| 138 | + KDCImage = "gcavalcante8808/krb5-server:latest" |
| 139 | + SquidImage = "ubuntu/squid:latest" |
| 140 | +) |
| 141 | +``` |
| 142 | + |
| 143 | +#### Add More Tests |
| 144 | + |
| 145 | +To run additional tests, update the test command: |
| 146 | +```yaml |
| 147 | +- name: Run SPNEGO Integration Tests |
| 148 | + run: | |
| 149 | + go test -v -tags=integration -run "TestSPNEGO|TestBasic" -timeout=15m ./integration/... |
| 150 | +``` |
| 151 | +
|
| 152 | +## Future Workflows |
| 153 | +
|
| 154 | +Consider adding: |
| 155 | +- Unit tests workflow |
| 156 | +- Linting workflow |
| 157 | +- Security scanning |
| 158 | +- Release workflow |
| 159 | +
|
0 commit comments