MCPcopy Create free account
hub / github.com/tailscale/tailscale / TestHandlePeerAPI

Function TestHandlePeerAPI

feature/taildrop/peerapi_test.go:149–536  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

147}
148
149func TestHandlePeerAPI(t *testing.T) {
150 tests := []struct {
151 name string
152 isSelf bool // the peer sending the request is owned by us
153 capSharing bool // self node has file sharing capability
154 debugCap bool // self node has debug capability
155 omitRoot bool // don't configure
156 reqs []*http.Request
157 checks []check
158 }{
159 {
160 name: "reject_non_owner_put",
161 isSelf: false,
162 capSharing: true,
163 reqs: []*http.Request{httptest.NewRequest("PUT", "/v0/put/foo", nil)},
164 checks: checks(
165 httpStatus(http.StatusForbidden),
166 bodyContains("Taildrop disabled"),
167 ),
168 },
169 {
170 name: "owner_without_cap",
171 isSelf: true,
172 capSharing: false,
173 reqs: []*http.Request{httptest.NewRequest("PUT", "/v0/put/foo", nil)},
174 checks: checks(
175 httpStatus(http.StatusForbidden),
176 bodyContains("Taildrop disabled"),
177 ),
178 },
179 {
180 name: "owner_with_cap_no_rootdir",
181 omitRoot: true,
182 isSelf: true,
183 capSharing: true,
184 reqs: []*http.Request{httptest.NewRequest("PUT", "/v0/put/foo", nil)},
185 checks: checks(
186 httpStatus(http.StatusForbidden),
187 bodyContains("Taildrop disabled"),
188 ),
189 },
190
191 {
192 name: "bad_method",
193 isSelf: true,
194 capSharing: true,
195 reqs: []*http.Request{httptest.NewRequest("POST", "/v0/put/foo", nil)},
196 checks: checks(
197 httpStatus(405),
198 bodyContains("expected method GET or PUT"),
199 ),
200 },
201 {
202 name: "put_zero_length",
203 isSelf: true,
204 capSharing: true,
205 reqs: []*http.Request{httptest.NewRequest("PUT", "/v0/put/foo", nil)},
206 checks: checks(

Callers

nothing calls this directly

Calls 15

ViewMethod · 0.95
fileHasSizeFunction · 0.85
fileHasContentsFunction · 0.85
hexAllFunction · 0.85
handlePeerPutWithBackendFunction · 0.85
DiffMethod · 0.80
InfoMethod · 0.80
ModeMethod · 0.80
checksFunction · 0.70
httpStatusFunction · 0.70
bodyContainsFunction · 0.70
FatalfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…