-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rgw/admin: support new-bucket-name for LinkBucket
Signed-off-by: Simon Jürgensmeyer <[email protected]>
- Loading branch information
Showing
2 changed files
with
68 additions
and
9 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
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 |
---|---|---|
|
@@ -55,7 +55,7 @@ func (suite *RadosGWTestSuite) TestLink() { | |
bucket, err := co.GetBucketInfo(context.Background(), Bucket{Bucket: suite.bucketTestName}) | ||
assert.NoError(t, err) | ||
|
||
err = co.UnlinkBucket(context.Background(), BucketLinkInput{ | ||
err = co.UnlinkBucket(context.Background(), BucketUnlinkInput{ | ||
Bucket: suite.bucketTestName, | ||
UID: bucket.Owner, | ||
}) | ||
|
@@ -76,4 +76,57 @@ func (suite *RadosGWTestSuite) TestLink() { | |
err := co.RemoveUser(context.Background(), User{ID: "test-user2"}) | ||
assert.NoError(suite.T(), err) | ||
}) | ||
|
||
} | ||
|
||
func (suite *RadosGWTestSuite) TestLinkRename() { | ||
suite.SetupConnection() | ||
co, err := New(suite.endpoint, suite.accessKey, suite.secretKey, newDebugHTTPClient(http.DefaultClient)) | ||
assert.NoError(suite.T(), err) | ||
|
||
const ( | ||
userName = "test-user-bucket-rename" | ||
initialBucketName = "initial-name" | ||
renamedBucketName = "renamed-name" | ||
) | ||
|
||
suite.T().Run("create test user for bucket rename", func(_ *testing.T) { | ||
user, err := co.CreateUser(context.Background(), User{ID: userName, DisplayName: userName, Email: "[email protected]"}) | ||
assert.NoError(suite.T(), err) | ||
assert.Equal(suite.T(), userName, user.ID) | ||
assert.Zero(suite.T(), len(user.Caps)) | ||
}) | ||
|
||
suite.T().Run("create test bucket for rename", func(t *testing.T) { | ||
s3, err := newS3Agent(suite.accessKey, suite.secretKey, suite.endpoint, true) | ||
assert.NoError(t, err) | ||
|
||
err = s3.createBucket(initialBucketName) | ||
assert.NoError(t, err) | ||
}) | ||
|
||
suite.T().Run("rename bucket", func(t *testing.T) { | ||
err = co.LinkBucket(context.Background(), BucketLinkInput{ | ||
UID: userName, | ||
Bucket: initialBucketName, | ||
NewBucketName: renamedBucketName, | ||
}) | ||
assert.NoError(suite.T(), err) | ||
|
||
_, err = co.GetBucketInfo(context.Background(), Bucket{Bucket: initialBucketName}) | ||
assert.ErrorIs(t, err, ErrNoSuchBucket) | ||
|
||
_, err = co.GetBucketInfo(context.Background(), Bucket{Bucket: renamedBucketName}) | ||
assert.NoError(t, err) | ||
}) | ||
|
||
suite.T().Run("remove bucket", func(_ *testing.T) { | ||
err := co.RemoveBucket(context.Background(), Bucket{Bucket: renamedBucketName}) | ||
assert.NoError(suite.T(), err) | ||
}) | ||
|
||
suite.T().Run("delete test user for bucket rename", func(_ *testing.T) { | ||
err := co.RemoveUser(context.Background(), User{ID: userName}) | ||
assert.NoError(suite.T(), err) | ||
}) | ||
} |