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

Function testPresignedPostPolicyEmptyFileName

functional_tests.go:6122–6274  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

6120
6121// testPresignedPostPolicyEmptyFileName tests that an empty file name in the presigned post policy
6122func testPresignedPostPolicyEmptyFileName() {
6123 // initialize logging params
6124 startTime := time.Now()
6125 testName := getFuncName()
6126 function := "PresignedPostPolicy(policy)"
6127 args := map[string]interface{}{
6128 "policy": "",
6129 }
6130
6131 c, err := NewClient(ClientConfig{})
6132 if err != nil {
6133 logError(testName, function, args, startTime, "", "MinIO client object creation failed", err)
6134 return
6135 }
6136
6137 // Generate a new random bucket name.
6138 bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test-")
6139
6140 // Make a new bucket in 'us-east-1' (source bucket).
6141 err = c.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{Region: "us-east-1"})
6142 if err != nil {
6143 logError(testName, function, args, startTime, "", "MakeBucket failed", err)
6144 return
6145 }
6146
6147 defer cleanupBucket(bucketName, c)
6148
6149 // Generate 33K of data.
6150 reader := getDataReader("datafile-33-kB")
6151 defer reader.Close()
6152
6153 objectName := randString(60, rand.NewSource(time.Now().UnixNano()), "")
6154 // Azure requires the key to not start with a number
6155 metadataKey := randString(60, rand.NewSource(time.Now().UnixNano()), "user")
6156 metadataValue := randString(60, rand.NewSource(time.Now().UnixNano()), "")
6157
6158 buf, err := io.ReadAll(reader)
6159 if err != nil {
6160 logError(testName, function, args, startTime, "", "ReadAll failed", err)
6161 return
6162 }
6163
6164 policy := minio.NewPostPolicy()
6165 policy.SetBucket(bucketName)
6166 policy.SetKey(objectName)
6167 policy.SetExpires(time.Now().UTC().AddDate(0, 0, 10)) // expires in 10 days
6168 policy.SetContentType("binary/octet-stream")
6169 policy.SetContentLengthRange(10, 1024*1024)
6170 policy.SetUserMetadata(metadataKey, metadataValue)
6171 policy.SetContentEncoding("gzip")
6172
6173 // Add CRC32C
6174 checksum := minio.ChecksumCRC32C.ChecksumBytes(buf)
6175 err = policy.SetChecksum(checksum)
6176 if err != nil {
6177 logError(testName, function, args, startTime, "", "SetChecksum failed", err)
6178 return
6179 }

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