Skip to content

Commit

Permalink
Changed response type for Add bucket
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
  • Loading branch information
Benjamin Perez committed Mar 17, 2023
1 parent 07b7af5 commit 113b7c9
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 69 deletions.
68 changes: 34 additions & 34 deletions integration/user_api_bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ func TestPutObjectsLegalholdStatus(t *testing.T) {
status := "enabled"

// 1. Create bucket
if !setupBucket(bucketName, true, true, nil, nil, assert, 201) {
if !setupBucket(bucketName, true, true, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -835,7 +835,7 @@ func TestGetBucketQuota(t *testing.T) {
validBucket := "testgetbucketquota"

// 1. Create bucket
if !setupBucket(validBucket, true, true, nil, nil, assert, 201) {
if !setupBucket(validBucket, true, true, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -912,7 +912,7 @@ func TestPutBucketQuota(t *testing.T) {
validBucket := "testputbucketquota"

// 1. Create bucket
if !setupBucket(validBucket, true, true, nil, nil, assert, 201) {
if !setupBucket(validBucket, true, true, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -971,7 +971,7 @@ func TestListBucketEvents(t *testing.T) {
validBucket := "testlistbucketevents"

// 1. Create bucket
if !setupBucket(validBucket, true, true, nil, nil, assert, 201) {
if !setupBucket(validBucket, true, true, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -1029,7 +1029,7 @@ func TestDeleteObjectsRetentionStatus(t *testing.T) {
validPrefix := encodeBase64(fileName)

// 1. Create bucket
if !setupBucket(bucketName, true, true, nil, nil, assert, 201) {
if !setupBucket(bucketName, true, true, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -1136,7 +1136,7 @@ func TestBucketSetPolicy(t *testing.T) {
validBucketName := "testbucketsetpolicy"

// 1. Create bucket
if !setupBucket(validBucketName, true, true, nil, nil, assert, 201) {
if !setupBucket(validBucketName, true, true, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -1197,7 +1197,7 @@ func TestRestoreObjectToASelectedVersion(t *testing.T) {
validPrefix := encodeBase64(fileName)

// 1. Create bucket
if !setupBucket(bucketName, true, true, nil, nil, assert, 201) {
if !setupBucket(bucketName, true, true, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -1285,7 +1285,7 @@ func TestPutBucketsTags(t *testing.T) {
// 1. Create the bucket
assert := assert.New(t)
validBucketName := "testputbuckettags1"
if !setupBucket(validBucketName, false, false, nil, nil, assert, 201) {
if !setupBucket(validBucketName, false, false, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -1343,7 +1343,7 @@ func TestGetsTheMetadataOfAnObject(t *testing.T) {
tags["tag"] = "testputobjecttagbucketonetagone"

// 1. Create the bucket
if !setupBucket(bucketName, false, false, nil, nil, assert, 201) {
if !setupBucket(bucketName, false, false, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -1414,7 +1414,7 @@ func TestPutObjectsRetentionStatus(t *testing.T) {
prefix := encodeBase64(fileName)

// 1. Create bucket
if !setupBucket(bucketName, true, true, nil, nil, assert, 201) {
if !setupBucket(bucketName, true, true, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -1512,7 +1512,7 @@ func TestShareObjectOnURL(t *testing.T) {
versionID := "null"

// 1. Create the bucket
if !setupBucket(bucketName, false, false, nil, nil, assert, 201) {
if !setupBucket(bucketName, false, false, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -1586,7 +1586,7 @@ func TestListObjects(t *testing.T) {
fileName := "testlistobjecttobucket1.txt"

// 1. Create the bucket
if !setupBucket(bucketName, false, false, nil, nil, assert, 201) {
if !setupBucket(bucketName, false, false, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -1634,7 +1634,7 @@ func TestDeleteObject(t *testing.T) {
numberOfFiles := 2

// 1. Create bucket
if !setupBucket(bucketName, true, true, nil, nil, assert, 201) {
if !setupBucket(bucketName, true, true, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -1700,7 +1700,7 @@ func TestUploadObjectToBucket(t *testing.T) {
fileName := "sample.txt"

// 1. Create the bucket
if !setupBucket(bucketName, false, false, nil, nil, assert, 201) {
if !setupBucket(bucketName, false, false, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -1735,7 +1735,7 @@ func TestDownloadObject(t *testing.T) {
}

// 1. Create the bucket
if !setupBucket(bucketName, true, true, nil, nil, assert, 201) {
if !setupBucket(bucketName, true, true, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -1797,7 +1797,7 @@ func TestDeleteMultipleObjects(t *testing.T) {
fileName := "testdeletemultipleobjs"

// 1. Create a bucket for this particular test
if !setupBucket(bucketName, false, false, nil, nil, assert, 201) {
if !setupBucket(bucketName, false, false, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -1874,7 +1874,7 @@ func TestPutObjectTag(t *testing.T) {
versionID := "null"

// 1. Create the bucket
if !setupBucket(bucketName, false, false, nil, nil, assert, 201) {
if !setupBucket(bucketName, false, false, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -1948,7 +1948,7 @@ func TestBucketRetention(t *testing.T) {
retention["mode"] = "compliance"
retention["unit"] = "years"
retention["validity"] = 2
if !setupBucket("setbucketretention1", true, true, nil, retention, assert, 201) {
if !setupBucket("setbucketretention1", true, true, nil, retention, assert, 200) {
return
}

Expand Down Expand Up @@ -1999,7 +1999,7 @@ func TestBucketInformationGenericErrorResponse(t *testing.T) {

// 1. Create the bucket
assert := assert.New(t)
if !setupBucket("bucketinformation2", false, false, nil, nil, assert, 201) {
if !setupBucket("bucketinformation2", false, false, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -2044,7 +2044,7 @@ func TestBucketInformationSuccessfulResponse(t *testing.T) {

// 1. Create the bucket
assert := assert.New(t)
if !setupBucket("bucketinformation1", false, false, nil, nil, assert, 201) {
if !setupBucket("bucketinformation1", false, false, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -2157,7 +2157,7 @@ func TestListBuckets(t *testing.T) {
// 1. Create buckets
numberOfBuckets := 3
for i := 1; i <= numberOfBuckets; i++ {
if !setupBucket("testlistbuckets"+strconv.Itoa(i), false, false, nil, nil, assert, 201) {
if !setupBucket("testlistbuckets"+strconv.Itoa(i), false, false, nil, nil, assert, 200) {
return
}
}
Expand Down Expand Up @@ -2273,7 +2273,7 @@ func TestBucketVersioning(t *testing.T) {

requestDataBody := bytes.NewReader(requestDataJSON)

if !setupBucket("test2", true, false, nil, nil, assert, 201) {
if !setupBucket("test2", true, false, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -2310,7 +2310,7 @@ func TestBucketVersioning(t *testing.T) {
if distributedSystem {
assert.Equal(200, response.StatusCode, "Versioning test Status Code is incorrect - bucket failed to create")
} else {
assert.NotEqual(201, response.StatusCode, "Versioning test Status Code is incorrect - versioned bucket created on non-distributed system")
assert.NotEqual(200, response.StatusCode, "Versioning test Status Code is incorrect - versioned bucket created on non-distributed system")
}

request, error := http.NewRequest("DELETE", "http://localhost:9090/api/v1/buckets/test2", requestDataBody)
Expand Down Expand Up @@ -2341,7 +2341,7 @@ func TestSetBucketTags(t *testing.T) {
}

// put bucket
if !setupBucket("test4", false, false, nil, nil, assert, 201) {
if !setupBucket("test4", false, false, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -2408,7 +2408,7 @@ func TestGetBucket(t *testing.T) {
Timeout: 2 * time.Second,
}

if !setupBucket("test3", false, false, nil, nil, assert, 201) {
if !setupBucket("test3", false, false, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -2446,7 +2446,7 @@ func TestAddBucket(t *testing.T) {
}{
{
name: "Add Bucket with valid name",
expectedStatus: 201,
expectedStatus: 200,
args: args{
bucketName: "test1",
},
Expand Down Expand Up @@ -3046,7 +3046,7 @@ func TestSetBucketVersioning(t *testing.T) {
versioning := true

// 1. Create bucket with versioning as true and locking as false
if !setupBucket(bucket, locking, versioning, nil, nil, assert, 201) {
if !setupBucket(bucket, locking, versioning, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -3129,7 +3129,7 @@ func TestEnableBucketEncryption(t *testing.T) {
kmsKeyID := ""

// 1. Add bucket
if !setupBucket(bucketName, locking, versioning, nil, nil, assert, 201) {
if !setupBucket(bucketName, locking, versioning, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -3398,7 +3398,7 @@ func TestBucketLifeCycle(t *testing.T) {
var noncurrentversionExpirationDays int64

// 1. Add bucket
if !setupBucket(bucketName, locking, versioning, nil, nil, assert, 201) {
if !setupBucket(bucketName, locking, versioning, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -3608,7 +3608,7 @@ func TestAccessRule(t *testing.T) {
access := "readonly"

// 1. Add bucket
if !setupBucket(bucketName, locking, versioning, nil, nil, assert, 201) {
if !setupBucket(bucketName, locking, versioning, nil, nil, assert, 200) {
return
}

Expand Down Expand Up @@ -3852,13 +3852,13 @@ func TestAddRemoteBucket(t *testing.T) {
fmt.Println("targetBucket: ", targetBucket)

// 1. Create bucket
if !setupBucket("source", true, true, nil, nil, assert, 201) {
if !setupBucket("source", true, true, nil, nil, assert, 200) {
return
}
// 1.1. Create target bucket
targetEndpoint := "http://localhost:9092"
targetToken := getTokenForEndpoint(targetEndpoint)
if !setupBucketForEndpoint(targetBucket, true, true, nil, nil, assert, 201, &targetEndpoint, &targetToken) {
if !setupBucketForEndpoint(targetBucket, true, true, nil, nil, assert, 200, &targetEndpoint, &targetToken) {
log.Println("bucket already exists")
}
_, err := SetBucketVersioning(targetBucket, false, &targetURL, &targetToken)
Expand Down Expand Up @@ -3911,13 +3911,13 @@ func TestDeleteRemoteBucket(t *testing.T) {
fmt.Println("targetBucket: ", targetBucket)

// 1. Create bucket
if !setupBucket("deletesource", true, true, nil, nil, assert, 201) {
if !setupBucket("deletesource", true, true, nil, nil, assert, 200) {
return
}
// 1.1. Create target bucket
targetEndpoint := "http://localhost:9092"
targetToken := getTokenForEndpoint(targetEndpoint)
if !setupBucketForEndpoint(targetBucket, true, true, nil, nil, assert, 201, &targetEndpoint, &targetToken) {
if !setupBucketForEndpoint(targetBucket, true, true, nil, nil, assert, 200, &targetEndpoint, &targetToken) {
log.Println("bucket already exists")
}
_, err := SetBucketVersioning(targetBucket, false, &targetURL, &targetToken)
Expand Down
67 changes: 67 additions & 0 deletions models/make_buckets_response.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion portal-ui/src/api/consoleApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,10 @@ export interface AddBucketReplication {
destination_bucket?: string;
}

export interface MakeBucketsResponse {
bucketName?: string;
}

export interface ListBucketEventsResponse {
events?: NotificationConfig[];
/**
Expand Down Expand Up @@ -1927,12 +1931,13 @@ export class Api<
* @secure
*/
makeBucket: (body: MakeBucketRequest, params: RequestParams = {}) =>
this.request<void, Error>({
this.request<MakeBucketsResponse, Error>({
path: `/buckets`,
method: "POST",
body: body,
secure: true,
type: ContentType.Json,
format: "json",
...params,
}),

Expand Down
Loading

0 comments on commit 113b7c9

Please sign in to comment.