MCPcopy Create free account
hub / github.com/coder/coder / TestConvertAppURLForCSP

Function TestConvertAppURLForCSP

coderd/workspaceapps/appurl/appurl_test.go:532–585  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

530}
531
532func 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
587func TestURLGenerationVsParsing(t *testing.T) {
588 t.Parallel()

Callers

nothing calls this directly

Calls 3

ConvertAppHostForCSPFunction · 0.92
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected