(t *testing.T)
| 530 | } |
| 531 | |
| 532 | func TestConvertAppURLForCSP(t *testing.T) { |
| 533 | t.Parallel() |
| 534 | |
| 535 | testCases := []struct { |
| 536 | name string |
| 537 | host string |
| 538 | wildcard string |
| 539 | expected string |
| 540 | }{ |
| 541 | { |
| 542 | name: "Empty", |
| 543 | host: "example.com", |
| 544 | wildcard: "", |
| 545 | expected: "example.com", |
| 546 | }, |
| 547 | { |
| 548 | name: "NoAsterisk", |
| 549 | host: "example.com", |
| 550 | wildcard: "coder.com", |
| 551 | expected: "coder.com", |
| 552 | }, |
| 553 | { |
| 554 | name: "Asterisk", |
| 555 | host: "example.com", |
| 556 | wildcard: "*.coder.com", |
| 557 | expected: "*.coder.com", |
| 558 | }, |
| 559 | { |
| 560 | name: "FirstPrefix", |
| 561 | host: "example.com", |
| 562 | wildcard: "*--apps.coder.com", |
| 563 | expected: "*.coder.com", |
| 564 | }, |
| 565 | { |
| 566 | name: "FirstSuffix", |
| 567 | host: "example.com", |
| 568 | wildcard: "apps--*.coder.com", |
| 569 | expected: "*.coder.com", |
| 570 | }, |
| 571 | { |
| 572 | name: "Middle", |
| 573 | host: "example.com", |
| 574 | wildcard: "apps.*.com", |
| 575 | expected: "example.com", |
| 576 | }, |
| 577 | } |
| 578 | |
| 579 | for _, c := range testCases { |
| 580 | t.Run(c.name, func(t *testing.T) { |
| 581 | t.Parallel() |
| 582 | require.Equal(t, c.expected, appurl.ConvertAppHostForCSP(c.host, c.wildcard)) |
| 583 | }) |
| 584 | } |
| 585 | } |
| 586 | |
| 587 | func TestURLGenerationVsParsing(t *testing.T) { |
| 588 | t.Parallel() |
nothing calls this directly
no test coverage detected