MCPcopy Create free account
hub / github.com/containerd/nerdctl / TestFilesystemRestrictions

Function TestFilesystemRestrictions

pkg/internal/filesystem/path_test.go:29–85  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

27)
28
29func TestFilesystemRestrictions(t *testing.T) {
30 t.Parallel()
31
32 invalid := []string{
33 "/",
34 "/start",
35 "mid/dle",
36 "end/",
37 ".",
38 "..",
39 "",
40 fmt.Sprintf("A%0255s", "A"),
41 }
42
43 valid := []string{
44 fmt.Sprintf("A%0254s", "A"),
45 "test",
46 "test-hyphen",
47 ".start.dot",
48 "mid.dot",
49 "∞",
50 }
51
52 if runtime.GOOS == "windows" {
53 invalid = append(invalid, []string{
54 "\\start",
55 "mid\\dle",
56 "end\\",
57 "\\",
58 "\\.",
59 "com².whatever",
60 "lpT2",
61 "Prn.",
62 "nUl",
63 "AUX",
64 "A<A",
65 "A>A",
66 "A:A",
67 "A\"A",
68 "A|A",
69 "A?A",
70 "A*A",
71 "end.dot.",
72 "end.space ",
73 }...)
74 }
75
76 for _, v := range invalid {
77 err := filesystem.ValidatePathComponent(v)
78 assert.ErrorIs(t, err, filesystem.ErrInvalidPath, v)
79 }
80
81 for _, v := range valid {
82 err := filesystem.ValidatePathComponent(v)
83 assert.NilError(t, err, v)
84 }
85}

Callers

nothing calls this directly

Calls 1

ValidatePathComponentFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…