Integration Test: Create Service Account (#1725)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
This commit is contained in:
@@ -654,7 +654,7 @@ func PutObjectsLegalholdStatus(bucketName string, prefix string, status string,
|
||||
}
|
||||
|
||||
func TestPutObjectsLegalholdStatus(t *testing.T) {
|
||||
printStartFunc("TestPutObjectsLegalholdStatus")
|
||||
|
||||
// Variables
|
||||
assert := assert.New(t)
|
||||
bucketName := "testputobjectslegalholdstatus"
|
||||
@@ -742,11 +742,11 @@ func TestPutObjectsLegalholdStatus(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
printEndFunc("TestPutObjectsLegalholdStatus")
|
||||
|
||||
}
|
||||
|
||||
func TestGetBucketQuota(t *testing.T) {
|
||||
printStartFunc("TestGetBucketQuota")
|
||||
|
||||
// Variables
|
||||
assert := assert.New(t)
|
||||
validBucket := "testgetbucketquota"
|
||||
@@ -821,11 +821,11 @@ func TestGetBucketQuota(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
printEndFunc("TestGetBucketQuota")
|
||||
|
||||
}
|
||||
|
||||
func TestPutBucketQuota(t *testing.T) {
|
||||
printStartFunc("TestPutBucketQuota")
|
||||
|
||||
// Variables
|
||||
assert := assert.New(t)
|
||||
validBucket := "testputbucketquota"
|
||||
@@ -882,11 +882,11 @@ func TestPutBucketQuota(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
printEndFunc("TestPutBucketQuota")
|
||||
|
||||
}
|
||||
|
||||
func TestListBucketEvents(t *testing.T) {
|
||||
printStartFunc("TestListBucketEvents")
|
||||
|
||||
// Variables
|
||||
assert := assert.New(t)
|
||||
validBucket := "testlistbucketevents"
|
||||
@@ -942,11 +942,11 @@ func TestListBucketEvents(t *testing.T) {
|
||||
|
||||
})
|
||||
}
|
||||
printEndFunc("TestListBucketEvents")
|
||||
|
||||
}
|
||||
|
||||
func TestDeleteObjectsRetentionStatus(t *testing.T) {
|
||||
printStartFunc("TestDeleteObjectsRetentionStatus")
|
||||
|
||||
// Variables
|
||||
assert := assert.New(t)
|
||||
bucketName := "testdeleteobjectslegalholdstatus"
|
||||
@@ -1053,11 +1053,11 @@ func TestDeleteObjectsRetentionStatus(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
printEndFunc("TestDeleteObjectsRetentionStatus")
|
||||
|
||||
}
|
||||
|
||||
func TestBucketSetPolicy(t *testing.T) {
|
||||
printStartFunc("TestBucketSetPolicy")
|
||||
|
||||
// Variables
|
||||
assert := assert.New(t)
|
||||
validBucketName := "testbucketsetpolicy"
|
||||
@@ -1116,11 +1116,11 @@ func TestBucketSetPolicy(t *testing.T) {
|
||||
|
||||
})
|
||||
}
|
||||
printEndFunc("TestBucketSetPolicy")
|
||||
|
||||
}
|
||||
|
||||
func TestRestoreObjectToASelectedVersion(t *testing.T) {
|
||||
printStartFunc("TestRestoreObjectToASelectedVersion")
|
||||
|
||||
// Variables
|
||||
assert := assert.New(t)
|
||||
bucketName := "testrestoreobjectstoselectedversion"
|
||||
@@ -1208,11 +1208,11 @@ func TestRestoreObjectToASelectedVersion(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
printEndFunc("TestRestoreObjectToASelectedVersion")
|
||||
|
||||
}
|
||||
|
||||
func TestPutBucketsTags(t *testing.T) {
|
||||
printStartFunc("TestPutBucketsTags")
|
||||
|
||||
// Focused test for "Put Bucket's tags" endpoint
|
||||
|
||||
// 1. Create the bucket
|
||||
@@ -1266,11 +1266,11 @@ func TestPutBucketsTags(t *testing.T) {
|
||||
|
||||
})
|
||||
}
|
||||
printEndFunc("TestPutBucketsTags")
|
||||
|
||||
}
|
||||
|
||||
func TestGetsTheMetadataOfAnObject(t *testing.T) {
|
||||
printStartFunc("TestGetsTheMetadataOfAnObject")
|
||||
|
||||
// Vars
|
||||
assert := assert.New(t)
|
||||
bucketName := "testgetsthemetadataofanobject"
|
||||
@@ -1343,11 +1343,11 @@ func TestGetsTheMetadataOfAnObject(t *testing.T) {
|
||||
|
||||
})
|
||||
}
|
||||
printEndFunc("TestGetsTheMetadataOfAnObject")
|
||||
|
||||
}
|
||||
|
||||
func TestPutObjectsRetentionStatus(t *testing.T) {
|
||||
printStartFunc("TestPutObjectsRetentionStatus")
|
||||
|
||||
// Variables
|
||||
assert := assert.New(t)
|
||||
bucketName := "testputobjectsretentionstatus"
|
||||
@@ -1436,14 +1436,14 @@ func TestPutObjectsRetentionStatus(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
printEndFunc("TestPutObjectsRetentionStatus")
|
||||
|
||||
}
|
||||
|
||||
func TestShareObjectOnURL(t *testing.T) {
|
||||
/*
|
||||
Test to share an object via URL
|
||||
*/
|
||||
printStartFunc("TestShareObjectOnURL")
|
||||
|
||||
// Vars
|
||||
assert := assert.New(t)
|
||||
bucketName := "testshareobjectonurl"
|
||||
@@ -1517,14 +1517,14 @@ func TestShareObjectOnURL(t *testing.T) {
|
||||
|
||||
})
|
||||
}
|
||||
printEndFunc("TestShareObjectOnURL")
|
||||
|
||||
}
|
||||
|
||||
func TestListObjects(t *testing.T) {
|
||||
/*
|
||||
To test list objects end point.
|
||||
*/
|
||||
printStartFunc("TestListObjects")
|
||||
|
||||
// Test's variables
|
||||
assert := assert.New(t)
|
||||
bucketName := "testlistobjecttobucket1"
|
||||
@@ -1564,14 +1564,14 @@ func TestListObjects(t *testing.T) {
|
||||
assert.True(
|
||||
strings.Contains(finalResponse, "testlistobjecttobucket1"),
|
||||
finalResponse)
|
||||
printEndFunc("TestListObjects")
|
||||
|
||||
}
|
||||
|
||||
func TestDeleteObject(t *testing.T) {
|
||||
/*
|
||||
Test to delete an object from a given bucket.
|
||||
*/
|
||||
printStartFunc("TestDeleteObject")
|
||||
|
||||
// Variables
|
||||
assert := assert.New(t)
|
||||
bucketName := "testdeleteobjectbucket1"
|
||||
@@ -1633,14 +1633,14 @@ func TestDeleteObject(t *testing.T) {
|
||||
strings.Contains(
|
||||
finalResponse,
|
||||
"testdeleteobjectfile1.txt"), finalResponse) // Gone
|
||||
printEndFunc("TestDeleteObject")
|
||||
|
||||
}
|
||||
|
||||
func TestUploadObjectToBucket(t *testing.T) {
|
||||
/*
|
||||
Function to test the upload of an object to a bucket.
|
||||
*/
|
||||
printStartFunc("TestUploadObjectToBucket")
|
||||
|
||||
// Test's variables
|
||||
assert := assert.New(t)
|
||||
bucketName := "testuploadobjecttobucket1"
|
||||
@@ -1664,14 +1664,14 @@ func TestUploadObjectToBucket(t *testing.T) {
|
||||
if uploadResponse != nil {
|
||||
assert.Equal(200, uploadResponse.StatusCode, finalResponse)
|
||||
}
|
||||
printEndFunc("TestUploadObjectToBucket")
|
||||
|
||||
}
|
||||
|
||||
func TestDownloadObject(t *testing.T) {
|
||||
/*
|
||||
Test to download an object from a given bucket.
|
||||
*/
|
||||
printStartFunc("TestDownloadObject")
|
||||
|
||||
// Vars
|
||||
assert := assert.New(t)
|
||||
bucketName := "testdownloadobjbucketone"
|
||||
@@ -1731,14 +1731,14 @@ func TestDownloadObject(t *testing.T) {
|
||||
// path/to/whatever does not exist
|
||||
assert.Fail("File wasn't downloaded")
|
||||
}
|
||||
printEndFunc("TestDownloadObject")
|
||||
|
||||
}
|
||||
|
||||
func TestDeleteMultipleObjects(t *testing.T) {
|
||||
/*
|
||||
Function to test the deletion of multiple objects from a given bucket.
|
||||
*/
|
||||
printStartFunc("TestDeleteMultipleObjects")
|
||||
|
||||
// Variables
|
||||
assert := assert.New(t)
|
||||
bucketName := "testdeletemultipleobjsbucket1"
|
||||
@@ -1806,14 +1806,14 @@ func TestDeleteMultipleObjects(t *testing.T) {
|
||||
// 5. Verify empty list is obtained as we deleted all the objects
|
||||
expected := "Http Response: {\"objects\":null}\n"
|
||||
assert.Equal(expected, finalResponse, finalResponse)
|
||||
printEndFunc("TestDeleteMultipleObjects")
|
||||
|
||||
}
|
||||
|
||||
func TestPutObjectTag(t *testing.T) {
|
||||
/*
|
||||
Test to put a tag to an object
|
||||
*/
|
||||
printStartFunc("TestPutObjectTag")
|
||||
|
||||
// Vars
|
||||
assert := assert.New(t)
|
||||
bucketName := "testputobjecttagbucketone"
|
||||
@@ -1872,14 +1872,14 @@ func TestPutObjectTag(t *testing.T) {
|
||||
assert.True(
|
||||
strings.Contains(finalResponse, tags["tag"]),
|
||||
finalResponse)
|
||||
printEndFunc("TestPutObjectTag")
|
||||
|
||||
}
|
||||
|
||||
func TestBucketRetention(t *testing.T) {
|
||||
/*
|
||||
To test bucket retention feature
|
||||
*/
|
||||
printStartFunc("TestBucketRetention")
|
||||
|
||||
// 1. Create the bucket with 2 years validity retention
|
||||
assert := assert.New(t)
|
||||
/*
|
||||
@@ -1941,14 +1941,14 @@ func TestBucketRetention(t *testing.T) {
|
||||
}
|
||||
expected := "Http Response: {\"mode\":\"compliance\",\"unit\":\"years\",\"validity\":3}\n"
|
||||
assert.Equal(expected, finalResponse, finalResponse)
|
||||
printEndFunc("TestBucketRetention")
|
||||
|
||||
}
|
||||
|
||||
func TestBucketInformationGenericErrorResponse(t *testing.T) {
|
||||
/*
|
||||
Test Bucket Info End Point with a Generic Error Response.
|
||||
*/
|
||||
printStartFunc("TestBucketInformationGenericErrorResponse")
|
||||
|
||||
// 1. Create the bucket
|
||||
assert := assert.New(t)
|
||||
if !BucketGotAdded("bucketinformation2", false, false, nil, nil, assert, 201) {
|
||||
@@ -1987,14 +1987,14 @@ func TestBucketInformationGenericErrorResponse(t *testing.T) {
|
||||
// Since bucketinformation3 hasn't been created, then it is expected that
|
||||
// tag2 is not part of the response, this is why assert.False is used.
|
||||
assert.False(strings.Contains(finalResponse, "tag2"), finalResponse)
|
||||
printEndFunc("TestBucketInformationGenericErrorResponse")
|
||||
|
||||
}
|
||||
|
||||
func TestBucketInformationSuccessfulResponse(t *testing.T) {
|
||||
/*
|
||||
Test Bucket Info End Point with a Successful Response.
|
||||
*/
|
||||
printStartFunc("TestBucketInformationSuccessfulResponse")
|
||||
|
||||
// 1. Create the bucket
|
||||
assert := assert.New(t)
|
||||
if !BucketGotAdded("bucketinformation1", false, false, nil, nil, assert, 201) {
|
||||
@@ -2029,7 +2029,7 @@ func TestBucketInformationSuccessfulResponse(t *testing.T) {
|
||||
assert.Equal(200, bucketInfoResponse.StatusCode,
|
||||
debugResponse)
|
||||
}
|
||||
printMessage(debugResponse)
|
||||
fmt.Println(debugResponse)
|
||||
|
||||
// 4. Verify the information
|
||||
assert.True(
|
||||
@@ -2038,14 +2038,14 @@ func TestBucketInformationSuccessfulResponse(t *testing.T) {
|
||||
assert.True(
|
||||
strings.Contains(debugResponse, "tag1"),
|
||||
inspectHTTPResponse(bucketInfoResponse))
|
||||
printEndFunc("TestBucketInformationSuccessfulResponse")
|
||||
|
||||
}
|
||||
|
||||
func TestDeleteBucket(t *testing.T) {
|
||||
/*
|
||||
Test to delete a bucket
|
||||
*/
|
||||
printStartFunc("TestDeleteBucket")
|
||||
|
||||
// 1. Create the bucket
|
||||
assert := assert.New(t)
|
||||
if !BucketGotAdded("testdeletebucket1", false, false, nil, nil, assert, 201) {
|
||||
@@ -2082,14 +2082,14 @@ func TestDeleteBucket(t *testing.T) {
|
||||
}
|
||||
assert.True(
|
||||
strings.Contains(finalResponse, "The specified bucket does not exist"))
|
||||
printEndFunc("TestDeleteBucket")
|
||||
|
||||
}
|
||||
|
||||
func TestListBuckets(t *testing.T) {
|
||||
/*
|
||||
Test the list of buckets without query parameters.
|
||||
*/
|
||||
printStartFunc("TestListBuckets")
|
||||
|
||||
assert := assert.New(t)
|
||||
|
||||
// 1. Create buckets
|
||||
@@ -2122,11 +2122,11 @@ func TestListBuckets(t *testing.T) {
|
||||
assert.True(strings.Contains(string(b),
|
||||
"testlistbuckets"+strconv.Itoa(i)))
|
||||
}
|
||||
printEndFunc("TestListBuckets")
|
||||
|
||||
}
|
||||
|
||||
func TestBucketsGet(t *testing.T) {
|
||||
printStartFunc("TestListBuckets")
|
||||
|
||||
assert := assert.New(t)
|
||||
|
||||
client := &http.Client{
|
||||
@@ -2164,11 +2164,11 @@ func TestBucketsGet(t *testing.T) {
|
||||
assert.Greater(listBuckets.Total, int64(0), "Total buckets is 0")
|
||||
|
||||
}
|
||||
printEndFunc("TestListBuckets")
|
||||
|
||||
}
|
||||
|
||||
func TestBucketVersioning(t *testing.T) {
|
||||
printStartFunc("TestBucketVersioning")
|
||||
|
||||
assert := assert.New(t)
|
||||
|
||||
client := &http.Client{
|
||||
@@ -2268,11 +2268,11 @@ func TestBucketVersioning(t *testing.T) {
|
||||
if response != nil {
|
||||
fmt.Println("DELETE StatusCode:", response.StatusCode)
|
||||
}
|
||||
printEndFunc("TestBucketVersioning")
|
||||
|
||||
}
|
||||
|
||||
func TestSetBucketTags(t *testing.T) {
|
||||
printStartFunc("TestSetBucketTags")
|
||||
|
||||
assert := assert.New(t)
|
||||
|
||||
client := &http.Client{
|
||||
@@ -2338,11 +2338,11 @@ func TestSetBucketTags(t *testing.T) {
|
||||
}
|
||||
|
||||
assert.Equal("TAG", bucket.Details.Tags["test"], "Failed to add tag")
|
||||
printEndFunc("TestSetBucketTags")
|
||||
|
||||
}
|
||||
|
||||
func TestGetBucket(t *testing.T) {
|
||||
printStartFunc("TestGetBucket")
|
||||
|
||||
assert := assert.New(t)
|
||||
|
||||
client := &http.Client{
|
||||
@@ -2373,11 +2373,11 @@ func TestGetBucket(t *testing.T) {
|
||||
if response != nil {
|
||||
assert.Equal(200, response.StatusCode, "Status Code is incorrect")
|
||||
}
|
||||
printEndFunc("TestGetBucket")
|
||||
|
||||
}
|
||||
|
||||
func TestAddBucket(t *testing.T) {
|
||||
printStartFunc("TestAddBucket")
|
||||
|
||||
assert := assert.New(t)
|
||||
type args struct {
|
||||
bucketName string
|
||||
@@ -2409,7 +2409,7 @@ func TestAddBucket(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
printEndFunc("TestAddBucket")
|
||||
|
||||
}
|
||||
|
||||
func CreateBucketEvent(bucketName string, ignoreExisting bool, arn string, prefix string, suffix string, events []string) (*http.Response, error) {
|
||||
@@ -2491,7 +2491,7 @@ func DeleteBucketEvent(bucketName string, arn string, events []string, prefix st
|
||||
}
|
||||
|
||||
func TestDeleteBucketEvent(t *testing.T) {
|
||||
printStartFunc("TestDeleteBucketEvent")
|
||||
|
||||
// Variables
|
||||
assert := assert.New(t)
|
||||
|
||||
@@ -2571,7 +2571,7 @@ func TestDeleteBucketEvent(t *testing.T) {
|
||||
efinalResponseEvent,
|
||||
)
|
||||
}
|
||||
printEndFunc("TestDeleteBucketEvent")
|
||||
|
||||
}
|
||||
|
||||
func SetMultiBucketReplication(accessKey string, secretKey string, targetURL string, region string, originBucket string, destinationBucket string, syncMode string, bandwidth int, healthCheckPeriod int, prefix string, tags string, replicateDeleteMarkers bool, replicateDeletes bool, priority int, storageClass string, replicateMetadata bool) (*http.Response, error) {
|
||||
@@ -2712,7 +2712,7 @@ func DeleteBucketReplicationRule(bucketName string, ruleID string) (*http.Respon
|
||||
}
|
||||
|
||||
func TestReplication(t *testing.T) {
|
||||
printStartFunc("TestReplication")
|
||||
|
||||
// Vars
|
||||
assert := assert.New(t)
|
||||
originBucket := "testputobjectslegalholdstatus"
|
||||
@@ -2770,6 +2770,10 @@ func TestReplication(t *testing.T) {
|
||||
assert.Nil(err)
|
||||
}
|
||||
|
||||
assert.Greater(len(structBucketRepl.Rules), 0, "Number of expected rules is 0")
|
||||
if len(structBucketRepl.Rules) == 0 {
|
||||
return
|
||||
}
|
||||
// 4. Verify rules are enabled
|
||||
for index := 0; index < 2; index++ {
|
||||
Status := structBucketRepl.Rules[index].Status
|
||||
@@ -2807,7 +2811,7 @@ func TestReplication(t *testing.T) {
|
||||
if response != nil {
|
||||
assert.Equal(204, response.StatusCode, finalResponse)
|
||||
}
|
||||
printEndFunc("TestReplication")
|
||||
|
||||
}
|
||||
|
||||
func GetBucketVersioning(bucketName string) (*http.Response, error) {
|
||||
@@ -2846,7 +2850,7 @@ func BaseGetFunction(bucketName string, endPoint string) (*http.Response, error)
|
||||
|
||||
func TestReturnsTheStatusOfObjectLockingSupportOnTheBucket(t *testing.T) {
|
||||
// Test for end point: /buckets/{bucket_name}/object-locking
|
||||
printStartFunc("TestReturnsTheStatusOfObjectLockingSupportOnTheBucket")
|
||||
|
||||
// Vars
|
||||
assert := assert.New(t)
|
||||
bucketName := "testputobjectslegalholdstatus"
|
||||
@@ -2877,7 +2881,7 @@ func TestReturnsTheStatusOfObjectLockingSupportOnTheBucket(t *testing.T) {
|
||||
true,
|
||||
structBucketLocking,
|
||||
)
|
||||
printEndFunc("TestReturnsTheStatusOfObjectLockingSupportOnTheBucket")
|
||||
|
||||
}
|
||||
|
||||
func SetBucketVersioning(bucketName string, versioning bool) (*http.Response, error) {
|
||||
@@ -2905,7 +2909,7 @@ func SetBucketVersioning(bucketName string, versioning bool) (*http.Response, er
|
||||
}
|
||||
|
||||
func TestSetBucketVersioning(t *testing.T) {
|
||||
printStartFunc("TestSetBucketVersioning")
|
||||
|
||||
// Variables
|
||||
assert := assert.New(t)
|
||||
bucket := "test-set-bucket-versioning"
|
||||
@@ -2948,7 +2952,7 @@ func TestSetBucketVersioning(t *testing.T) {
|
||||
assert.Nil(err)
|
||||
}
|
||||
assert.Equal(false, result.IsVersioned, result)
|
||||
printEndFunc("TestSetBucketVersioning")
|
||||
|
||||
}
|
||||
|
||||
func EnableBucketEncryption(bucketName string, encType string, kmsKeyID string) (*http.Response, error) {
|
||||
@@ -2985,7 +2989,7 @@ func EnableBucketEncryption(bucketName string, encType string, kmsKeyID string)
|
||||
}
|
||||
|
||||
func TestEnableBucketEncryption(t *testing.T) {
|
||||
printStartFunc("TestEnableBucketEncryption")
|
||||
|
||||
// Variables
|
||||
assert := assert.New(t)
|
||||
bucketName := "test-enable-bucket-encryption"
|
||||
@@ -3030,7 +3034,6 @@ func TestEnableBucketEncryption(t *testing.T) {
|
||||
assert.Nil(err)
|
||||
}
|
||||
assert.Equal("AES256", result.Algorithm, result)
|
||||
printEndFunc("TestEnableBucketEncryption")
|
||||
|
||||
// 4. Disable Bucket's Encryption
|
||||
resp, err = DisableBucketEncryption(bucketName)
|
||||
@@ -3064,7 +3067,7 @@ func TestEnableBucketEncryption(t *testing.T) {
|
||||
}
|
||||
dereferencedPointerDetailedMessage := *result2.DetailedMessage
|
||||
assert.Equal("error server side encryption configuration not found", dereferencedPointerDetailedMessage, dereferencedPointerDetailedMessage)
|
||||
printEndFunc("TestEnableBucketEncryption")
|
||||
|
||||
}
|
||||
|
||||
func GetBucketEncryptionInformation(bucketName string) (*http.Response, error) {
|
||||
@@ -3259,8 +3262,6 @@ func DeleteLifecycleRule(bucketName string, lifecycleID string) (*http.Response,
|
||||
|
||||
func TestBucketLifeCycle(t *testing.T) {
|
||||
|
||||
printStartFunc("TestBucketLifeCycle")
|
||||
|
||||
// Variables
|
||||
assert := assert.New(t)
|
||||
bucketName := "test-bucket-life-cycle"
|
||||
@@ -3391,7 +3392,6 @@ func TestBucketLifeCycle(t *testing.T) {
|
||||
404, resp.StatusCode, "Status Code is incorrect")
|
||||
}
|
||||
|
||||
printEndFunc("TestBucketLifeCycle")
|
||||
}
|
||||
|
||||
func SetAccessRuleWithBucket(bucketName string, prefix string, access string) (*http.Response, error) {
|
||||
@@ -3480,8 +3480,6 @@ func DeleteAccessRuleWithBucket(bucketName string, prefix string) (*http.Respons
|
||||
|
||||
func TestAccessRule(t *testing.T) {
|
||||
|
||||
printStartFunc("TestAccessRule")
|
||||
|
||||
// Variables
|
||||
assert := assert.New(t)
|
||||
bucketName := "test-access-rule-bucket"
|
||||
@@ -3569,10 +3567,9 @@ func TestAccessRule(t *testing.T) {
|
||||
}
|
||||
AccessRules := &result.AccessRules // The array has to be empty, no index accessible
|
||||
if len(*AccessRules) == 0 {
|
||||
printMessage("Cool, access rules are gone from this bucket")
|
||||
fmt.Println("Cool, access rules are gone from this bucket")
|
||||
} else {
|
||||
assert.Fail("Access Rule not deleted")
|
||||
}
|
||||
|
||||
printEndFunc("TestAccessRule")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user