支持项目编码访问单项目公示屏

需求:无需查询公示 Token,直接通过项目编码打开单项目公示页。

实现:规范化项目编码并按 code 查询,同时保留既有 Token 哈希查询;补充前后端及集成回归测试。
This commit is contained in:
2026-07-31 17:11:21 +08:00
parent 78df07e074
commit 9948c23bef
8 changed files with 108 additions and 8 deletions

View File

@@ -58,6 +58,26 @@ func TestPublicDisplayProjectViewOnlySerializesDisplayFields(t *testing.T) {
}
}
func TestNormalizeDisplayProjectCode(t *testing.T) {
tests := []struct {
input string
want string
ok bool
}{
{input: "raft", want: "RAFT", ok: true},
{input: " east-ride ", want: "EAST-RIDE", ok: true},
{input: "A", ok: false},
{input: "bad code", ok: false},
{input: strings.Repeat("a", 40), ok: false},
}
for _, test := range tests {
got, ok := normalizeDisplayProjectCode(test.input)
if got != test.want || ok != test.ok {
t.Fatalf("normalizeDisplayProjectCode(%q) = %q, %v; want %q, %v", test.input, got, ok, test.want, test.ok)
}
}
}
func TestPublicPhoneLookupIsDisabledInProduction(t *testing.T) {
server := &Server{config: config.Config{Environment: "production"}}
recorder := httptest.NewRecorder()