summaryrefslogtreecommitdiff
path: root/internal/api/client/streaming/streaming_test.go
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2023-11-28 11:05:07 +0000
committerLibravatar GitHub <noreply@github.com>2023-11-28 11:05:07 +0000
commit2eb8b8eeb41384dbf34989d7a850b4d498d90064 (patch)
tree132bd8b2504744945a5af0808782b43163044f69 /internal/api/client/streaming/streaming_test.go
parent[bugfix] Don't copy ptr fields in caches (#2386) (diff)
downloadgotosocial-2eb8b8eeb41384dbf34989d7a850b4d498d90064.tar.xz
[chore]: Bump github.com/gorilla/websocket from 1.5.0 to 1.5.1 (#2335)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/api/client/streaming/streaming_test.go')
-rw-r--r--internal/api/client/streaming/streaming_test.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/internal/api/client/streaming/streaming_test.go b/internal/api/client/streaming/streaming_test.go
index 30574080e..df4009890 100644
--- a/internal/api/client/streaming/streaming_test.go
+++ b/internal/api/client/streaming/streaming_test.go
@@ -19,6 +19,7 @@ package streaming_test
import (
"bufio"
+ "encoding/base64"
"errors"
"fmt"
"io/ioutil"
@@ -227,17 +228,21 @@ func (suite *StreamingTestSuite) TestSecurityHeader() {
ctx.Request.Header.Set("Connection", "upgrade")
ctx.Request.Header.Set("Upgrade", "websocket")
ctx.Request.Header.Set("Sec-Websocket-Version", "13")
- ctx.Request.Header.Set("Sec-Websocket-Key", "abcd")
+ key := [16]byte{'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd'}
+ key64 := base64.StdEncoding.EncodeToString(key[:]) // sec-websocket-key must be base64 encoded and 16 bytes long
+ ctx.Request.Header.Set("Sec-Websocket-Key", key64)
suite.streamingModule.StreamGETHandler(ctx)
- // check response
- suite.EqualValues(http.StatusOK, recorder.Code)
-
result := recorder.Result()
defer result.Body.Close()
- _, err := ioutil.ReadAll(result.Body)
+ b, err := ioutil.ReadAll(result.Body)
suite.NoError(err)
+
+ // check response
+ if !suite.EqualValues(http.StatusOK, recorder.Code) {
+ suite.T().Logf("%s", b)
+ }
}
func TestStreamingTestSuite(t *testing.T) {