feat(storage): add S3 backend support and advanced upload limits
- Introduce S3-compatible storage backend support using minio-go. - Add configuration options for local storage limits, box limits, and rate limiting. - Implement storage backend selection (local vs S3) for anonymous and registered users. - Add an `/admin/storage` management interface. - Update documentation and environment examples with the new configuration variables.
This commit is contained in:
@@ -146,6 +146,44 @@ func TestDailyUsageAndCleanup(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestEffectiveUserPolicyUsesOverridesAndInheritance(t *testing.T) {
|
||||
settings := newTestSettingsService(t)
|
||||
policy, err := settings.UploadPolicy()
|
||||
if err != nil {
|
||||
t.Fatalf("UploadPolicy returned error: %v", err)
|
||||
}
|
||||
policy.UserDailyUploadMB = 100
|
||||
policy.DefaultUserStorageMB = 200
|
||||
policy.UserMaxDays = 30
|
||||
policy.UserDailyBoxes = 40
|
||||
policy.UserActiveBoxes = 50
|
||||
policy.UserStorageBackend = "local"
|
||||
|
||||
overrideDaily := 300.0
|
||||
overrideQuota := 0.0
|
||||
overrideDays := 12
|
||||
overrideBackend := "bucket-1"
|
||||
user := User{
|
||||
ID: "user-1",
|
||||
Policy: UserPolicy{
|
||||
DailyUploadMB: &overrideDaily,
|
||||
StorageQuotaMB: &overrideQuota,
|
||||
MaxDays: &overrideDays,
|
||||
StorageBackendID: &overrideBackend,
|
||||
},
|
||||
}
|
||||
effective := settings.EffectivePolicyForUser(policy, user)
|
||||
if effective.DailyUploadMB != overrideDaily || effective.MaxDays != overrideDays || effective.StorageBackendID != overrideBackend {
|
||||
t.Fatalf("effective policy did not use overrides: %+v", effective)
|
||||
}
|
||||
if effective.StorageQuotaSet {
|
||||
t.Fatalf("zero storage quota override should mean unlimited: %+v", effective)
|
||||
}
|
||||
if effective.DailyBoxes != policy.UserDailyBoxes || effective.ActiveBoxes != policy.UserActiveBoxes {
|
||||
t.Fatalf("effective policy did not inherit box caps: %+v", effective)
|
||||
}
|
||||
}
|
||||
|
||||
func newTestSettingsService(t *testing.T) *SettingsService {
|
||||
t.Helper()
|
||||
root := t.TempDir()
|
||||
|
||||
Reference in New Issue
Block a user