@@ -58,6 +58,7 @@ func (h *dashboardHandler) Mux() *http.ServeMux {
5858 mux := http .NewServeMux ()
5959 mux .HandleFunc ("/sessions/{id}/log" , errToStatus (h .sessionLog ))
6060 mux .HandleFunc ("/sessions/{id}/test_logs" , errToStatus (h .sessionTestLog ))
61+ mux .HandleFunc ("/sessions/{id}/test_artifacts" , errToStatus (h .sessionTestArtifacts ))
6162 mux .HandleFunc ("/series/{id}" , errToStatus (h .seriesInfo ))
6263 mux .HandleFunc ("/patches/{id}" , errToStatus (h .patchContent ))
6364 mux .HandleFunc ("/findings/{id}/{key}" , errToStatus (h .findingInfo ))
@@ -254,11 +255,24 @@ func (h *dashboardHandler) sessionTestLog(w http.ResponseWriter, r *http.Request
254255 if err != nil {
255256 return err
256257 } else if test == nil {
257- return fmt .Errorf ("%w: test log " , errNotFound )
258+ return fmt .Errorf ("%w: test" , errNotFound )
258259 }
259260 return h .streamBlob (w , test .LogURI )
260261}
261262
263+ func (h * dashboardHandler ) sessionTestArtifacts (w http.ResponseWriter , r * http.Request ) error {
264+ test , err := h .sessionTestRepo .Get (r .Context (), r .PathValue ("id" ), r .FormValue ("name" ))
265+ if err != nil {
266+ return err
267+ } else if test == nil {
268+ return fmt .Errorf ("%w: test" , errNotFound )
269+ }
270+ filename := fmt .Sprintf ("%s_%s.tar.gz" , test .SessionID , test .TestName )
271+ w .Header ().Set ("Content-Disposition" , fmt .Sprintf ("attachment; filename=\" %s\" " , filename ))
272+ w .Header ().Set ("Content-Type" , "application/octet-stream" )
273+ return h .streamBlob (w , test .ArtifactsArchiveURI )
274+ }
275+
262276func (h * dashboardHandler ) streamBlob (w http.ResponseWriter , uri string ) error {
263277 if uri == "" {
264278 return nil
0 commit comments