1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-09-15 17:46:55 +00:00

Use a regexp instead to match origin

This commit is contained in:
Kane York 2016-02-03 22:06:46 -08:00
parent cddd13ba16
commit bba5d8f344
2 changed files with 13 additions and 7 deletions

View file

@ -14,6 +14,8 @@ import (
"time"
)
const TestOrigin = "http://www.twitch.tv"
func TestSubscriptionAndPublish(t *testing.T) {
var doneWg sync.WaitGroup
var readyWg sync.WaitGroup
@ -54,7 +56,7 @@ func TestSubscriptionAndPublish(t *testing.T) {
var err error
var headers http.Header = make(http.Header)
headers.Set("Origin", TwitchDotTv)
headers.Set("Origin", TestOrigin)
// client 1: sub ch1, ch2
// client 2: sub ch1, ch3
@ -72,6 +74,9 @@ func TestSubscriptionAndPublish(t *testing.T) {
return
}
// both origins need testing
headers.Set("Origin", "https://www.twitch.tv")
doneWg.Add(1)
readyWg.Add(1)
go func(conn *websocket.Conn) {
@ -265,7 +270,7 @@ func TestRestrictedCommands(t *testing.T) {
var challengeChan = make(chan string)
var headers http.Header = make(http.Header)
headers.Set("Origin", TwitchDotTv)
headers.Set("Origin", TestOrigin)
// Client 1
conn, _, err = websocket.DefaultDialer.Dial(urls.Websocket, headers)
@ -366,7 +371,7 @@ func BenchmarkUserSubscriptionSinglePublish(b *testing.B) {
defer unsubscribeAllClients()
var headers http.Header = make(http.Header)
headers.Set("Origin", TwitchDotTv)
headers.Set("Origin", TestOrigin)
b.ResetTimer()
for i := 0; i < b.N; i++ {