(t *testing.T)
| 520 | } |
| 521 | |
| 522 | func TestValidateAndSanitizeRequest(t *testing.T) { |
| 523 | tests := []struct { |
| 524 | httpReq *http.Request |
| 525 | queryMode string |
| 526 | startTime int64 |
| 527 | endTime int64 |
| 528 | blockStart string |
| 529 | blockEnd string |
| 530 | expectedError string |
| 531 | }{ |
| 532 | { |
| 533 | httpReq: httptest.NewRequest("GET", "/api/traces/1234?blockEnd=ffffffffffffffffffffffffffffffff&blockStart=00000000000000000000000000000000&mode=blocks&start=1&end=2", nil), |
| 534 | queryMode: "blocks", |
| 535 | startTime: 1, |
| 536 | endTime: 2, |
| 537 | blockStart: "00000000000000000000000000000000", |
| 538 | blockEnd: "ffffffffffffffffffffffffffffffff", |
| 539 | }, |
| 540 | { |
| 541 | httpReq: httptest.NewRequest("GET", "/api/traces/1234?blockEnd=ffffffffffffffffffffffffffffffff&blockStart=00000000000000000000000000000000&mode=blocks", nil), |
| 542 | queryMode: "blocks", |
| 543 | startTime: 0, |
| 544 | endTime: 0, |
| 545 | blockStart: "00000000000000000000000000000000", |
| 546 | blockEnd: "ffffffffffffffffffffffffffffffff", |
| 547 | }, |
| 548 | { |
| 549 | httpReq: httptest.NewRequest("GET", "/api/traces/1234?mode=blocks", nil), |
| 550 | queryMode: "blocks", |
| 551 | startTime: 0, |
| 552 | endTime: 0, |
| 553 | blockStart: "00000000-0000-0000-0000-000000000000", |
| 554 | blockEnd: "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF", |
| 555 | }, |
| 556 | { |
| 557 | httpReq: httptest.NewRequest("GET", "/api/traces/1234?mode=blocks&blockStart=12345678000000001235000001240000&blockEnd=ffffffffffffffffffffffffffffffff", nil), |
| 558 | queryMode: "blocks", |
| 559 | startTime: 0, |
| 560 | endTime: 0, |
| 561 | blockStart: "12345678000000001235000001240000", |
| 562 | blockEnd: "ffffffffffffffffffffffffffffffff", |
| 563 | }, |
| 564 | { |
| 565 | httpReq: httptest.NewRequest("GET", "/api/traces/1234?mode=blocks&blockStart=12345678000000001235000001240000&blockEnd=ffffffffffffffffffffffffffffffff&rf1After=1970-01-01T01:16:40Z", nil), |
| 566 | queryMode: "blocks", |
| 567 | startTime: 0, |
| 568 | endTime: 0, |
| 569 | blockStart: "12345678000000001235000001240000", |
| 570 | blockEnd: "ffffffffffffffffffffffffffffffff", |
| 571 | }, |
| 572 | { |
| 573 | httpReq: httptest.NewRequest("GET", "/api/traces/1234?mode=blocks&blockStart=12345678000000001235000001240000&blockEnd=ffffffffffffffffffffffffffffffff&start=1&end=1", nil), |
| 574 | queryMode: "blocks", |
| 575 | startTime: 0, |
| 576 | endTime: 0, |
| 577 | blockStart: "12345678000000001235000001240000", |
| 578 | blockEnd: "ffffffffffffffffffffffffffffffff", |
| 579 | expectedError: "http parameter start must be before end. received start=1 end=1", |
nothing calls this directly
no test coverage detected