test(voice/tts): pin fragment-before-query in redactURL fallback
Review r1 P2-01: the only fragment case had '?' before '#', so degrading stripURLQuery to cut '?' alone stayed green and the '#'-first branch was unpinned. Add a scheme-less '#access_token=...' case (OAuth implicit flow shape) and correct the mutation comment to state which case each mutation actually kills.
This commit is contained in:
1 parent
28a6cd7e53
commit
a1c9da6e8a
1 file changed
+7
-2
@@ -128,8 +128,12 @@ func TestRedactURLCredentials(t *testing.T) {
|
||||
// 于是 host 为空、走兜底。旧兜底把原串连 query 一起返回,签名/token 就这么进了
|
||||
// 日志与工单。现在兜底只按 `?`/`#` 切掉查询串与片段。
|
||||
//
|
||||
// 变异:把兜底的 `stripURLQuery(raw)` 改回 `raw` ⇒ 前两条用例必红(secret 与
|
||||
// `token=` 都会出现);把 stripURLQuery 改成只切 `?` ⇒ 第二条用例留下 `#frag`。
|
||||
// 变异(两种,各自被不同的子用例杀灭):
|
||||
// - 兜底改回 `raw` ⇒ 带 query 的三条用例全红(secret / `token=` 会出现在结果里);
|
||||
// - `stripURLQuery` 退化成**只切 `?`** ⇒ 只有「片段先于查询」那条红
|
||||
// (`#access_token=…` 原样留在结果里)。「query 与片段」那条**打不红** ——
|
||||
// `?` 在 `#` 之前,只切 `?` 会顺带把片段带走 —— 所以 `#` 先行这条分支必须由
|
||||
// 「片段先于查询」独立钉住(review M55 r1 的 P2-01)。
|
||||
func TestRedactURLNoSchemeDropsQuery(t *testing.T) {
|
||||
const secret = "TTS-SECRET-7b3e"
|
||||
cases := []struct {
|
||||
@@ -139,6 +143,7 @@ func TestRedactURLNoSchemeDropsQuery(t *testing.T) {
|
||||
}{
|
||||
{"无 scheme 带 query", "127.0.0.1:9880/v1/audio/speech?token=" + secret, "127.0.0.1:9880/v1/audio/speech"},
|
||||
{"无 scheme 带 query 与片段", "tts.internal:9880/v1?token=" + secret + "#frag", "tts.internal:9880/v1"},
|
||||
{"无 scheme 片段先于查询", "127.0.0.1:9880/v1#access_token=" + secret, "127.0.0.1:9880/v1"},
|
||||
{"无 scheme 无 query 原样", "127.0.0.1:9880", "127.0.0.1:9880"},
|
||||
{"无 scheme 带 userinfo ⇒ 整体打码", "user:pass@host/v1?token=" + secret, "<redacted>"},
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user