feat(core): answer cognitive channel questions
CI / test (push) Successful in 19s
CI / test (pull_request) Successful in 19s

This commit is contained in:
m
2026-08-21 09:19:15 +03:00
parent 0d10e6fd82
commit 8d149b2b9d
4 changed files with 107 additions and 2 deletions
+19
View File
@@ -9,6 +9,8 @@ import (
"strings"
"testing"
"time"
"git.cin.su/m/Assistant/contracts/capability"
)
func TestBearerTokenRequiresBearerScheme(t *testing.T) {
@@ -23,6 +25,23 @@ func TestBearerTokenRequiresBearerScheme(t *testing.T) {
}
}
func TestCognitiveChannelQuestionUsesHumanSafeHealthReply(t *testing.T) {
if !isCognitiveChannelQuestion("Проверь локальную модель") {
t.Fatal("expected local model question to be recognized")
}
reply := humanCognitiveChannelReply("Проверь локальную модель", capability.Health{State: capability.HealthAvailable, CapabilityID: "provider-secret-model"}, nil)
if !strings.Contains(reply, "доступен") || strings.Contains(reply, "provider-secret-model") {
t.Fatalf("unexpected safe reply: %q", reply)
}
}
func TestCognitiveConfigurationRequestDoesNotPretendToMutate(t *testing.T) {
reply := humanCognitiveChannelReply("Переключи локальную модель", capability.Health{State: capability.HealthUnavailable}, nil)
if !strings.Contains(reply, "не меняю модель") || !strings.Contains(reply, "консоли") {
t.Fatalf("unexpected configuration reply: %q", reply)
}
}
func TestCreatorSessionHandlerAcceptsConfiguredCredentials(t *testing.T) {
handler := creatorSessionHandler("recovery", "m", "password", []byte("01234567890123456789012345678901"), func() time.Time { return time.Unix(1000, 0) })
request := httptest.NewRequest(http.MethodPost, "/v1/creator/sessions", strings.NewReader(`{"username":"m","password":"password"}`))