MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / TestRewriteSchemes

Function TestRewriteSchemes

pkg/webui/csp_test.go:59–93  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

57}
58
59func TestRewriteSchemes(t *testing.T) {
60 t.Parallel()
61 for _, tc := range []struct {
62 name string
63 baseURLs []string
64 rewrites map[string]string
65 expected []string
66 }{
67 {
68 name: "no match",
69 baseURLs: []string{"https://foo.example.com", "https://bar.example.com"},
70 rewrites: map[string]string{
71 "http": "ws",
72 },
73 expected: []string{"https://foo.example.com", "https://bar.example.com"},
74 },
75 {
76 name: "match",
77 baseURLs: []string{"https://foo.example.com", "https://bar.example.com"},
78 rewrites: map[string]string{
79 "https": "wss",
80 },
81 expected: []string{
82 "https://foo.example.com", "wss://foo.example.com", "https://bar.example.com", "wss://bar.example.com",
83 },
84 },
85 } {
86 t.Run(tc.name, func(t *testing.T) {
87 t.Parallel()
88 a := assertions.New(t)
89 actual := webui.RewriteSchemes(tc.rewrites, tc.baseURLs...)
90 a.So(actual, should.Resemble, tc.expected)
91 })
92 }
93}

Callers

nothing calls this directly

Calls 3

RewriteSchemesFunction · 0.92
RunMethod · 0.65
NewMethod · 0.65

Tested by

no test coverage detected