@@ -921,10 +921,11 @@ func Test_shareObject(t *testing.T) {
921921 shareFunc func (ctx context.Context , versionID string , expires time.Duration ) (string , * probe.Error )
922922 }
923923 tests := []struct {
924- test string
925- args args
926- wantError error
927- expected string
924+ test string
925+ args args
926+ setEnvVars func ()
927+ wantError error
928+ expected string
928929 }{
929930 {
930931 test : "return sharefunc url base64 encoded with host name" ,
@@ -1023,11 +1024,52 @@ func Test_shareObject(t *testing.T) {
10231024 wantError : nil ,
10241025 expected : "http://localhost:9090/api/v1/download-shared-object/aHR0cHM6Ly8xMjcuMC4wLjE6OTAwMC9jZXN0ZXN0L0F1ZGlvJTIwaWNvbi5zdmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTY=" ,
10251026 },
1027+ {
1028+ test : "returns redirect url with share link if redirect url env variable set" ,
1029+ setEnvVars : func () {
1030+ t .Setenv (ConsoleBrowserRedirectURL , "http://proxy-url.com:9012/console/subpath" )
1031+ },
1032+ args : args {
1033+ r : & http.Request {
1034+ TLS : nil ,
1035+ Host : "localhost:9090" ,
1036+ },
1037+ versionID : "2121434" ,
1038+ expires : "30s" ,
1039+ shareFunc : func (_ context.Context , _ string , _ time.Duration ) (string , * probe.Error ) {
1040+ return "http://someurl" , nil
1041+ },
1042+ },
1043+ wantError : nil ,
1044+ expected : "http://proxy-url.com:9012/console/subpath/api/v1/download-shared-object/aHR0cDovL3NvbWV1cmw=" ,
1045+ },
1046+ {
1047+ test : "returns redirect url with share link if redirect url env variable set with trailing slash" ,
1048+ setEnvVars : func () {
1049+ t .Setenv (ConsoleBrowserRedirectURL , "http://proxy-url.com:9012/console/subpath/" )
1050+ },
1051+ args : args {
1052+ r : & http.Request {
1053+ TLS : nil ,
1054+ Host : "localhost:9090" ,
1055+ },
1056+ versionID : "2121434" ,
1057+ expires : "30s" ,
1058+ shareFunc : func (_ context.Context , _ string , _ time.Duration ) (string , * probe.Error ) {
1059+ return "http://someurl" , nil
1060+ },
1061+ },
1062+ wantError : nil ,
1063+ expected : "http://proxy-url.com:9012/console/subpath/api/v1/download-shared-object/aHR0cDovL3NvbWV1cmw=" ,
1064+ },
10261065 }
10271066
10281067 for _ , tt := range tests {
10291068 t .Run (tt .test , func (_ * testing.T ) {
10301069 mcShareDownloadMock = tt .args .shareFunc
1070+ if tt .setEnvVars != nil {
1071+ tt .setEnvVars ()
1072+ }
10311073 url , err := getShareObjectURL (ctx , client , tt .args .r , tt .args .versionID , tt .args .expires )
10321074 if tt .wantError != nil {
10331075 if ! reflect .DeepEqual (err , tt .wantError ) {
0 commit comments