aboutsummaryrefslogtreecommitdiffstats
path: root/syz-cluster/dashboard
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2025-07-11 13:17:34 +0200
committerAleksandr Nogikh <nogikh@google.com>2025-07-14 11:30:46 +0000
commit76718eb73e3d1e2a43363d80ab15366706b6491f (patch)
tree4d8008f2b7fcfb674e7f8c9562c9cc3643aea50f /syz-cluster/dashboard
parent0bfc1202cebeedf826d470296424f85dee4fe842 (diff)
syz-cluster: generate web dashboard URLs for reports
Take web dashboard URL from the config and use it to generate links for logs, reproducers, etc.
Diffstat (limited to 'syz-cluster/dashboard')
-rw-r--r--syz-cluster/dashboard/handler.go6
-rw-r--r--syz-cluster/dashboard/handler_test.go51
2 files changed, 52 insertions, 5 deletions
diff --git a/syz-cluster/dashboard/handler.go b/syz-cluster/dashboard/handler.go
index ea3802533..f6c9b3e3b 100644
--- a/syz-cluster/dashboard/handler.go
+++ b/syz-cluster/dashboard/handler.go
@@ -42,12 +42,8 @@ func newHandler(env *app.AppEnvironment) (*dashboardHandler, error) {
return nil, err
}
}
- cfg, err := app.Config()
- if err != nil {
- return nil, err
- }
return &dashboardHandler{
- title: cfg.Name,
+ title: env.Config.Name,
templates: perFile,
blobStorage: env.BlobStorage,
seriesRepo: db.NewSeriesRepository(env.Spanner),
diff --git a/syz-cluster/dashboard/handler_test.go b/syz-cluster/dashboard/handler_test.go
new file mode 100644
index 000000000..9ef993b93
--- /dev/null
+++ b/syz-cluster/dashboard/handler_test.go
@@ -0,0 +1,51 @@
+// Copyright 2025 syzkaller project authors. All rights reserved.
+// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+
+package main
+
+import (
+ "net/http"
+ "net/http/httptest"
+ "testing"
+
+ "github.com/google/syzkaller/syz-cluster/pkg/api"
+ "github.com/google/syzkaller/syz-cluster/pkg/app"
+ "github.com/google/syzkaller/syz-cluster/pkg/controller"
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
+)
+
+func TestURLs(t *testing.T) {
+ env, ctx := app.TestEnvironment(t)
+ client := controller.TestServer(t, env)
+ testSeries := controller.DummySeries()
+ ids := controller.FakeSeriesWithFindings(t, ctx, env, client, testSeries)
+
+ handler, baseURL := testServer(t, env)
+ urlGen := api.NewURLGenerator(baseURL)
+
+ var urls []string
+ urls = append(urls, urlGen.Series(ids.SeriesID))
+ findings, err := handler.findingRepo.ListForSession(ctx, ids.SessionID, 0)
+ require.NoError(t, err)
+ for _, finding := range findings {
+ urls = append(urls, urlGen.FindingLog(finding.ID))
+ urls = append(urls, urlGen.FindingCRepro(finding.ID))
+ urls = append(urls, urlGen.FindingSyzRepro(finding.ID))
+ }
+ for _, url := range urls {
+ t.Logf("checking %s", url)
+ resp, err := http.Get(url)
+ assert.NoError(t, err)
+ resp.Body.Close()
+ assert.Equal(t, http.StatusOK, resp.StatusCode, "%q was expected to return HTTP 200", url)
+ }
+}
+
+func testServer(t *testing.T, env *app.AppEnvironment) (*dashboardHandler, string) {
+ handler, err := newHandler(env)
+ require.NoError(t, err)
+ server := httptest.NewServer(handler.Mux())
+ t.Cleanup(server.Close)
+ return handler, server.URL
+}