mirror of
https://github.com/ceph/go-ceph
synced 2025-02-21 13:16:51 +00:00
rgw/admin: Add tests for user bucket quota APIs
Credits: Pavel Boev (https://github.com/R4scal) Signed-off-by: Anoop C S <anoopcs@cryptolab.net>
This commit is contained in:
parent
2f0bbfe505
commit
8cc709a846
50
rgw/admin/user_bucket_quota_test.go
Normal file
50
rgw/admin/user_bucket_quota_test.go
Normal file
@ -0,0 +1,50 @@
|
||||
//go:build ceph_preview
|
||||
|
||||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func (suite *RadosGWTestSuite) TestUserBucketQuota() {
|
||||
suite.SetupConnection()
|
||||
co, err := New(suite.endpoint, suite.accessKey, suite.secretKey, newDebugHTTPClient(http.DefaultClient))
|
||||
assert.NoError(suite.T(), err)
|
||||
|
||||
usercaps := "users=read"
|
||||
_, err = co.CreateUser(context.Background(), User{ID: "leseb", DisplayName: "This is leseb", Email: "leseb@example.com", UserCaps: usercaps})
|
||||
assert.NoError(suite.T(), err)
|
||||
defer func() {
|
||||
err = co.RemoveUser(context.Background(), User{ID: "leseb"})
|
||||
assert.NoError(suite.T(), err)
|
||||
}()
|
||||
|
||||
suite.T().Run("set bucket quota without uid", func(t *testing.T) {
|
||||
err := co.SetBucketQuota(context.Background(), QuotaSpec{})
|
||||
assert.Error(suite.T(), err)
|
||||
assert.EqualError(suite.T(), err, errMissingUserID.Error())
|
||||
})
|
||||
|
||||
suite.T().Run("set bucket quota", func(t *testing.T) {
|
||||
maxObjects := int64(101)
|
||||
err := co.SetBucketQuota(context.Background(), QuotaSpec{UID: "leseb", MaxObjects: &maxObjects})
|
||||
assert.NoError(suite.T(), err)
|
||||
})
|
||||
|
||||
suite.T().Run("get bucket quota without uid", func(t *testing.T) {
|
||||
_, err := co.GetBucketQuota(context.Background(), QuotaSpec{})
|
||||
assert.Error(suite.T(), err)
|
||||
assert.EqualError(suite.T(), err, errMissingUserID.Error())
|
||||
})
|
||||
|
||||
suite.T().Run("get bucket quota", func(t *testing.T) {
|
||||
q, err := co.GetBucketQuota(context.Background(), QuotaSpec{UID: "leseb"})
|
||||
assert.NoError(suite.T(), err)
|
||||
assert.Equal(suite.T(), int64(101), *q.MaxObjects)
|
||||
assert.Equal(suite.T(), false, *q.Enabled)
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user