diff options
author | Valery Piashchynski <[email protected]> | 2021-09-16 21:46:50 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2021-09-16 21:46:50 +0300 |
commit | 3581b45f237a3f7aa29591ceb2bf6f4a4642a2f5 (patch) | |
tree | e723b19ec1ac16b7ccc7b3c2da69d4a416d63d81 /plugins/websockets/origin_test.go | |
parent | 337d292dd2d6ff0a555098b1970d8194d8df8bc2 (diff) | |
parent | 823d831b57b75f70c7c3bbbee355f2016633bb3b (diff) |
[#803]: feat(plugins): move plugins to a separate repositoryv2.5.0-alpha.2
[#803]: feat(plugins): move plugins to a separate repository
Diffstat (limited to 'plugins/websockets/origin_test.go')
-rw-r--r-- | plugins/websockets/origin_test.go | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/plugins/websockets/origin_test.go b/plugins/websockets/origin_test.go deleted file mode 100644 index bbc49bbb..00000000 --- a/plugins/websockets/origin_test.go +++ /dev/null @@ -1,73 +0,0 @@ -package websockets - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestConfig_Origin(t *testing.T) { - cfg := &Config{ - AllowedOrigin: "*", - Broker: "any", - } - - err := cfg.InitDefault() - assert.NoError(t, err) - - assert.True(t, isOriginAllowed("http://some.some.some.sssome", cfg)) - assert.True(t, isOriginAllowed("http://", cfg)) - assert.True(t, isOriginAllowed("http://google.com", cfg)) - assert.True(t, isOriginAllowed("ws://*", cfg)) - assert.True(t, isOriginAllowed("*", cfg)) - assert.True(t, isOriginAllowed("you are bad programmer", cfg)) // True :( - assert.True(t, isOriginAllowed("****", cfg)) - assert.True(t, isOriginAllowed("asde!@#!!@#!%", cfg)) - assert.True(t, isOriginAllowed("http://*.domain.com", cfg)) -} - -func TestConfig_OriginWildCard(t *testing.T) { - cfg := &Config{ - AllowedOrigin: "https://*my.site.com", - Broker: "any", - } - - err := cfg.InitDefault() - assert.NoError(t, err) - - assert.True(t, isOriginAllowed("https://my.site.com", cfg)) - assert.False(t, isOriginAllowed("http://", cfg)) - assert.False(t, isOriginAllowed("http://google.com", cfg)) - assert.False(t, isOriginAllowed("ws://*", cfg)) - assert.False(t, isOriginAllowed("*", cfg)) - assert.False(t, isOriginAllowed("you are bad programmer", cfg)) // True :( - assert.False(t, isOriginAllowed("****", cfg)) - assert.False(t, isOriginAllowed("asde!@#!!@#!%", cfg)) - assert.False(t, isOriginAllowed("http://*.domain.com", cfg)) - - assert.False(t, isOriginAllowed("https://*site.com", cfg)) - assert.True(t, isOriginAllowed("https://some.my.site.com", cfg)) -} - -func TestConfig_OriginWildCard2(t *testing.T) { - cfg := &Config{ - AllowedOrigin: "https://my.*.com", - Broker: "any", - } - - err := cfg.InitDefault() - assert.NoError(t, err) - - assert.True(t, isOriginAllowed("https://my.site.com", cfg)) - assert.False(t, isOriginAllowed("http://", cfg)) - assert.False(t, isOriginAllowed("http://google.com", cfg)) - assert.False(t, isOriginAllowed("ws://*", cfg)) - assert.False(t, isOriginAllowed("*", cfg)) - assert.False(t, isOriginAllowed("you are bad programmer", cfg)) // True :( - assert.False(t, isOriginAllowed("****", cfg)) - assert.False(t, isOriginAllowed("asde!@#!!@#!%", cfg)) - assert.False(t, isOriginAllowed("http://*.domain.com", cfg)) - - assert.False(t, isOriginAllowed("https://*site.com", cfg)) - assert.True(t, isOriginAllowed("https://my.bad.com", cfg)) -} |