MCPcopy Index your code
hub / github.com/cli/cli / TestPathTraversalErrorMessage

Function TestPathTraversalErrorMessage

internal/safepaths/absolute_test.go:102–111  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

100}
101
102func TestPathTraversalErrorMessage(t *testing.T) {
103 t.Parallel()
104
105 pathTraversalError := safepaths.PathTraversalError{
106 Base: mustParseAbsolute("/base"),
107 Elems: []string{".."},
108 }
109 expectedMsg := fmt.Sprintf("joining %s and %s would be a traversal", filepath.Join(rootDir(), "base"), "..")
110 require.EqualError(t, pathTraversalError, expectedMsg)
111}
112
113func mustParseAbsolute(s string) safepaths.Absolute {
114 t, err := safepaths.ParseAbsolute(s)

Callers

nothing calls this directly

Calls 3

mustParseAbsoluteFunction · 0.85
rootDirFunction · 0.85
JoinMethod · 0.80

Tested by

no test coverage detected