(t *testing.T)
| 337 | } |
| 338 | |
| 339 | func 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 | } |
nothing calls this directly
no test coverage detected