2018-05-01 23:45:06 +00:00
|
|
|
package websocket
|
|
|
|
|
|
|
|
import (
|
2018-09-21 15:18:23 +00:00
|
|
|
"testing"
|
2021-03-09 15:57:04 +00:00
|
|
|
|
2018-09-21 15:18:23 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
2018-05-01 23:45:06 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2018-09-21 15:18:23 +00:00
|
|
|
// example in Sec-Websocket-Key in rfc6455
|
|
|
|
testSecWebsocketKey = "dGhlIHNhbXBsZSBub25jZQ=="
|
|
|
|
// example Sec-Websocket-Accept in rfc6455
|
|
|
|
testSecWebsocketAccept = "s3pPLMBiTxaQ9kYGzzhZRbK+xOo="
|
2018-05-01 23:45:06 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestGenerateAcceptKey(t *testing.T) {
|
2021-04-02 06:10:43 +00:00
|
|
|
assert.Equal(t, testSecWebsocketAccept, generateAcceptKey(testSecWebsocketKey))
|
2021-03-09 15:57:04 +00:00
|
|
|
}
|