@@ -927,7 +927,7 @@ func Test_shareObject(t *testing.T) {
927927 expected string
928928 }{
929929 {
930- test : "Get share object url" ,
930+ test : "return sharefunc url base64 encoded with host name " ,
931931 args : args {
932932 r : & http.Request {
933933 TLS : nil ,
@@ -944,7 +944,7 @@ func Test_shareObject(t *testing.T) {
944944 expected : "http://localhost:9090/api/v1/download-shared-object/aHR0cDovL3NvbWV1cmw=" ,
945945 },
946946 {
947- test : "URL with TLS uses https scheme " ,
947+ test : "return https scheme if url uses TLS " ,
948948 args : args {
949949 r : & http.Request {
950950 TLS : & tls.ConnectionState {},
@@ -961,7 +961,7 @@ func Test_shareObject(t *testing.T) {
961961 expected : "https://localhost:9090/api/v1/download-shared-object/aHR0cDovL3NvbWV1cmw=" ,
962962 },
963963 {
964- test : "handle invalid expire duration" ,
964+ test : "returns invalid expire duration if expiration is invalid " ,
965965 args : args {
966966 r : & http.Request {
967967 TLS : nil ,
@@ -976,7 +976,7 @@ func Test_shareObject(t *testing.T) {
976976 wantError : errors .New ("time: invalid duration \" invalid\" " ),
977977 },
978978 {
979- test : "handle empty expire duration " ,
979+ test : "add default expiration if expiration is empty " ,
980980 args : args {
981981 r : & http.Request {
982982 TLS : nil ,
@@ -992,7 +992,7 @@ func Test_shareObject(t *testing.T) {
992992 expected : "http://localhost:9090/api/v1/download-shared-object/aHR0cDovL3NvbWV1cmw=" ,
993993 },
994994 {
995- test : "handle error on share func " ,
995+ test : "return error if sharefunc returns error " ,
996996 args : args {
997997 r : & http.Request {
998998 TLS : nil ,
@@ -1006,6 +1006,23 @@ func Test_shareObject(t *testing.T) {
10061006 },
10071007 wantError : errors .New ("probe error" ),
10081008 },
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+ },
10091026 }
10101027
10111028 for _ , tt := range tests {
0 commit comments