This directory contains comprehensive integration tests for the SeaweedFS S3 API with Advanced IAM (Identity and Access Management) system integration.
Important: The STS service uses a stateless JWT design where all session information is embedded directly in the JWT token. No external session storage is required.
The S3 IAM integration tests validate the complete end-to-end functionality of:
TestS3IAMAuthentication)TestS3IAMPolicyEnforcement)TestS3IAMSessionExpiration)TestS3IAMMultipartUploadPolicyEnforcement)TestS3IAMBucketPolicyIntegration)TestS3IAMContextualPolicyEnforcement)TestS3IAMPresignedURLIntegration)weed) built with IAM supportTest Dependencies:
go get github.com/stretchr/testify
go get github.com/aws/aws-sdk-go
go get github.com/golang-jwt/jwt/v5
# Run all tests with service management
make test
# Quick test run (assumes services running)
make test-quick
# Test only authentication
make test-auth
# Test only policy enforcement
make test-policy
# Test only session expiration
make test-expiration
# Test only multipart uploads
make test-multipart
# Test only bucket policies
make test-bucket-policy
# Start services and keep running
make debug
# Show service logs
make logs
# Check service status
make status
# Watch for changes and re-run tests
make watch
If you prefer to manage services manually:
# Start services
make start-services
# Wait for services to be ready
make wait-for-services
# Run tests
make run-tests
# Stop services
make stop-services
test_config.json)The test configuration defines:
| Service | Port | Purpose |
|---|---|---|
| Master | 9333 | Cluster coordination |
| Volume | 8080 | Object storage |
| Filer | 8888 | Metadata & IAM storage |
| S3 API | 8333 | S3-compatible API with IAM |
# SeaweedFS binary location
export WEED_BINARY=../../../weed
# Service ports (optional)
export S3_PORT=8333
export FILER_PORT=8888
export MASTER_PORT=9333
export VOLUME_PORT=8080
# Test timeout
export TEST_TIMEOUT=30m
# Log level (0-4)
export LOG_LEVEL=2
The test framework automatically:
# Clean everything
make clean
# Clean while keeping services running
rm -rf test-volume-data/
Create Test Function:
func TestS3IAMNewFeature(t *testing.T) {
framework := NewS3IAMTestFramework(t)
defer framework.Cleanup()
// Test implementation
}
Use Test Framework:
// Create authenticated S3 client
s3Client, err := framework.CreateS3ClientWithJWT("user", "TestRole")
require.NoError(t, err)
// Test S3 operations
err = framework.CreateBucket(s3Client, "test-bucket")
require.NoError(t, err)
Add to Makefile:
test-new-feature: ## Test new feature
go test -v -run TestS3IAMNewFeature ./...
Add policies to test_config.json:
{
"policies": {
"CustomPolicy": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:GetObject"],
"Resource": ["arn:seaweed:s3:::specific-bucket/*"],
"Condition": {
"StringEquals": {
"s3:prefix": ["allowed-prefix/"]
}
}
}
]
}
}
}
Mock Provider Setup:
// In test framework
func (f *S3IAMTestFramework) setupCustomProvider() {
provider := custom.NewCustomProvider("test-custom")
// Configure and register
}
Configuration:
{
"providers": {
"custom": {
"test-custom": {
"endpoint": "http://localhost:8080",
"clientId": "custom-client"
}
}
}
}
# Check if ports are available
netstat -an | grep -E "(8333|8888|9333|8080)"
# Check service logs
make logs
# Try different ports
export S3_PORT=18333
make start-services
# Verify OIDC mock server
curl http://localhost:8080/.well-known/openid_configuration
# Check JWT token format in logs
make logs | grep -i jwt
# Verify IAM configuration
cat test_config.json | jq '.policies'
# Check policy evaluation in logs
export LOG_LEVEL=4
make start-services
# Increase timeout
export TEST_TIMEOUT=60m
make test
# Run individual tests
make test-auth
Start services in debug mode to inspect manually:
# Start and keep running
make debug
# In another terminal, run specific operations
aws s3 ls --endpoint-url http://localhost:8333
# Stop when done (Ctrl+C in debug terminal)
# Service-specific logs
tail -f weed-s3.log # S3 API server
tail -f weed-filer.log # Filer (IAM storage)
tail -f weed-master.log # Master server
tail -f weed-volume.log # Volume server
# Filter for IAM-related logs
make logs | grep -i iam
make logs | grep -i jwt
make logs | grep -i policy
# Run performance benchmarks
make benchmark
# Profile memory usage
go test -bench=. -memprofile=mem.prof
go tool pprof mem.prof
For load testing with IAM:
Create Multiple Clients:
// Generate multiple JWT tokens
tokens := framework.GenerateMultipleJWTTokens(100)
// Create concurrent clients
var wg sync.WaitGroup
for _, token := range tokens {
wg.Add(1)
go func(token string) {
defer wg.Done()
// Perform S3 operations
}(token)
}
wg.Wait()
Measure Performance:
# Run with verbose output
go test -v -bench=BenchmarkS3IAMOperations
name: S3 IAM Integration Tests
on: [push, pull_request]
jobs:
s3-iam-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.19'
- name: Build SeaweedFS
run: go build -o weed ./main.go
- name: Run S3 IAM Tests
run: |
cd test/s3/iam
make ci
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'go build -o weed ./main.go'
}
}
stage('S3 IAM Tests') {
steps {
dir('test/s3/iam') {
sh 'make ci'
}
}
post {
always {
dir('test/s3/iam') {
sh 'make clean'
}
}
}
}
}
}
Follow Test Patterns:
S3IAMTestFramework for setupdefer framework.Cleanup()Update Documentation:
Ensure Test Reliability:
require.NoError() for critical assertionsassert.Equal() for value comparisonsFor issues with S3 IAM integration tests:
make logs to inspect service logstest_config.json is correctmake status to check service healthmake clean && make testThis test suite is part of the SeaweedFS project and follows the same licensing terms.