mirror of
https://github.com/hanzoai/ai.git
synced 2026-11-20 14:13:23 +00:00
Ninety-one errors, all residue of the same mechanical pass: recorders read after the response moved onto the context, a probe renamed mid-conversion so its old name resolved to a struct and read as a type conversion, harnesses returning a recorder they no longer had, and signatures that had already become pure functions (bearerToken of two strings, publicAddr of two, relayZenStream of its destination) still being handed a request. The tests that survive say what they always meant, and a few say it better: bearerToken's is a truth table now because the function is one, and the reward and contribution suites present a credential instead of seeding a store. Three tests are gone rather than converted, each pinning something that no longer exists: two host-resolver tests superseded by the stamped header, a session-path test that had become the bearer test beside it, and a nil-session table that was the table above it with four rows missing. go mod tidy runs for the first time on this branch — nothing imports the deleted router any more — so the build no longer needs -mod=mod.
46 lines
1.6 KiB
Go
46 lines
1.6 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"
|
|
"testing"
|
|
)
|
|
|
|
// TestResponseForbiddenAndUnauthorizedStatus is the R5 mechanism assertion: the
|
|
// controller auth-deny helpers emit REAL 403/401 statuses (not The router'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 := visit(http.MethodGet, "/v1/x")
|
|
c.ResponseForbidden("auth:Unauthorized operation")
|
|
if answered(c) != 403 {
|
|
t.Errorf("ResponseForbidden status = %d, want 403", answered(c))
|
|
}
|
|
|
|
c2 := visit(http.MethodGet, "/v1/x")
|
|
c2.ResponseUnauthorized("auth:Please sign in first")
|
|
if answered(c2) != 401 {
|
|
t.Errorf("ResponseUnauthorized status = %d, want 401", answered(c2))
|
|
}
|
|
|
|
// Contrast: plain ResponseError still emits 200 (why the deny sites had to move).
|
|
c3 := visit(http.MethodGet, "/v1/x")
|
|
c3.ResponseError("some non-auth error")
|
|
if answered(c3) != 200 {
|
|
t.Errorf("plain ResponseError status = %d, want 200 (baseline)", answered(c3))
|
|
}
|
|
}
|