@@ -461,24 +461,12 @@ func ListObjects(bucketName, prefix, withVersions string) (*http.Response, error
461
461
return response , err
462
462
}
463
463
464
- func SharesAnObjectOnAUrl (bucketName , prefix , versionID , expires , accessKey , secretKey string ) (* http.Response , error ) {
465
- // Helper function to share an object on an url
466
-
467
- requestDataAdd := map [string ]interface {}{
468
- "prefix" : prefix ,
469
- "version_id" : versionID ,
470
- "expires" : expires ,
471
- "access_key" : accessKey ,
472
- "secret_key" : secretKey ,
473
- }
474
-
475
- requestDataJSON , _ := json .Marshal (requestDataAdd )
476
- requestDataBody := bytes .NewReader (requestDataJSON )
477
-
464
+ func SharesAnObjectOnAUrl (bucketName , prefix , versionID , expires string ) (* http.Response , error ) {
465
+ // Helper function to share an object on a url
478
466
request , err := http .NewRequest (
479
- "POST " ,
480
- "http://localhost:9090/api/v1/buckets/" + bucketName + "/objects/share" ,
481
- requestDataBody ,
467
+ "GET " ,
468
+ "http://localhost:9090/api/v1/buckets/" + bucketName + "/objects/share?prefix=" + prefix + "&version_id=" + versionID + "&expires=" + expires ,
469
+ nil ,
482
470
)
483
471
if err != nil {
484
472
log .Println (err )
@@ -755,39 +743,6 @@ func PutObjectsLegalholdStatus(bucketName, prefix, status, versionID string) (*h
755
743
return response , err
756
744
}
757
745
758
- func PostServiceAccountCredentials (accessKey , secretKey , policy string ) (* http.Response , error ) {
759
- /*
760
- Helper function to create a service account
761
- POST: {{baseUrl}}/service-account-credentials
762
- {
763
- "accessKey":"testsa",
764
- "secretKey":"secretsa",
765
- "policy":""
766
- }
767
- */
768
- requestDataAdd := map [string ]interface {}{
769
- "accessKey" : accessKey ,
770
- "secretKey" : secretKey ,
771
- "policy" : policy ,
772
- }
773
- requestDataJSON , _ := json .Marshal (requestDataAdd )
774
- requestDataBody := bytes .NewReader (requestDataJSON )
775
-
776
- request , err := http .NewRequest ("POST" ,
777
- "http://localhost:9090/api/v1/service-account-credentials" ,
778
- requestDataBody )
779
- if err != nil {
780
- log .Println (err )
781
- }
782
- request .Header .Add ("Cookie" , fmt .Sprintf ("token=%s" , token ))
783
- request .Header .Add ("Content-Type" , "application/json" )
784
- client := & http.Client {
785
- Timeout : 2 * time .Second ,
786
- }
787
- response , err := client .Do (request )
788
- return response , err
789
- }
790
-
791
746
func TestPutObjectsLegalholdStatus (t * testing.T ) {
792
747
// Variables
793
748
assert := assert .New (t )
@@ -1559,8 +1514,6 @@ func TestShareObjectOnURL(t *testing.T) {
1559
1514
tags := make (map [string ]string )
1560
1515
tags ["tag" ] = "testputobjecttagbucketonetagone"
1561
1516
versionID := "null"
1562
- accessKey := "testaccesskey"
1563
- secretKey := "secretAccessKey"
1564
1517
1565
1518
// 1. Create the bucket
1566
1519
if ! setupBucket (bucketName , false , false , nil , nil , assert , 200 ) {
@@ -1581,21 +1534,6 @@ func TestShareObjectOnURL(t *testing.T) {
1581
1534
inspectHTTPResponse (uploadResponse ),
1582
1535
)
1583
1536
}
1584
- // 2. Create Access Key
1585
- accKeyRsp , createError := PostServiceAccountCredentials (accessKey , secretKey , "" )
1586
-
1587
- if createError != nil {
1588
- log .Println (createError )
1589
- return
1590
- }
1591
-
1592
- if accKeyRsp != nil {
1593
- assert .Equal (
1594
- 201 ,
1595
- accKeyRsp .StatusCode ,
1596
- inspectHTTPResponse (accKeyRsp ),
1597
- )
1598
- }
1599
1537
1600
1538
type args struct {
1601
1539
prefix string
@@ -1623,7 +1561,7 @@ func TestShareObjectOnURL(t *testing.T) {
1623
1561
for _ , tt := range tests {
1624
1562
t .Run (tt .name , func (t * testing.T ) {
1625
1563
// 3. Share the object on a URL
1626
- shareResponse , shareError := SharesAnObjectOnAUrl (bucketName , tt .args .prefix , versionID , "604800s" , accessKey , secretKey )
1564
+ shareResponse , shareError := SharesAnObjectOnAUrl (bucketName , tt .args .prefix , versionID , "604800s" )
1627
1565
assert .Nil (shareError )
1628
1566
if shareError != nil {
1629
1567
log .Println (shareError )
0 commit comments