MCPcopy Index your code
hub / github.com/harness/harness / TestTerminatedPathBefore

Function TestTerminatedPathBefore

app/api/middleware/encode/encode_test.go:26–97  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestTerminatedPathBefore(t *testing.T) {
27 tests := []struct {
28 name string
29 prefixes []string
30 path string
31 expectedPath string
32 expectedStatus int
33 }{
34 {
35 name: "basic terminated path",
36 prefixes: []string{"/spaces"},
37 path: "/spaces/space1/space2/+/authToken",
38 expectedPath: "/spaces/space1%2Fspace2/authToken",
39 expectedStatus: http.StatusOK,
40 },
41 {
42 name: "no matching prefix",
43 prefixes: []string{"/other"},
44 path: "/spaces/space1/space2/+/authToken",
45 expectedPath: "/spaces/space1/space2/+/authToken",
46 expectedStatus: http.StatusOK,
47 },
48 {
49 name: "multiple prefixes - first match",
50 prefixes: []string{"/spaces", "/repos"},
51 path: "/spaces/space1/space2/+/authToken",
52 expectedPath: "/spaces/space1%2Fspace2/authToken",
53 expectedStatus: http.StatusOK,
54 },
55 {
56 name: "encoded paths - no match",
57 prefixes: []string{"/spaces", "/repos"},
58 path: "/spaces/space1%2Fspace2/authToken",
59 expectedPath: "/spaces/space1%2Fspace2/authToken",
60 expectedStatus: http.StatusOK,
61 },
62 {
63 name: "encoded paths - suffix match 1",
64 prefixes: []string{"/spaces", "/repos"},
65 path: "/spaces/space1/space2/+/",
66 expectedPath: "/spaces/space1%2Fspace2/",
67 expectedStatus: http.StatusOK,
68 },
69 {
70 name: "encoded paths - suffix match 2",
71 prefixes: []string{"/spaces", "/repos"},
72 path: "/spaces/space1/space2/+",
73 expectedPath: "/spaces/space1%2Fspace2",
74 expectedStatus: http.StatusOK,
75 },
76 }
77
78 for _, tt := range tests {
79 t.Run(tt.name, func(t *testing.T) {
80 req := &http.Request{
81 Method: http.MethodGet,
82 URL: &url.URL{
83 Path: tt.path,

Callers

nothing calls this directly

Calls 4

TerminatedPathBeforeFunction · 0.85
EqualMethod · 0.80
ServeHTTPMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…