MCPcopy
hub / github.com/gotify/server / Test_isAllowedOriginMatching

Function Test_isAllowedOriginMatching

api/stream/stream_test.go:464–477  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

462}
463
464func Test_isAllowedOriginMatching(t *testing.T) {
465 mode.Set(mode.Prod)
466 compiledAllowedOrigins := compileAllowedWebSocketOrigins([]string{"go.{4}\\.example\\.com", "go\\.example\\.com"})
467
468 req := httptest.NewRequest("GET", "http://example.me/stream", nil)
469 req.Header.Set("Origin", "http://gorify.example.com")
470 assert.True(t, isAllowedOrigin(req, compiledAllowedOrigins))
471
472 req.Header.Set("Origin", "http://go.example.com")
473 assert.True(t, isAllowedOrigin(req, compiledAllowedOrigins))
474
475 req.Header.Set("Origin", "http://hello.example.com")
476 assert.False(t, isAllowedOrigin(req, compiledAllowedOrigins))
477}
478
479func Test_emptyOrigin_returnsTrue(t *testing.T) {
480 mode.Set(mode.Prod)

Callers

nothing calls this directly

Calls 3

SetFunction · 0.92
isAllowedOriginFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…