MCPcopy Create free account
hub / github.com/docker/docker-agent / TestCreateRejectsUnsafeNames

Function TestCreateRejectsUnsafeNames

pkg/worktree/worktree_test.go:176–197  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

174}
175
176func TestCreateRejectsUnsafeNames(t *testing.T) {
177 t.Parallel()
178 dir := bootstrapRepo(t)
179 root := t.TempDir()
180
181 for _, name := range []string{
182 "../escape",
183 "../../etc/evil",
184 "foo/bar",
185 `foo\bar`,
186 ".",
187 "..",
188 " leading",
189 "trailing ",
190 } {
191 t.Run(name, func(t *testing.T) {
192 t.Parallel()
193 _, err := Create(t.Context(), dir, name, WithRoot(root))
194 assert.ErrorIs(t, err, ErrInvalidName)
195 })
196 }
197}
198
199func TestCreateRejectsDuplicateName(t *testing.T) {
200 t.Parallel()

Callers

nothing calls this directly

Calls 5

CreateFunction · 0.85
WithRootFunction · 0.85
ContextMethod · 0.80
bootstrapRepoFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected