|
|
3 månader sedan | |
|---|---|---|
| .. | ||
| Makefile | 3 månader sedan | |
| README.md | 3 månader sedan | |
| docker-compose.yml | 3 månader sedan | |
| filer.toml | 3 månader sedan | |
| openbao_integration_test.go | 3 månader sedan | |
| setup_openbao.sh | 3 månader sedan | |
| test_s3_kms.sh | 3 månader sedan | |
| wait_for_services.sh | 3 månader sedan | |
This directory contains comprehensive integration tests for SeaweedFS Server-Side Encryption (SSE) with Key Management Service (KMS) providers. The tests validate the complete encryption/decryption workflow using OpenBao (open source fork of HashiCorp Vault) as the KMS provider.
The KMS integration tests simulate AWS KMS functionality using OpenBao, providing:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ S3 Client │ │ SeaweedFS │ │ OpenBao │
│ (aws s3) │───▶│ S3 API │───▶│ Transit │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
│ ┌─────────────────┐ │
│ │ KMS Manager │ │
└──────────────▶│ - AWS Provider │◀─────────────┘
│ - Azure Provider│
│ - GCP Provider │
│ - OpenBao │
└─────────────────┘
bao) - For direct OpenBao interaction (optional)# Install Docker (macOS)
brew install docker docker-compose
# Install OpenBao (optional - used by some tests)
brew install openbao
# Install AWS CLI
brew install awscli
# Install jq
brew install jq
cd test/kms
make test
# Unit tests only
make test-unit
# Integration tests with OpenBao
make test-integration
# End-to-end S3 API tests
make test-e2e
# Performance benchmarks
make test-benchmark
# Start OpenBao only
make dev-openbao
# Start full environment (OpenBao + SeaweedFS)
make setup-seaweedfs
# Run manual tests
make dev-test
openbao_integration_test.go)What it tests:
Key test cases:
TestOpenBaoKMSProvider_Integration
TestOpenBaoKMSProvider_ErrorHandling
TestKMSManager_WithOpenBao
BenchmarkOpenBaoKMS_GenerateDataKey
BenchmarkOpenBaoKMS_Decrypt
test_s3_kms.sh)What it tests:
Key scenarios:
# Bucket encryption setup
aws s3api put-bucket-encryption --bucket test-openbao \
--server-side-encryption-configuration '{
"Rules": [{
"ApplyServerSideEncryptionByDefault": {
"SSEAlgorithm": "aws:kms",
"KMSMasterKeyID": "test-key-1"
}
}]
}'
# Object upload with encryption
aws s3 cp file.txt s3://test-openbao/encrypted-file.txt \
--sse aws:kms --sse-kms-key-id "test-key-2"
docker-compose.yml)Services:
filer.toml)KMS Configuration:
[kms]
default_provider = "openbao-test"
[kms.providers.openbao-test]
type = "openbao"
address = "http://openbao:8200"
token = "root-token-for-testing"
transit_path = "transit"
[kms.buckets.test-openbao]
provider = "openbao-test"
The setup script creates these test keys in OpenBao:
| Key Name | Type | Purpose |
|---|---|---|
test-key-1 |
AES256-GCM96 | Basic operations |
test-key-2 |
AES256-GCM96 | Multi-key scenarios |
seaweedfs-test-key |
AES256-GCM96 | Integration testing |
bucket-default-key |
AES256-GCM96 | Default bucket encryption |
high-security-key |
AES256-GCM96 | Security testing |
performance-key |
AES256-GCM96 | Performance benchmarks |
multipart-key |
AES256-GCM96 | Multipart upload testing |
| Bucket Name | KMS Provider | Purpose |
|---|---|---|
test-openbao |
openbao-test | OpenBao integration |
test-vault |
vault-test | Vault compatibility |
test-local |
local-test | Local KMS testing |
secure-data |
openbao-test | High security scenarios |
# OpenBao configuration
export OPENBAO_ADDR="http://127.0.0.1:8200"
export OPENBAO_TOKEN="root-token-for-testing"
# SeaweedFS configuration
export SEAWEEDFS_S3_ENDPOINT="http://127.0.0.1:8333"
export ACCESS_KEY="any"
export SECRET_KEY="any"
# Test configuration
export TEST_TIMEOUT="5m"
| Target | Description |
|---|---|
make help |
Show available commands |
make setup |
Set up test environment |
make test |
Run all tests |
make test-unit |
Run unit tests only |
make test-integration |
Run integration tests |
make test-e2e |
Run end-to-end tests |
make clean |
Clean up environment |
make logs |
Show service logs |
make status |
Check service status |
OpenBao provider is automatically registered via init():
func init() {
seaweedkms.RegisterProvider("openbao", NewOpenBaoKMSProvider)
seaweedkms.RegisterProvider("vault", NewOpenBaoKMSProvider) // Alias
}
1. S3 PUT with SSE-KMS headers
2. SeaweedFS extracts KMS key ID
3. KMSManager routes to OpenBao provider
4. OpenBao generates random data key
5. OpenBao encrypts data key with master key
6. SeaweedFS encrypts object with data key
7. Encrypted data key stored in metadata
1. S3 GET request for encrypted object
2. SeaweedFS extracts encrypted data key from metadata
3. KMSManager routes to OpenBao provider
4. OpenBao decrypts data key with master key
5. SeaweedFS decrypts object with data key
6. Plaintext object returned to client
OpenBao not starting:
# Check if port 8200 is in use
lsof -i :8200
# Check Docker logs
docker-compose logs openbao
KMS provider not found:
# Verify provider registration
go test -v -run TestProviderRegistration ./test/kms/
# Check imports in filer_kms.go
grep -n "kms/" weed/command/filer_kms.go
S3 API connection refused:
# Check SeaweedFS services
make status
# Wait for services to be ready
./wait_for_services.sh
# Test OpenBao directly
curl -H "X-Vault-Token: root-token-for-testing" \
http://127.0.0.1:8200/v1/sys/health
# Test transit engine
curl -X POST \
-H "X-Vault-Token: root-token-for-testing" \
-d '{"plaintext":"SGVsbG8gV29ybGQ="}' \
http://127.0.0.1:8200/v1/transit/encrypt/test-key-1
# Test S3 API
aws s3 ls --endpoint-url http://127.0.0.1:8333
This test suite simulates AWS KMS behavior using OpenBao, enabling:
Typical performance metrics (local testing):
After successful integration testing, deploy with real KMS providers:
[kms.providers.aws-prod]
type = "aws"
region = "us-east-1"
# IAM roles preferred over access keys
[kms.providers.azure-prod]
type = "azure"
vault_url = "https://prod-vault.vault.azure.net/"
use_default_creds = true # Managed identity
[kms.providers.gcp-prod]
type = "gcp"
project_id = "prod-project"
use_default_credentials = true # Service account
Tests pass when:
For issues with KMS integration tests:
make logsmake statusmake debugmake clean && make setupHappy testing! 🔐✨