MCPcopy Index your code
hub / github.com/labstack/echo / TestValidateOrigins

Function TestValidateOrigins

middleware/util_test.go:105–309  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

103}
104
105func TestValidateOrigins(t *testing.T) {
106 var testCases = []struct {
107 name string
108 givenOrigins []string
109 givenWhat string
110 expectErr string
111 }{
112 // Valid cases
113 {
114 name: "ok, empty origins",
115 givenOrigins: []string{},
116 },
117 {
118 name: "ok, basic http",
119 givenOrigins: []string{"http://example.com"},
120 },
121 {
122 name: "ok, basic https",
123 givenOrigins: []string{"https://example.com"},
124 },
125 {
126 name: "ok, with port",
127 givenOrigins: []string{"http://localhost:8080"},
128 },
129 {
130 name: "ok, with subdomain",
131 givenOrigins: []string{"https://api.example.com"},
132 },
133 {
134 name: "ok, subdomain with port",
135 givenOrigins: []string{"https://api.example.com:8080"},
136 },
137 {
138 name: "ok, localhost",
139 givenOrigins: []string{"http://localhost"},
140 },
141 {
142 name: "ok, IPv4 address",
143 givenOrigins: []string{"http://192.168.1.1"},
144 },
145 {
146 name: "ok, IPv4 with port",
147 givenOrigins: []string{"http://192.168.1.1:8080"},
148 },
149 {
150 name: "ok, IPv6 loopback",
151 givenOrigins: []string{"http://[::1]"},
152 },
153 {
154 name: "ok, IPv6 with port",
155 givenOrigins: []string{"http://[::1]:8080"},
156 },
157 {
158 name: "ok, IPv6 full address",
159 givenOrigins: []string{"http://[2001:db8::1]"},
160 },
161 {
162 name: "ok, multiple valid origins",

Callers

nothing calls this directly

Calls 1

validateOriginsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…