(t *testing.T)
| 211 | } |
| 212 | |
| 213 | func TestFunkyDocAndAttachmentIDs(t *testing.T) { |
| 214 | rt := NewRestTester(t, &RestTesterConfig{GuestEnabled: true}) |
| 215 | defer rt.Close() |
| 216 | |
| 217 | attachmentBody := "this is the body of attachment" |
| 218 | attachmentContentType := "content/type" |
| 219 | |
| 220 | // assertResponse asserts that the specified attachment exists in the response body. |
| 221 | assertResponse := func(response *TestResponse, attachmentBody string) { |
| 222 | RequireStatus(t, response, http.StatusOK) |
| 223 | require.Equal(t, attachmentBody, response.Body.String()) |
| 224 | require.Empty(t, response.Header().Get("Content-Disposition")) |
| 225 | require.Equal(t, attachmentContentType, response.Header().Get("Content-Type")) |
| 226 | } |
| 227 | testCases := []struct { |
| 228 | name string |
| 229 | docID string |
| 230 | }{ |
| 231 | { |
| 232 | name: "simple", |
| 233 | docID: "doc1", |
| 234 | }, |
| 235 | { |
| 236 | name: "single embedded '/'", |
| 237 | docID: "AC%2FDC", |
| 238 | }, |
| 239 | { |
| 240 | name: "embedded '+'", |
| 241 | docID: "AC%2BDC%2BGC2", |
| 242 | }, |
| 243 | } |
| 244 | for _, testCase := range testCases { |
| 245 | rt.Run(testCase.name, func(t *testing.T) { |
| 246 | |
| 247 | version := rt.CreateTestDoc(testCase.docID) |
| 248 | |
| 249 | // Add attachment with single embedded '/' (%2F HEX) |
| 250 | version = rt.storeAttachment(testCase.docID, version, "attachpath%2Fattachment.txt", attachmentBody) |
| 251 | |
| 252 | // Retrieve attachment |
| 253 | response := rt.SendRequest(http.MethodGet, "/{{.keyspace}}/doc1/attachpath%2Fattachment.txt", "") |
| 254 | assertResponse(response, attachmentBody) |
| 255 | |
| 256 | // Add attachment with two embedded '/' (%2F HEX) |
| 257 | _ = rt.storeAttachment(testCase.docID, version, "attachpath%2Fattachpath2%2Fattachment.txt", attachmentBody) |
| 258 | |
| 259 | // Retrieve attachment |
| 260 | response = rt.SendRequest(http.MethodGet, "/{{.keyspace}}/doc1/attachpath%2Fattachpath2%2Fattachment.txt", "") |
| 261 | assertResponse(response, attachmentBody) |
| 262 | }) |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | func TestManualAttachment(t *testing.T) { |
| 267 | rt := NewRestTester(t, &RestTesterConfig{GuestEnabled: true}) |
nothing calls this directly
no test coverage detected