release / go (push) Successful in 2m7s
release / web (push) Successful in 1m25s
release / govulncheck (push) Successful in 21s
release / integration (push) Successful in 4m30s
release / android (push) Successful in 4m39s
release / Build signed APK (push) Successful in 5m10s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 29s
release / Verify release artifacts (tag releases only) (push) Skipped
- Module path: github.com/Fabled-Sword/minstrel, in go.mod, every import and the Dockerfile's version ldflags. - buildinfo.ProjectURL, the contact outside services see in Minstrel's User-Agent: https://github.com/Fabled-Sword/minstrel. - README's compose example pulls ghcr.io/fabled-sword/minstrel:latest. - docs/security.md sends problem reports to the GitHub issues. - The demo-library stack builds Minstrel from the checkout, since :dev is not published to GHCR. - hygiene.go's same-site example uses example.com names. The workbench CI (.gitea/, ci/, export-ignored) still builds and publishes :dev to the private registry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
75 lines
2.1 KiB
Go
75 lines
2.1 KiB
Go
package api
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
|
|
"github.com/Fabled-Sword/minstrel/internal/auth"
|
|
"github.com/Fabled-Sword/minstrel/internal/coverart"
|
|
)
|
|
|
|
func newResearchRouter(h *handlers) chi.Router {
|
|
r := chi.NewRouter()
|
|
r.Route("/api/admin", func(admin chi.Router) {
|
|
admin.Use(auth.RequireAdmin())
|
|
admin.Post("/cover-sources/research", h.handleResearchMissingArt)
|
|
})
|
|
return r
|
|
}
|
|
|
|
func TestAdminResearchMissingArt_BumpsAndReturnsVersion(t *testing.T) {
|
|
if os.Getenv("MINSTREL_TEST_DATABASE_URL") == "" {
|
|
t.Skip("MINSTREL_TEST_DATABASE_URL not set")
|
|
}
|
|
coverart.ResetRegistryForTests()
|
|
t.Cleanup(coverart.ResetRegistryForTests)
|
|
|
|
coverart.Register(&apiTestAlbumProvider{id: "research-prov", display: "Research Provider"})
|
|
|
|
h, _ := testHandlersWithCoverSettings(t)
|
|
admin := seedUser(t, h.pool, "researchadmin", "pw", true)
|
|
|
|
req := httptest.NewRequest(http.MethodPost, "/api/admin/cover-sources/research", nil)
|
|
req = withUser(req, admin)
|
|
rec := httptest.NewRecorder()
|
|
newResearchRouter(h).ServeHTTP(rec, req)
|
|
|
|
if rec.Code != http.StatusOK {
|
|
t.Fatalf("status = %d, want 200; body=%s", rec.Code, rec.Body.String())
|
|
}
|
|
var resp map[string]any
|
|
if err := json.Unmarshal(rec.Body.Bytes(), &resp); err != nil {
|
|
t.Fatalf("decode: %v", err)
|
|
}
|
|
if _, ok := resp["version"]; !ok {
|
|
t.Errorf("response missing 'version' field; got %v", resp)
|
|
}
|
|
}
|
|
|
|
func TestAdminResearchMissingArt_NonAdmin_403(t *testing.T) {
|
|
if os.Getenv("MINSTREL_TEST_DATABASE_URL") == "" {
|
|
t.Skip("MINSTREL_TEST_DATABASE_URL not set")
|
|
}
|
|
coverart.ResetRegistryForTests()
|
|
t.Cleanup(coverart.ResetRegistryForTests)
|
|
|
|
coverart.Register(&apiTestAlbumProvider{id: "research-prov2", display: "Research Provider 2"})
|
|
|
|
h, _ := testHandlersWithCoverSettings(t)
|
|
user := seedUser(t, h.pool, "researchnonadmin", "pw", false)
|
|
|
|
req := httptest.NewRequest(http.MethodPost, "/api/admin/cover-sources/research", nil)
|
|
req = withUser(req, user)
|
|
rec := httptest.NewRecorder()
|
|
newResearchRouter(h).ServeHTTP(rec, req)
|
|
|
|
if rec.Code != http.StatusForbidden {
|
|
t.Errorf("status = %d, want 403", rec.Code)
|
|
}
|
|
}
|