ci: 复用部署服务器缓存并支持 HTTPS 同源登录
This commit is contained in:
@@ -23,3 +23,28 @@ func TestRejectInvalidRedisDB(t *testing.T) {
|
||||
t.Fatal("negative database must be rejected")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPublicOriginConfiguration(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
origin string
|
||||
valid bool
|
||||
}{
|
||||
{"", true},
|
||||
{"https://veyra.sundynix.cn", true},
|
||||
{"http://localhost:8080", true},
|
||||
{"https://veyra.sundynix.cn/", false},
|
||||
{"https://veyra.sundynix.cn?", false},
|
||||
{"https://veyra.sundynix.cn#", false},
|
||||
{"https://user:password@veyra.sundynix.cn", false},
|
||||
{"ftp://veyra.sundynix.cn", false},
|
||||
{"https:///missing-host", false},
|
||||
} {
|
||||
t.Run(tc.origin, func(t *testing.T) {
|
||||
t.Setenv("PUBLIC_ORIGIN", tc.origin)
|
||||
_, err := Load()
|
||||
if (err == nil) != tc.valid {
|
||||
t.Fatalf("valid=%v error=%v", tc.valid, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user