AI Gateway Go 0.10.0 源码快照 + 旗舰版需求规划报告

M0-M7 已完成:核心网关(身份/RBAC/TOTP/OIDC/SAML/Provider/配额/路由/内容策略/审计/定价)+ 资源市场(MCP/Skills/数字员工)。
含 22 个 PostgreSQL 迁移、管理端/门户端前端源码、OpenAPI 契约、部署 compose。

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
ben
2026-08-12 11:45:54 +08:00
commit 5759c1862e
807 changed files with 114727 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
package identity
import (
"testing"
"time"
)
func TestHOTPUsesRFC6238Vector(t *testing.T) {
// RFC 6238 SHA-1 shared secret, time 59 seconds, 8-digit expected value.
code, err := hotp("GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ", 59/30, 8)
if err != nil {
t.Fatal(err)
}
if code != "94287082" {
t.Fatalf("got %s", code)
}
}
func TestVerifyTOTPAcceptsWindow(t *testing.T) {
now := time.Unix(1_700_000_000, 0)
secret := "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ"
code, err := hotp(secret, now.Unix()/30-1, 6)
if err != nil {
t.Fatal(err)
}
step, ok := VerifyTOTP(secret, code, now)
if !ok || step != now.Unix()/30-1 {
t.Fatalf("step=%d ok=%v", step, ok)
}
}
func TestBackupCodeNormalization(t *testing.T) {
if HashBackupCode("abcd-2345") != HashBackupCode(" ABCD2345 ") {
t.Fatal("backup code normalization differs")
}
codes, records, err := GenerateBackupCodes()
if err != nil {
t.Fatal(err)
}
if len(codes) != 10 || len(records) != 10 || records[0].Hash != HashBackupCode(codes[0]) {
t.Fatal("invalid backup code generation")
}
}