mirror of
https://github.com/dagu-org/dagu.git
synced 2025-12-28 06:34:22 +00:00
api: expose metrics without auth (#1410)
This commit is contained in:
parent
db32c6640a
commit
e569995e48
@ -145,6 +145,7 @@ func (a *API) ConfigureRoutes(ctx context.Context, r chi.Router, baseURL string)
|
||||
Creds: map[string]string{authConfig.Basic.Username: authConfig.Basic.Password},
|
||||
PublicPaths: []string{
|
||||
pathutil.BuildPublicEndpointPath(basePath, "api/v2/health"),
|
||||
pathutil.BuildPublicEndpointPath(basePath, "api/v2/metrics"),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
24
internal/service/frontend/api/v2/metrics_test.go
Normal file
24
internal/service/frontend/api/v2/metrics_test.go
Normal file
@ -0,0 +1,24 @@
|
||||
package api_test
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/dagu-org/dagu/internal/common/config"
|
||||
"github.com/dagu-org/dagu/internal/test"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestMetrics_BypassesAuth(t *testing.T) {
|
||||
server := test.SetupServer(t, test.WithConfigMutator(func(cfg *config.Config) {
|
||||
cfg.Server.Auth.Basic.Username = "admin"
|
||||
cfg.Server.Auth.Basic.Password = "secret"
|
||||
}))
|
||||
|
||||
resp := server.Client().Get("/api/v2/metrics").ExpectStatus(http.StatusOK).Send(t)
|
||||
|
||||
require.Contains(t, resp.Response.Header().Get("Content-Type"), "text/plain")
|
||||
require.NotEmpty(t, resp.Body)
|
||||
|
||||
server.Client().Get("/api/v2/dag-runs").ExpectStatus(http.StatusUnauthorized).Send(t)
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user