(t *testing.T)
| 1655 | } |
| 1656 | |
| 1657 | func TestNewRequest_errorForNoTrailingSlash(t *testing.T) { |
| 1658 | t.Parallel() |
| 1659 | tests := []struct { |
| 1660 | rawurl string |
| 1661 | wantError bool |
| 1662 | }{ |
| 1663 | {rawurl: "https://example.com/api/v3", wantError: true}, |
| 1664 | {rawurl: "https://example.com/api/v3/", wantError: false}, |
| 1665 | } |
| 1666 | c := mustNewClient(t) |
| 1667 | for _, test := range tests { |
| 1668 | u, err := url.Parse(test.rawurl) |
| 1669 | if err != nil { |
| 1670 | t.Fatalf("url.Parse returned unexpected error: %v.", err) |
| 1671 | } |
| 1672 | c.baseURL = u |
| 1673 | if _, err := c.NewRequest(t.Context(), "GET", "test", nil); test.wantError && err == nil { |
| 1674 | t.Fatal("Expected error to be returned.") |
| 1675 | } else if !test.wantError && err != nil { |
| 1676 | t.Fatalf("NewRequest returned unexpected error: %v.", err) |
| 1677 | } |
| 1678 | } |
| 1679 | } |
| 1680 | |
| 1681 | func TestCheckURLPathTraversal(t *testing.T) { |
| 1682 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…