forked from ceph/go-ceph
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rgw/admin: Add tests for user bucket quota APIs
Credits: Pavel Boev (https://github.com/R4scal) Signed-off-by: Anoop C S <[email protected]>
- Loading branch information
1 parent
2f0bbfe
commit 8cc709a
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: "[email protected]", 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) | ||
}) | ||
} |