From 4e0ee4dd3d5083bac0613a6bd412d09789bc293f Mon Sep 17 00:00:00 2001 From: Aaron Piotrowski Date: Sun, 22 Oct 2023 09:35:18 -0500 Subject: [PATCH] Generate accept header from request key --- test/WebsocketTest.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/WebsocketTest.php b/test/WebsocketTest.php index d997c10..9e7583c 100644 --- a/test/WebsocketTest.php +++ b/test/WebsocketTest.php @@ -21,6 +21,8 @@ use Psr\Log\NullLogger; use Revolt\EventLoop; use function Amp\delay; +use function Amp\Websocket\generateAcceptFromKey; +use function Amp\Websocket\generateKey; class WebsocketTest extends AsyncTestCase { @@ -145,7 +147,7 @@ public function createRequest(): Request { $headers = [ "host" => ["localhost"], - "sec-websocket-key" => ["x3JJHMbDL1EzLkh9GBhXDw=="], + "sec-websocket-key" => [generateKey()], "sec-websocket-version" => ["13"], "upgrade" => ["websocket"], "connection" => ["upgrade"], @@ -178,7 +180,7 @@ public function provideHandshakes(): iterable [ "upgrade" => ["websocket"], "connection" => ["upgrade"], - "sec-websocket-accept" => ["HSmrc0sMlYUkAGmm5OPpG2HaGWk="], + "sec-websocket-accept" => [generateAcceptFromKey($request->getHeader('sec-websocket-key'))], ], ]; @@ -230,7 +232,7 @@ public function provideHandshakes(): iterable [ "upgrade" => ["websocket"], "connection" => ["upgrade"], - "sec-websocket-accept" => ["HSmrc0sMlYUkAGmm5OPpG2HaGWk="], + "sec-websocket-accept" => [generateAcceptFromKey($request->getHeader('sec-websocket-key'))], "sec-websocket-extensions" => ["permessage-deflate; client_max_window_bits=15"], ], ]; @@ -244,7 +246,7 @@ public function provideHandshakes(): iterable [ "upgrade" => ["websocket"], "connection" => ["upgrade"], - "sec-websocket-accept" => ["HSmrc0sMlYUkAGmm5OPpG2HaGWk="], + "sec-websocket-accept" => [generateAcceptFromKey($request->getHeader('sec-websocket-key'))], ], ]; }