MCPcopy
hub / github.com/minio/minio-go / testPresignedPostPolicyEmptyFileName

Function testPresignedPostPolicyEmptyFileName

functional_tests.go:6018–6170  ·  view source on GitHub ↗

testPresignedPostPolicyEmptyFileName tests that an empty file name in the presigned post policy

()

Source from the content-addressed store, hash-verified

6016
6017// testPresignedPostPolicyEmptyFileName tests that an empty file name in the presigned post policy
6018func testPresignedPostPolicyEmptyFileName() {
6019 // initialize logging params
6020 startTime := time.Now()
6021 testName := getFuncName()
6022 function := "PresignedPostPolicy(policy)"
6023 args := map[string]interface{}{
6024 "policy": "",
6025 }
6026
6027 c, err := NewClient(ClientConfig{})
6028 if err != nil {
6029 logError(testName, function, args, startTime, "", "MinIO client object creation failed", err)
6030 return
6031 }
6032
6033 // Generate a new random bucket name.
6034 bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test-")
6035
6036 // Make a new bucket in 'us-east-1' (source bucket).
6037 err = c.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{Region: "us-east-1"})
6038 if err != nil {
6039 logError(testName, function, args, startTime, "", "MakeBucket failed", err)
6040 return
6041 }
6042
6043 defer cleanupBucket(bucketName, c)
6044
6045 // Generate 33K of data.
6046 reader := getDataReader("datafile-33-kB")
6047 defer reader.Close()
6048
6049 objectName := randString(60, rand.NewSource(time.Now().UnixNano()), "")
6050 // Azure requires the key to not start with a number
6051 metadataKey := randString(60, rand.NewSource(time.Now().UnixNano()), "user")
6052 metadataValue := randString(60, rand.NewSource(time.Now().UnixNano()), "")
6053
6054 buf, err := io.ReadAll(reader)
6055 if err != nil {
6056 logError(testName, function, args, startTime, "", "ReadAll failed", err)
6057 return
6058 }
6059
6060 policy := minio.NewPostPolicy()
6061 policy.SetBucket(bucketName)
6062 policy.SetKey(objectName)
6063 policy.SetExpires(time.Now().UTC().AddDate(0, 0, 10)) // expires in 10 days
6064 policy.SetContentType("binary/octet-stream")
6065 policy.SetContentLengthRange(10, 1024*1024)
6066 policy.SetUserMetadata(metadataKey, metadataValue)
6067 policy.SetContentEncoding("gzip")
6068
6069 // Add CRC32C
6070 checksum := minio.ChecksumCRC32C.ChecksumBytes(buf)
6071 err = policy.SetChecksum(checksum)
6072 if err != nil {
6073 logError(testName, function, args, startTime, "", "SetChecksum failed", err)
6074 return
6075 }

Callers 1

mainFunction · 0.85

Calls 15

MakeBucketMethod · 0.95
SetBucketMethod · 0.95
SetKeyMethod · 0.95
SetExpiresMethod · 0.95
SetContentTypeMethod · 0.95
SetContentLengthRangeMethod · 0.95
SetUserMetadataMethod · 0.95
SetContentEncodingMethod · 0.95
SetChecksumMethod · 0.95
StringMethod · 0.95
PresignedPostPolicyMethod · 0.95
getFuncNameFunction · 0.85

Tested by

no test coverage detected