| 536 | } |
| 537 | |
| 538 | func TestEcho_StaticPanic(t *testing.T) { |
| 539 | var testCases = []struct { |
| 540 | name string |
| 541 | givenRoot string |
| 542 | }{ |
| 543 | { |
| 544 | name: "panics for ../", |
| 545 | givenRoot: "../assets", |
| 546 | }, |
| 547 | { |
| 548 | name: "panics for /", |
| 549 | givenRoot: "/assets", |
| 550 | }, |
| 551 | } |
| 552 | |
| 553 | for _, tc := range testCases { |
| 554 | t.Run(tc.name, func(t *testing.T) { |
| 555 | e := New() |
| 556 | e.Filesystem = os.DirFS("./") |
| 557 | |
| 558 | assert.Panics(t, func() { |
| 559 | e.Static("../assets", tc.givenRoot) |
| 560 | }) |
| 561 | }) |
| 562 | } |
| 563 | } |
| 564 | |
| 565 | func TestEchoStaticRedirectIndex(t *testing.T) { |
| 566 | e := New() |