...
1 package authproxy
2
3 import (
4 "testing"
5
6 "github.com/stretchr/testify/assert"
7 )
8
9 func TestAllowedOrigins(t *testing.T) {
10 testCases := []struct {
11 title string
12 cfg *ProxyConfig
13 expected int
14 }{
15 {
16 title: "Test Case 1",
17 cfg: &ProxyConfig{
18 AllowedOrigins: "http://localhost:3000,https://*.edge-preprod.dev",
19 },
20 expected: 2,
21 },
22 {
23 title: "Test Case 2",
24 cfg: &ProxyConfig{
25 AllowedOrigins: "",
26 },
27 expected: 1,
28 },
29 {
30 title: "Test Case 3",
31 cfg: &ProxyConfig{
32 AllowedOrigins: "http://localhost:3000,https://*.edge-preprod.dev,https://google.com",
33 },
34 expected: 3,
35 },
36 }
37 for _, testCase := range testCases {
38 t.Run(testCase.title, func(t *testing.T) {
39 assert.Equal(t, len(testCase.cfg.allowedOrigins()), testCase.expected)
40 })
41 }
42 }
43
View as plain text