aboutsummaryrefslogtreecommitdiff
path: root/internal/admin/correct_audit_fixes_test.go
blob: 381fb5c2b4ad7c748220300ef6fff5667241c619 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package admin

import "testing"

// Regression: the raw file API must canonicalize repeated "/" and "data/"
// prefixes, or "//players/..." reaches the real file while the classifiers
// see a non-player path and skip the redaction / online refusal.
func TestCanonicalDataRelPathStripsRepeatedPrefixes(t *testing.T) {
	cases := map[string]string{
		"players/accounts/x.yaml":           "players/accounts/x.yaml",
		"/players/accounts/x.yaml":          "players/accounts/x.yaml",
		"//players/accounts/x.yaml":         "players/accounts/x.yaml",
		"data/players/accounts/x.yaml":      "players/accounts/x.yaml",
		"data/data/players/accounts/x.yaml": "players/accounts/x.yaml",
		"../etc/passwd":                     "etc/passwd",
	}
	for in, want := range cases {
		if got := canonicalDataRelPath(in); got != want {
			t.Errorf("canonicalDataRelPath(%q) = %q, want %q", in, got, want)
		}
	}
}