(t *testing.T)
| 1713 | } |
| 1714 | |
| 1715 | func TestNewRequest_pathTraversal(t *testing.T) { |
| 1716 | t.Parallel() |
| 1717 | c := mustNewClient(t) |
| 1718 | |
| 1719 | tests := []struct { |
| 1720 | urlStr string |
| 1721 | wantError bool |
| 1722 | }{ |
| 1723 | {"repos/o/r/readme", false}, |
| 1724 | {"repos/o/r/contents/file..txt", false}, |
| 1725 | {"repos/x/../../../admin/users", true}, |
| 1726 | {"repos/../admin", true}, |
| 1727 | } |
| 1728 | for _, tt := range tests { |
| 1729 | _, err := c.NewRequest(t.Context(), "GET", tt.urlStr, nil) |
| 1730 | if tt.wantError && !errors.Is(err, ErrPathForbidden) { |
| 1731 | t.Errorf("NewRequest(%q): want ErrPathForbidden, got %v", tt.urlStr, err) |
| 1732 | } else if !tt.wantError && err != nil { |
| 1733 | t.Errorf("NewRequest(%q): unexpected error: %v", tt.urlStr, err) |
| 1734 | } |
| 1735 | } |
| 1736 | } |
| 1737 | |
| 1738 | func TestNewFormRequest_pathTraversal(t *testing.T) { |
| 1739 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…