@@ -927,7 +927,7 @@ func Test_shareObject(t *testing.T) {
927
927
expected string
928
928
}{
929
929
{
930
- test : "Get share object url" ,
930
+ test : "return sharefunc url base64 encoded with host name " ,
931
931
args : args {
932
932
r : & http.Request {
933
933
TLS : nil ,
@@ -944,7 +944,7 @@ func Test_shareObject(t *testing.T) {
944
944
expected : "http://localhost:9090/api/v1/download-shared-object/aHR0cDovL3NvbWV1cmw=" ,
945
945
},
946
946
{
947
- test : "URL with TLS uses https scheme " ,
947
+ test : "return https scheme if url uses TLS " ,
948
948
args : args {
949
949
r : & http.Request {
950
950
TLS : & tls.ConnectionState {},
@@ -961,7 +961,7 @@ func Test_shareObject(t *testing.T) {
961
961
expected : "https://localhost:9090/api/v1/download-shared-object/aHR0cDovL3NvbWV1cmw=" ,
962
962
},
963
963
{
964
- test : "handle invalid expire duration" ,
964
+ test : "returns invalid expire duration if expiration is invalid " ,
965
965
args : args {
966
966
r : & http.Request {
967
967
TLS : nil ,
@@ -976,7 +976,7 @@ func Test_shareObject(t *testing.T) {
976
976
wantError : errors .New ("time: invalid duration \" invalid\" " ),
977
977
},
978
978
{
979
- test : "handle empty expire duration " ,
979
+ test : "add default expiration if expiration is empty " ,
980
980
args : args {
981
981
r : & http.Request {
982
982
TLS : nil ,
@@ -992,7 +992,7 @@ func Test_shareObject(t *testing.T) {
992
992
expected : "http://localhost:9090/api/v1/download-shared-object/aHR0cDovL3NvbWV1cmw=" ,
993
993
},
994
994
{
995
- test : "handle error on share func " ,
995
+ test : "return error if sharefunc returns error " ,
996
996
args : args {
997
997
r : & http.Request {
998
998
TLS : nil ,
@@ -1006,6 +1006,23 @@ func Test_shareObject(t *testing.T) {
1006
1006
},
1007
1007
wantError : errors .New ("probe error" ),
1008
1008
},
1009
+ {
1010
+ test : "return shareFunc url base64 encoded url-safe" ,
1011
+ args : args {
1012
+ r : & http.Request {
1013
+ TLS : nil ,
1014
+ Host : "localhost:9090" ,
1015
+ },
1016
+ versionID : "2121434" ,
1017
+ expires : "3h" ,
1018
+ shareFunc : func (_ context.Context , _ string , _ time.Duration ) (string , * probe.Error ) {
1019
+ // https://127.0.0.1:9000/cestest/Audio%20icon.svg?X-Amz-Algorithm=AWS4-HMAC-SHA256 using StdEncoding adds an extra `/` making it not url safe
1020
+ return "https://127.0.0.1:9000/cestest/Audio%20icon.svg?X-Amz-Algorithm=AWS4-HMAC-SHA256" , nil
1021
+ },
1022
+ },
1023
+ wantError : nil ,
1024
+ expected : "http://localhost:9090/api/v1/download-shared-object/aHR0cHM6Ly8xMjcuMC4wLjE6OTAwMC9jZXN0ZXN0L0F1ZGlvJTIwaWNvbi5zdmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTY=" ,
1025
+ },
1009
1026
}
1010
1027
1011
1028
for _ , tt := range tests {
0 commit comments