MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestCVUnescapedRevQueryParam

Function TestCVUnescapedRevQueryParam

rest/doc_api_test.go:339–365  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

337}
338
339func TestCVUnescapedRevQueryParam(t *testing.T) {
340 tests := []struct {
341 revValue string
342 expectError bool
343 }{
344 {revValue: "1-abc"}, // Normal Rev ID (doesn't need escaping)
345 {revValue: "185dd4a2b4490000%404EZjEgl1AKEj8qh%2BvXS7OQ"}, // CV escaped
346 {revValue: "185dd4a2b4490000@4EZjEgl1AKEj8qh+vXS7OQ", expectError: true}, // CV unescaped
347 }
348
349 rt := NewRestTesterPersistentConfig(t)
350 defer rt.Close()
351
352 for _, test := range tests {
353 t.Run(test.revValue, func(t *testing.T) {
354 resp := rt.SendAdminRequest(http.MethodPut, "/{{.keyspace}}/testdoc?rev="+test.revValue, `{"foo":"bar"}`)
355 if test.expectError {
356 RequireStatus(t, resp, http.StatusBadRequest)
357 assert.Contains(t, resp.BodyString(), "Bad rev query parameter")
358 } else {
359 // this is "successful" since there isn't a doc that exists with that rev but the request made it through
360 RequireStatus(t, resp, http.StatusConflict)
361 assert.Contains(t, resp.BodyString(), `Document revision conflict`)
362 }
363 })
364 }
365}

Callers

nothing calls this directly

Calls 7

RequireStatusFunction · 0.85
SendAdminRequestMethod · 0.80
BodyStringMethod · 0.80
CloseMethod · 0.65
RunMethod · 0.65
ContainsMethod · 0.65

Tested by

no test coverage detected