package xmltransformer import ( "testing" "github.com/DefangLabs/secret-detector/pkg/transformers/tests" ) var testCases = []tests.TestCase{ {"illegal xml - empty input", "", nil}, {"illegal xml - simple string", "hello world", nil}, {"illegal xml - double quoted string", `"hello world"`, nil}, {"illegal xml - single quoted string", `'hello world'`, nil}, {"illegal xml - missing open bracket", ``, nil}, {"illegal xml - missing close tag", ``, nil}, {"illegal xml - missing tag name", ``, nil}, {"illegal xml - tag mismatch", ``, nil}, {"illegal xml - wrong brackets", `{tag /}`, nil}, {"illegal xml - missing value quotes", ``, nil}, {"illegal xml - unescaped characters", ``, nil}, {"illegal xml - attr in close tag", ``, nil}, {"empty element tag with no data", ``, map[string]string{}}, {"empty element tag with attributes", ``, map[string]string{"tag[a1]": "v1"}}, {"tag with no data", ``, map[string]string{}}, {"tag with attributes", ``, map[string]string{"tag[a1]": "v1"}}, {"tag with element", `e`, map[string]string{"tag": "e"}}, {"tag with attributes and element", `e`, map[string]string{"tag": "e", "tag[a1]": "v1"}}, {"nested tags", ` e1 `, map[string]string{ "t1": "e1", "t1[a1]": "v1", "t1.t2[a2]": "v2", "t1.t3.t4[a4_1]": "v4_1", "t1.t3.t4[a4_2]": "v4_2", }}, {"ignore comments, directives and instructions", ` e2 `, map[string]string{"t1.t2": "e2"}}, {"ignore whitespace", "\n\n\n\t\te\t\n\n\n", map[string]string{"t": "e"}}, {"handle CR/LF", "\r\n\te\r\n", map[string]string{"t": "e"}}, {"escape characters", `<&>`, map[string]string{"t[a]": `"v"`, "t": "<&>"}}, {"split element body", `helloworld`, map[string]string{"t1": "hello", "t1 (ln. 2)": "world"}}, {"duplicate elements", ` e2 `, map[string]string{"r.t[a]": "v0", "r.t~1[a]": "v1", "r.t~2[a]": "v2", "r.t~2": "e2"}}, {"duplicate attributes", ``, map[string]string{"t[a]": "v0", "t[a~1]": "v1"}}, } var xmlTransformer = NewTransformer() func TestTransform(t *testing.T) { tests.TestTransform(t, xmlTransformer, testCases) }