mirror of
https://github.com/minio/minio.git
synced 2025-01-26 06:03:17 -05:00
Mint - Add AWS SDK Go tests (#12097)
* Add aws-sdk-go tests: extend testListObjectVersionsSimple with error cases * Add aws-sdk-go tests: extend testListMultipartUploads with error cases Co-authored-by: Andre Bruch <ab@andrebruch.com> Signed-off-by: Harshavardhana <harsha@minio.io>
This commit is contained in:
parent
445d080826
commit
046e8fd17e
@ -27,6 +27,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
|
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||||
|
"github.com/aws/aws-sdk-go/aws/session"
|
||||||
"github.com/aws/aws-sdk-go/service/s3"
|
"github.com/aws/aws-sdk-go/service/s3"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -177,6 +179,45 @@ func testListObjectVersionsSimple() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Error cases
|
||||||
|
|
||||||
|
// bucket-listobjects-handlers.go > ListObjectVersionsHandler > listObjectVersions
|
||||||
|
lovInput := &s3.ListObjectVersionsInput{
|
||||||
|
Bucket: aws.String(bucket),
|
||||||
|
VersionIdMarker: aws.String("test"),
|
||||||
|
}
|
||||||
|
result, err = s3Client.ListObjectVersions(lovInput)
|
||||||
|
if err == nil {
|
||||||
|
failureLog(function, args, startTime, "", fmt.Sprintf("ListObjectVersions expected to fail but got %v", err), err).Fatal()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// bucket-listobjects-handlers.go > ListObjectVersionsHandler > validateListObjectsArgs
|
||||||
|
lovInput.EncodingType = aws.String("test")
|
||||||
|
result, err = s3Client.ListObjectVersions(lovInput)
|
||||||
|
if err == nil {
|
||||||
|
failureLog(function, args, startTime, "", fmt.Sprintf("ListObjectVersions expected to fail but got %v", err), err).Fatal()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Second client
|
||||||
|
creds := credentials.NewStaticCredentials("test", "test", "")
|
||||||
|
newSession, err := session.NewSession()
|
||||||
|
if err != nil {
|
||||||
|
failureLog(function, args, startTime, "", fmt.Sprintf("NewSession expected to succeed but got %v", err), err).Fatal()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
s3Config := s3Client.Config
|
||||||
|
s3Config.Credentials = creds
|
||||||
|
s3ClientTest := s3.New(newSession, &s3Config)
|
||||||
|
|
||||||
|
// Check with a second client: bucket-listobjects-handlers.go > ListObjectVersionsHandler > checkRequestAuthType
|
||||||
|
result, err = s3ClientTest.ListObjectVersions(lovInput)
|
||||||
|
if err == nil {
|
||||||
|
failureLog(function, args, startTime, "", fmt.Sprintf("ListObjectVersions expected to fail but got %v", err), err).Fatal()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
successLogger(function, args, startTime).Info()
|
successLogger(function, args, startTime).Info()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -951,6 +951,29 @@ func testListMultipartUploads(s3Client *s3.S3) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Error cases
|
||||||
|
|
||||||
|
// MaxParts < 0
|
||||||
|
lpInput := &s3.ListPartsInput{
|
||||||
|
Bucket: aws.String(bucket),
|
||||||
|
Key: aws.String(object),
|
||||||
|
UploadId: multipartUpload.UploadId,
|
||||||
|
MaxParts: aws.Int64(-1),
|
||||||
|
}
|
||||||
|
listParts, err = s3Client.ListParts(lpInput)
|
||||||
|
if err == nil {
|
||||||
|
failureLog(function, args, startTime, "", "AWS SDK Go ListPartsInput API (MaxParts < 0) failed for", err).Fatal()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// PartNumberMarker < 0
|
||||||
|
lpInput.PartNumberMarker = aws.Int64(-1)
|
||||||
|
listParts, err = s3Client.ListParts(lpInput)
|
||||||
|
if err == nil {
|
||||||
|
failureLog(function, args, startTime, "", "AWS SDK Go ListPartsInput API (PartNumberMarker < 0) failed for", err).Fatal()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
successLogger(function, args, startTime).Info()
|
successLogger(function, args, startTime).Info()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user