mirror of
https://github.com/hanzoai/ai.git
synced 2026-11-20 14:13:23 +00:00
Removes 25 /v1 routes, their beego controllers, object models, native ZAP handlers, React pages and i18n strings. Evidence that this was dead upstream demo code and never a Hanzo surface: PROVENANCE. All five objects arrived in ONE upstream casibase commit,a0270c60"feat: add five new objects and related pages (#1670)", authored 2025-10-21 by the GitHub Copilot bot — three months before Hanzo forked the repo (010a124a, 2026-01-19). The original file headers read "Copyright 2025 The Casibase Authors"; they say Hanzo today only becausee0a49b54scrubbed every header in the tree. The `caase` spelling is an artifact of that generator dodging Go's `case` keyword — no human shipped a "Caases" nav label that renders as "Cases". NO HANZO AUTHORSHIP. Since the fork these files carry zero semantic change. Every diff is a repo-wide mechanical sweep: import path rename, xorm -> dbx, gofumpt, pagination refactor, IAM repoint, and one 401/403 conversion that hit chat/message/patient/scale alike. No commit subject, branch, or doc in the repo ever mentions a medical intent. NO CALLERS. Nothing in ~/work/hanzo outside this repo references any of the 25 routes — console, console2, chat, app, cloud, sdk, gui, dev, team, bot, platform, universe, base, iam and kms are all clean. The only external hits were git worktrees of this same repo. In-repo, the sole references were the route table itself and the mechanical ZAP strangler port. NO DATA. The models were registered for table creation but no migration, seed or fixture ever inserted a row, and the routes appear in no API spec. Corroborating: the in-flight router refactor (routers/resources.go) rebuilds every real resource under a subsystem namespace — iam, rag, chat, ai, content, compute, work — and gives these five none, leaving them the only flat verb-noun CRUD blocks left in router.go. They were also nav-filed under "Multimedia", which is where dumped demo code lands, not a product vertical. The `med:` i18n namespace is kept but pruned to the three keys still used by surviving features (Medical Image Analysis and Super Resolution in NavItemTree, Other in FileTree). object.IsAdmin, a duplicate of util.IsAdmin that happened to live in patient_util.go, goes with it. go build ./... and go vet ./... pass; controllers and routers tests are green and the full-suite failure set is byte-identical to the pre-change baseline. Co-authored-by: Hanzo Dev <[email protected]>
59 lines
2.1 KiB
Go
59 lines
2.1 KiB
Go
// Copyright 2023-2025 Hanzo AI Inc. All Rights Reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package controllers
|
|
|
|
import (
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
web "github.com/hanzoai/ai/web"
|
|
)
|
|
|
|
// newRecorderController builds an ApiController wired to an httptest recorder so a
|
|
// handler's HTTP status can be asserted directly.
|
|
func newRecorderController() (*ApiController, *httptest.ResponseRecorder) {
|
|
rec := httptest.NewRecorder()
|
|
ctx := web.NewContext()
|
|
ctx.Reset(rec, httptest.NewRequest("GET", "/v1/x", nil))
|
|
c := &ApiController{}
|
|
c.Init(ctx, "ApiController", "X", nil)
|
|
return c, rec
|
|
}
|
|
|
|
// TestResponseForbiddenAndUnauthorizedStatus is the R5 mechanism assertion: the
|
|
// controller auth-deny helpers emit REAL 403/401 statuses (not Beego's default
|
|
// 200). The controller deny sites (chat/message/scale) were converted from
|
|
// c.ResponseError (HTTP 200) to these helpers.
|
|
func TestResponseForbiddenAndUnauthorizedStatus(t *testing.T) {
|
|
c, rec := newRecorderController()
|
|
c.ResponseForbidden("auth:Unauthorized operation")
|
|
if rec.Code != 403 {
|
|
t.Errorf("ResponseForbidden status = %d, want 403", rec.Code)
|
|
}
|
|
|
|
c2, rec2 := newRecorderController()
|
|
c2.ResponseUnauthorized("auth:Please sign in first")
|
|
if rec2.Code != 401 {
|
|
t.Errorf("ResponseUnauthorized status = %d, want 401", rec2.Code)
|
|
}
|
|
|
|
// Contrast: plain ResponseError still emits 200 (why the deny sites had to move).
|
|
c3, rec3 := newRecorderController()
|
|
c3.ResponseError("some non-auth error")
|
|
if rec3.Code != 200 {
|
|
t.Errorf("plain ResponseError status = %d, want 200 (baseline)", rec3.Code)
|
|
}
|
|
}
|