Skip to content

Commit

Permalink
[test] Do not use a relative URL
Browse files Browse the repository at this point in the history
Use different username and password in the redirect URL.
  • Loading branch information
lpinca committed Mar 24, 2022
1 parent dd3d5a7 commit ff80d66
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/websocket.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,10 @@ describe('WebSocket', () => {
const authorization = 'Basic Zm9vOmJhcg==';

server.once('upgrade', (req, socket) => {
socket.end('HTTP/1.1 302 Found\r\nLocation: /foo\r\n\r\n');
socket.end(
'HTTP/1.1 302 Found\r\n' +
`Location: ws://baz:qux@localhost:${port}/foo\r\n\r\n`
);
server.once('upgrade', (req, socket, head) => {
wss.handleUpgrade(req, socket, head, (ws, req) => {
assert.strictEqual(req.headers.authorization, authorization);
Expand All @@ -1164,7 +1167,7 @@ describe('WebSocket', () => {

ws.on('close', (code) => {
assert.strictEqual(code, 1005);
assert.strictEqual(ws.url, `ws://foo:bar@localhost:${port}/foo`);
assert.strictEqual(ws.url, `ws://baz:qux@localhost:${port}/foo`);
assert.strictEqual(ws._redirects, 1);

wss.close(done);
Expand Down

0 comments on commit ff80d66

Please sign in to comment.