- Build single-source-of-truth 7-domain locale catalog (`locales/{zh-CN,en-US}/*.json`, 1,100+ keys) and `cmd/i18ngen` generator emitting Go catalogs and eager/lazy-split TypeScript domain modules (`core`/`vm` eager; `wizard`/`settings`/`plugins` lazy)
- Add zero-dependency ICU MessageFormat subset (`{var}`, `{n, number}`, CLDR `plural`, `select`), 8-hop cycle-free regional fallback (`zh-HK/zh-MO -> zh-Hant -> zh-TW -> zh-CN`), `auto` OS display-language preference, and `en-XA` pseudo-localization across Go and TypeScript
- Introduce `CodedError` supportability with `[E_CODE]` badges, collapsible `[detail]` diagnostics, and automatic SMC OSK / SMBIOS serial / MAC / token redaction
- Add Host × Guest macOS dual-terminology annotation (`FormatGuestTerm`) across 6 official Apple guest UI locales and localize Win32 system tray, file pickers, and DPI-adaptive `installguide` overlays with CJK font fallback probing
- Upgrade L1–L4 plugin localization to dual-track v2: Track A full language packs (`files`, WOFF2 `fonts`, cross-plugin `pluginOverrides`), Track B plugin-scoped `l10n` bundles (`HasUIMessages` isolation), live `plugin/localeChanged` notifications, `< 2ms` static CLI pack loading, and `reims-go plugin locale init|check` translator toolchain with `zh-TW` and `ja-JP` reference packs
- Harden security, WCAG 2.1 AA token contrast, `< 768px` responsive drawer & form layouts, and RTL logical properties; add backend security/locale regression tests and frontend `node --test` static/runtime guard suite in CI
# Conflicts:
# frontend/src/i18n.ts
# internal/cli/cli.go
# internal/i18n/i18n.go
450 lines
16 KiB
Go
450 lines
16 KiB
Go
package plugin
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/Nwflower/reims-go/internal/i18n"
|
|
)
|
|
|
|
func TestLocalizedTextExtraLocales(t *testing.T) {
|
|
var lt LocalizedText
|
|
raw := `{"zh-CN":"日语包","en-US":"Japanese Pack","ja-jp":"日本語パック"}`
|
|
if err := json.Unmarshal([]byte(raw), <); err != nil {
|
|
t.Fatalf("unmarshal: %v", err)
|
|
}
|
|
if !lt.HasAny() {
|
|
t.Fatal("expected HasAny=true")
|
|
}
|
|
if got := lt.Get("ja-JP"); got != "日本語パック" {
|
|
t.Fatalf("Get(ja-JP) = %q, want 日本語パック", got)
|
|
}
|
|
if got := lt.Get("zh-CN"); got != "日语包" {
|
|
t.Fatalf("Get(zh-CN) = %q", got)
|
|
}
|
|
if got := lt.Get("fr-FR"); got != "Japanese Pack" {
|
|
t.Fatalf("Get(fr-FR) fallback = %q, want Japanese Pack", got)
|
|
}
|
|
}
|
|
|
|
func TestValidateLocaleContribution(t *testing.T) {
|
|
dir := t.TempDir()
|
|
locDir := filepath.Join(dir, "locales")
|
|
if err := os.MkdirAll(locDir, 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(filepath.Join(locDir, "ja-JP.json"), []byte(`{"sidebarSettings":"設定"}`), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
okContrib := LocaleContribution{Locale: "ja-JP", Label: "日本語", File: "locales/ja-JP.json"}
|
|
if err := ValidateLocaleContribution(okContrib, dir); err != nil {
|
|
t.Fatalf("expected valid locale contribution, got: %v", err)
|
|
}
|
|
|
|
if err := ValidateLocaleContribution(LocaleContribution{Locale: "ja-JP"}, dir); err == nil {
|
|
t.Fatal("expected error for empty locale contribution")
|
|
}
|
|
if err := ValidateLocaleContribution(LocaleContribution{Locale: "bad/tag", Messages: map[string]string{"a": "b"}}, dir); err == nil {
|
|
t.Fatal("expected error for invalid locale tag")
|
|
}
|
|
if err := ValidateLocaleContribution(LocaleContribution{Locale: "ja-JP", File: "../secret.json"}, dir); err == nil {
|
|
t.Fatal("expected error for path traversal")
|
|
}
|
|
if err := ValidateLocaleContribution(LocaleContribution{Locale: "ja-JP", File: "locales/ja-JP.txt"}, dir); err == nil {
|
|
t.Fatal("expected error for non-.json locale file")
|
|
}
|
|
}
|
|
|
|
func TestManagerResolvedLocalePacks(t *testing.T) {
|
|
dataRoot := t.TempDir()
|
|
devDir := t.TempDir()
|
|
if err := os.MkdirAll(filepath.Join(devDir, "locales"), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(filepath.Join(devDir, "locales", "ja-JP.json"), []byte(`{"sidebarSettings":"設定","language":"言語"}`), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(filepath.Join(devDir, "locales", "ja-JP.backend.json"), []byte(`{"doctor.os":"OS (JP)"}`), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
manifest := `{
|
|
"schema": 1,
|
|
"id": "community.locale.ja",
|
|
"version": "1.0.0",
|
|
"name": {"zh-CN": "日语语言包", "en-US": "Japanese Pack", "ja-JP": "日本語パック"},
|
|
"description": {"zh-CN": "日语翻译", "en-US": "Japanese translations"},
|
|
"contributes": {
|
|
"locales": [
|
|
{
|
|
"locale": "ja_jp",
|
|
"label": "日本語",
|
|
"fallback": "en-US",
|
|
"file": "locales/ja-JP.json",
|
|
"backendFile": "locales/ja-JP.backend.json",
|
|
"messages": {"themeDark": "ダーク"}
|
|
}
|
|
]
|
|
}
|
|
}`
|
|
if err := os.WriteFile(filepath.Join(devDir, "plugin.json"), []byte(manifest), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
mgr, err := NewManager(ManagerOptions{DataRoot: dataRoot, HostVersion: "0.2.6"})
|
|
if err != nil {
|
|
t.Fatalf("NewManager: %v", err)
|
|
}
|
|
defer mgr.Close()
|
|
|
|
if _, err := mgr.LinkDev(context.Background(), devDir); err != nil {
|
|
t.Fatalf("LinkDev: %v", err)
|
|
}
|
|
if err := mgr.Enable(context.Background(), "community.locale.ja", false); err != nil {
|
|
t.Fatalf("Enable: %v", err)
|
|
}
|
|
|
|
uiPacks, backendPacks := mgr.ResolvedLocalePacks()
|
|
if len(uiPacks) != 1 {
|
|
t.Fatalf("expected 1 UI locale pack, got %d", len(uiPacks))
|
|
}
|
|
p := uiPacks[0]
|
|
if p.Locale != "ja-JP" || p.Label != "日本語" || p.Fallback != "en-US" {
|
|
t.Fatalf("unexpected pack metadata: %+v", p)
|
|
}
|
|
if p.Messages["sidebarSettings"] != "設定" || p.Messages["themeDark"] != "ダーク" {
|
|
t.Fatalf("unexpected merged UI messages: %+v", p.Messages)
|
|
}
|
|
bp, ok := backendPacks[i18n.Locale("ja-JP")]
|
|
if !ok || bp.Messages["doctor.os"] != "OS (JP)" {
|
|
t.Fatalf("unexpected backend catalog: %+v", backendPacks)
|
|
}
|
|
|
|
// Disabling the plugin removes the locale pack cleanly.
|
|
if err := mgr.Disable(context.Background(), "community.locale.ja"); err != nil {
|
|
t.Fatalf("Disable: %v", err)
|
|
}
|
|
uiPacks, backendPacks = mgr.ResolvedLocalePacks()
|
|
if len(uiPacks) != 0 || len(backendPacks) != 0 {
|
|
t.Fatalf("expected empty locale packs after disable, got ui=%d backend=%d", len(uiPacks), len(backendPacks))
|
|
}
|
|
}
|
|
|
|
func TestDualTrackLocaleV2FontsAndPluginOverrides(t *testing.T) {
|
|
dataRoot := t.TempDir()
|
|
|
|
// 1. Create functional plugin `acme.snap` with private l10n (`locales/en-US.json`, `locales/zh-CN.json`).
|
|
funcDir := t.TempDir()
|
|
if err := os.MkdirAll(filepath.Join(funcDir, "locales"), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(filepath.Join(funcDir, "locales", "en-US.json"), []byte(`{
|
|
"status.ok": {"message": "Backed up {count} items", "$comment": "Backup summary"}
|
|
}`), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(filepath.Join(funcDir, "locales", "zh-CN.json"), []byte(`{
|
|
"status.ok": "已备份 {count} 项"
|
|
}`), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
funcManifest := `{
|
|
"schema": 1,
|
|
"id": "acme.snap",
|
|
"version": "1.0.0",
|
|
"name": {"zh-CN": "快照助手", "en-US": "Snap Helper"},
|
|
"description": {"zh-CN": "自动快照", "en-US": "Auto snapshots"},
|
|
"l10n": "locales",
|
|
"permissions": ["ui:slot"],
|
|
"settings": {
|
|
"x-scope": "app",
|
|
"properties": {
|
|
"keep_count": {
|
|
"type": "integer",
|
|
"title": {"zh-CN": "保留份数", "en-US": "Keep count"},
|
|
"default": 5
|
|
}
|
|
}
|
|
},
|
|
"contributes": {
|
|
"menus": [
|
|
{"id": "quick", "slot": "vm.toolbar", "command": "snap.now", "title": {"zh-CN": "立即备份", "en-US": "Backup Now"}}
|
|
]
|
|
}
|
|
}`
|
|
if err := os.WriteFile(filepath.Join(funcDir, "plugin.json"), []byte(funcManifest), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
// 2. Create standalone Language Pack `official.lang.ja-jp` with domain files, valid WOFF2 font, and pluginOverrides for `acme.snap`.
|
|
langDir := t.TempDir()
|
|
if err := os.MkdirAll(filepath.Join(langDir, "locales"), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.MkdirAll(filepath.Join(langDir, "fonts"), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(filepath.Join(langDir, "locales", "core.json"), []byte(`{"sidebarSettings": "設定"}`), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(filepath.Join(langDir, "locales", "native.json"), []byte(`{"tray.quit": "Reims-Go を終了"}`), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
// Write a minimal dummy file starting with valid WOFF2 4-byte magic ("wOF2").
|
|
woff2Bytes := append([]byte("wOF2"), make([]byte, 44)...)
|
|
if err := os.WriteFile(filepath.Join(langDir, "fonts", "noto-jp-ui.woff2"), woff2Bytes, 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
// Also test rejecting bad WOFF2 header.
|
|
badFontPath := filepath.Join(langDir, "fonts", "bad.woff2")
|
|
if err := os.WriteFile(badFontPath, []byte("OTTO0000"), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := ValidateLocaleContribution(LocaleContribution{
|
|
Locale: "ja-JP",
|
|
Fonts: []ThemeFont{{Family: "BadFont", File: "fonts/bad.woff2"}},
|
|
}, langDir); err == nil {
|
|
t.Fatal("expected error for non-wOF2 font magic header")
|
|
}
|
|
|
|
langManifest := `{
|
|
"schema": 1,
|
|
"id": "official.lang.ja-jp",
|
|
"version": "1.0.0",
|
|
"name": {"zh-CN": "日语语言包", "en-US": "Japanese Language Pack", "ja-JP": "日本語言語パック"},
|
|
"description": {"en-US": "Japanese UI and CLI localization"},
|
|
"contributes": {
|
|
"locales": [
|
|
{
|
|
"locale": "ja-JP",
|
|
"label": "日本語",
|
|
"fallback": "en-US",
|
|
"files": {
|
|
"core": "locales/core.json",
|
|
"native": "locales/native.json"
|
|
},
|
|
"fonts": [
|
|
{"family": "Reims Noto JP", "file": "fonts/noto-jp-ui.woff2", "weight": "400"}
|
|
],
|
|
"pluginOverrides": {
|
|
"acme.snap": {
|
|
"manifest": {
|
|
"name": "スナップヘルパー",
|
|
"description": "自動スナップショット",
|
|
"fields": {
|
|
"setting.keep_count.title": "保持数",
|
|
"menu.quick.title": "今すぐバックアップ"
|
|
}
|
|
},
|
|
"messages": {
|
|
"status.ok": "{count} 件をバックアップしました"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}`
|
|
if err := os.WriteFile(filepath.Join(langDir, "plugin.json"), []byte(langManifest), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
mgr, err := NewManager(ManagerOptions{DataRoot: dataRoot, HostVersion: "0.2.8"})
|
|
if err != nil {
|
|
t.Fatalf("NewManager: %v", err)
|
|
}
|
|
defer mgr.Close()
|
|
|
|
if _, err := mgr.LinkDev(context.Background(), funcDir); err != nil {
|
|
t.Fatalf("LinkDev funcDir: %v", err)
|
|
}
|
|
if err := mgr.Enable(context.Background(), "acme.snap", false); err != nil {
|
|
t.Fatalf("Enable acme.snap: %v", err)
|
|
}
|
|
if _, err := mgr.LinkDev(context.Background(), langDir); err != nil {
|
|
t.Fatalf("LinkDev langDir: %v", err)
|
|
}
|
|
if err := mgr.Enable(context.Background(), "official.lang.ja-jp", false); err != nil {
|
|
t.Fatalf("Enable official.lang.ja-jp: %v", err)
|
|
}
|
|
|
|
uiPacks, backendPacks := mgr.ResolvedLocalePacks()
|
|
var jaPack *ResolvedLocalePack
|
|
for i := range uiPacks {
|
|
if uiPacks[i].Locale == "ja-JP" {
|
|
jaPack = &uiPacks[i]
|
|
break
|
|
}
|
|
}
|
|
if jaPack == nil {
|
|
t.Fatalf("ja-JP pack missing in %+v", uiPacks)
|
|
}
|
|
if jaPack.Messages["sidebarSettings"] != "設定" {
|
|
t.Fatalf("jaPack.Messages[sidebarSettings] = %q, want 設定", jaPack.Messages["sidebarSettings"])
|
|
}
|
|
if len(jaPack.Fonts) != 1 || jaPack.Fonts[0].Family != "Reims Noto JP" {
|
|
t.Fatalf("unexpected jaPack.Fonts: %+v", jaPack.Fonts)
|
|
}
|
|
if jaPack.PluginMessages["acme.snap"]["status.ok"] != "{count} 件をバックアップしました" {
|
|
t.Fatalf("unexpected PluginMessages: %+v", jaPack.PluginMessages)
|
|
}
|
|
if backendPacks[i18n.Locale("ja-JP")].Messages["tray.quit"] != "Reims-Go を終了" {
|
|
t.Fatalf("unexpected backend pack: %+v", backendPacks)
|
|
}
|
|
|
|
// Verify PluginL10nBundle merges acme.snap's own en-US fallback + ja-JP override.
|
|
bundle := mgr.PluginL10nBundle("acme.snap", i18n.Locale("ja-JP"))
|
|
if bundle["status.ok"] != "{count} 件をバックアップしました" {
|
|
t.Fatalf("PluginL10nBundle(ja-JP) = %+v", bundle)
|
|
}
|
|
|
|
// Verify LocalizePluginInfos and LocalizeMenus apply manifest overrides non-destructively.
|
|
infos := mgr.LocalizePluginInfos(mgr.Registry().List())
|
|
var snapInfo *PluginInfo
|
|
for i := range infos {
|
|
if infos[i].ID == "acme.snap" {
|
|
snapInfo = &infos[i]
|
|
break
|
|
}
|
|
}
|
|
if snapInfo == nil || snapInfo.Name.Get("ja-JP") != "スナップヘルパー" {
|
|
t.Fatalf("LocalizePluginInfos failed: %+v", snapInfo)
|
|
}
|
|
if snapInfo.Settings.Properties["keep_count"].Title.Get("ja-JP") != "保持数" {
|
|
t.Fatalf("Settings property title override failed: %+v", snapInfo.Settings.Properties["keep_count"])
|
|
}
|
|
menus := mgr.LocalizeMenus(mgr.Registry().Menus(""))
|
|
if len(menus) != 1 || menus[0].Title.Get("ja-JP") != "今すぐバックアップ" {
|
|
t.Fatalf("LocalizeMenus failed: %+v", menus)
|
|
}
|
|
|
|
// Verify LoadStaticLocalePacks (< 2ms CLI path) loads native.json without starting Manager.
|
|
staticPacks := LoadStaticLocalePacks(dataRoot)
|
|
defer i18n.SetPluginCatalogs(nil)
|
|
if got := i18n.T(i18n.Locale("ja-JP"), "tray.quit"); got != "Reims-Go を終了" {
|
|
t.Fatalf("LoadStaticLocalePacks i18n.T(ja-JP, tray.quit) = %q, staticPacks=%+v", got, staticPacks)
|
|
}
|
|
}
|
|
|
|
func TestSecurityAndGhostLocaleRegressions(t *testing.T) {
|
|
dataRoot := t.TempDir()
|
|
|
|
// H-3: A functional plugin shipping locales/de-DE.json (Track B) without contributes.locales (Track A)
|
|
// must NOT mark HasUIMessages=true, while still serving its own German L10n bundle.
|
|
funcDir := filepath.Join(t.TempDir(), "acme.german-tool")
|
|
if err := os.MkdirAll(filepath.Join(funcDir, "locales"), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
manifest := `{
|
|
"schema": 1,
|
|
"id": "acme.german-tool",
|
|
"version": "1.0.0",
|
|
"name": {"en-US": "German Tool"},
|
|
"description": {"en-US": "Ships plugin-scoped de-DE strings"},
|
|
"l10n": "locales"
|
|
}`
|
|
if err := os.WriteFile(filepath.Join(funcDir, "plugin.json"), []byte(manifest), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(filepath.Join(funcDir, "locales", "en-US.json"), []byte(`{"btn.run":"Run"}`), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(filepath.Join(funcDir, "locales", "de-DE.json"), []byte(`{"btn.run":"Ausführen"}`), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
// Also prepare an oversized > 2 MiB SVG inside funcDir to verify M-4 AssetServer cap.
|
|
bigSVG := `<svg xmlns="http://www.w3.org/2000/svg"><!--` + strings.Repeat("A", (2<<20)+1024) + `--></svg>`
|
|
if err := os.WriteFile(filepath.Join(funcDir, "huge.svg"), []byte(bigSVG), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
mgr, err := NewManager(ManagerOptions{DataRoot: dataRoot, HostVersion: "0.2.8"})
|
|
if err != nil {
|
|
t.Fatalf("NewManager: %v", err)
|
|
}
|
|
defer mgr.Close()
|
|
|
|
if _, err := mgr.LinkDev(context.Background(), funcDir); err != nil {
|
|
t.Fatalf("LinkDev: %v", err)
|
|
}
|
|
if err := mgr.Enable(context.Background(), "acme.german-tool", false); err != nil {
|
|
t.Fatalf("Enable: %v", err)
|
|
}
|
|
|
|
uiPacks, _ := mgr.ResolvedLocalePacks()
|
|
var dePack *ResolvedLocalePack
|
|
for i := range uiPacks {
|
|
if uiPacks[i].Locale == "de-DE" {
|
|
dePack = &uiPacks[i]
|
|
break
|
|
}
|
|
}
|
|
if dePack == nil {
|
|
t.Fatalf("expected de-DE plugin L10n entry in uiPacks, got %+v", uiPacks)
|
|
}
|
|
if dePack.HasUIMessages {
|
|
t.Fatalf("expected HasUIMessages=false for functional plugin without Track A host UI messages")
|
|
}
|
|
if got := mgr.PluginL10nBundle("acme.german-tool", i18n.Locale("de-DE"))["btn.run"]; got != "Ausführen" {
|
|
t.Fatalf("PluginL10nBundle(de-DE) = %q, want Ausführen", got)
|
|
}
|
|
|
|
// M-2: LinkDev must reject a dev plugin directory with an invalid font magic header.
|
|
badDevDir := filepath.Join(t.TempDir(), "bad.font.pack")
|
|
if err := os.MkdirAll(filepath.Join(badDevDir, "fonts"), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
badManifest := `{
|
|
"schema": 1,
|
|
"id": "bad.font.pack",
|
|
"version": "1.0.0",
|
|
"name": {"en-US": "Bad Font"},
|
|
"contributes": {
|
|
"locales": [{"locale": "fr-FR", "label": "Français", "fonts": [{"family": "Bad", "file": "fonts/bad.woff2"}]}]
|
|
}
|
|
}`
|
|
if err := os.WriteFile(filepath.Join(badDevDir, "plugin.json"), []byte(badManifest), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(filepath.Join(badDevDir, "fonts", "bad.woff2"), []byte("NOT_WOFF2"), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, err := mgr.LinkDev(context.Background(), badDevDir); err == nil {
|
|
t.Fatal("expected LinkDev to reject invalid WOFF2 magic header")
|
|
}
|
|
|
|
// M-3: Broker.AllowRate enforces 120 req/s per active plugin.
|
|
for i := 0; i < 120; i++ {
|
|
if err := mgr.Broker().AllowRate("acme.german-tool"); err != nil {
|
|
t.Fatalf("AllowRate call %d failed unexpectedly: %v", i+1, err)
|
|
}
|
|
}
|
|
if err := mgr.Broker().AllowRate("acme.german-tool"); err == nil {
|
|
t.Fatal("expected 121st AllowRate call within 1s window to be rate-limited")
|
|
}
|
|
|
|
// M-4: AssetServer rejects > 2 MiB SVG with 413 and path traversal with 400/403.
|
|
reqOversized := httptest.NewRequest(http.MethodGet, mgr.Assets().AssetURL("acme.german-tool", "huge.svg"), nil)
|
|
recOversized := httptest.NewRecorder()
|
|
mgr.Assets().ServeHTTP(recOversized, reqOversized)
|
|
if recOversized.Code != http.StatusRequestEntityTooLarge {
|
|
t.Fatalf("expected 413 for >2MiB SVG, got %d", recOversized.Code)
|
|
}
|
|
|
|
rawTraversalURL := "/plugin-assets/" + mgr.Assets().Token() + "/acme.german-tool/../secret.txt"
|
|
reqTraversal := httptest.NewRequest(http.MethodGet, rawTraversalURL, nil)
|
|
recTraversal := httptest.NewRecorder()
|
|
mgr.Assets().ServeHTTP(recTraversal, reqTraversal)
|
|
if recTraversal.Code != http.StatusBadRequest && recTraversal.Code != http.StatusForbidden {
|
|
t.Fatalf("expected 400/403 for traversal, got %d", recTraversal.Code)
|
|
}
|
|
}
|
|
|