MCPcopy Index your code
hub / github.com/devspace-sh/devspace / TestCheckOrigin

Function TestCheckOrigin

pkg/devspace/server/logs_test.go:10–33  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestCheckOrigin(t *testing.T) {
11 cases := map[string]struct {
12 origin string
13 want bool
14 }{
15 "no origin header (CLI/curl)": {origin: "", want: true},
16 "localhost origin": {origin: "http://localhost:8080", want: true},
17 "127.0.0.1 origin": {origin: "http://127.0.0.1:3000", want: true},
18 "localhost no port": {origin: "http://localhost", want: true},
19 "external origin": {origin: "http://bad.example.com", want: false},
20 "invalid origin": {origin: "://bad-url", want: false},
21 }
22
23 for name, tc := range cases {
24 t.Run(name, func(t *testing.T) {
25 r := &http.Request{Header: http.Header{}}
26 if tc.origin != "" {
27 r.Header.Set("Origin", tc.origin)
28 }
29 got := upgrader.CheckOrigin(r)
30 assert.Equal(t, tc.want, got, name)
31 })
32 }
33}

Callers

nothing calls this directly

Calls 3

EqualMethod · 0.80
RunMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected