@@ -21,6 +21,7 @@ package integration
21
21
import (
22
22
"bytes"
23
23
"context"
24
+ "encoding/base64"
24
25
"encoding/json"
25
26
"errors"
26
27
"fmt"
@@ -395,9 +396,10 @@ func UploadAnObject(bucketName, fileName string) (*http.Response, error) {
395
396
contentType + boundaryEnd
396
397
arrayOfBytes := []byte (file )
397
398
requestDataBody := bytes .NewReader (arrayOfBytes )
399
+ apiURL := "http://localhost:9090/api/v1/buckets/" + bucketName + "/objects/upload" + "?prefix=" + base64 .StdEncoding .EncodeToString ([]byte (fileName ))
398
400
request , err := http .NewRequest (
399
401
"POST" ,
400
- "http://localhost:9090/api/v1/buckets/" + bucketName + "/objects/upload" ,
402
+ apiURL ,
401
403
requestDataBody ,
402
404
)
403
405
if err != nil {
@@ -488,9 +490,11 @@ func PutObjectsRetentionStatus(bucketName, prefix, versionID, mode, expires stri
488
490
}
489
491
requestDataJSON , _ := json .Marshal (requestDataAdd )
490
492
requestDataBody := bytes .NewReader (requestDataJSON )
493
+ apiURL := "http://localhost:9090/api/v1/buckets/" + bucketName + "/objects/retention?prefix=" + prefix + "&version_id=" + versionID
494
+
491
495
request , err := http .NewRequest (
492
496
"PUT" ,
493
- "http://localhost:9090/api/v1/buckets/" + bucketName + "/objects/retention?prefix=" + prefix + "&version_id=" + versionID ,
497
+ apiURL ,
494
498
requestDataBody ,
495
499
)
496
500
if err != nil {
@@ -726,9 +730,10 @@ func PutObjectsLegalholdStatus(bucketName, prefix, status, versionID string) (*h
726
730
}
727
731
requestDataJSON , _ := json .Marshal (requestDataAdd )
728
732
requestDataBody := bytes .NewReader (requestDataJSON )
733
+ apiURL := "http://localhost:9090/api/v1/buckets/" + bucketName + "/objects/legalhold?prefix=" + prefix + "&version_id=" + versionID
729
734
request , err := http .NewRequest (
730
735
"PUT" ,
731
- "http://localhost:9090/api/v1/buckets/" + bucketName + "/objects/legalhold?prefix=" + prefix + "&version_id=" + versionID ,
736
+ apiURL ,
732
737
requestDataBody ,
733
738
)
734
739
if err != nil {
@@ -747,8 +752,8 @@ func TestPutObjectsLegalholdStatus(t *testing.T) {
747
752
// Variables
748
753
assert := assert .New (t )
749
754
bucketName := "testputobjectslegalholdstatus"
750
- fileName := "testputobjectslegalholdstatus.txt"
751
- prefix := "dGVzdHB1dG9iamVjdHNsZWdhbGhvbGRzdGF0dXMudHh0" // encoded base64
755
+ objName := "testputobjectslegalholdstatus.txt" // // encoded base64 of testputobjectslegalholdstatus.txt = dGVzdHB1dG9iamVjdHNsZWdhbGhvbGRzdGF0dXMudHh0
756
+ objectNameEncoded := "dGVzdHB1dG9iamVjdHNsZWdhbGhvbGRzdGF0dXMudHh0"
752
757
status := "enabled"
753
758
754
759
// 1. Create bucket
@@ -759,7 +764,7 @@ func TestPutObjectsLegalholdStatus(t *testing.T) {
759
764
// 2. Add object
760
765
uploadResponse , uploadError := UploadAnObject (
761
766
bucketName ,
762
- fileName ,
767
+ objName ,
763
768
)
764
769
assert .Nil (uploadError )
765
770
if uploadError != nil {
@@ -776,7 +781,7 @@ func TestPutObjectsLegalholdStatus(t *testing.T) {
776
781
}
777
782
778
783
// Get versionID
779
- listResponse , _ := ListObjects (bucketName , prefix , "true" )
784
+ listResponse , _ := ListObjects (bucketName , "" , "true" )
780
785
bodyBytes , _ := io .ReadAll (listResponse .Body )
781
786
listObjs := models.ListObjectsResponse {}
782
787
err := json .Unmarshal (bodyBytes , & listObjs )
@@ -814,7 +819,7 @@ func TestPutObjectsLegalholdStatus(t *testing.T) {
814
819
// 3. Put Objects Legal Status
815
820
putResponse , putError := PutObjectsLegalholdStatus (
816
821
bucketName ,
817
- prefix ,
822
+ objectNameEncoded ,
818
823
status ,
819
824
tt .args .versionID ,
820
825
)
0 commit comments