Skip to content

Commit 39951d5

Browse files
resolves http-party#882
Fixes style issues w/ original http-party#882 additions.
1 parent 626cba7 commit 39951d5

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

test/lib-http-proxy-passes-ws-incoming-test.js

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
var httpProxy = require('../lib/http-proxy/passes/ws-incoming'),
1+
var wsPasses = require('../lib/http-proxy/passes/ws-incoming'),
22
expect = require('expect.js'),
33
http = require('http'),
4-
httpProxyLib = require('../lib/http-proxy');
4+
httpProxy = require('../lib/http-proxy');
55

66
describe('lib/http-proxy/passes/ws-incoming.js', function () {
77
describe('#checkMethodAndHeader', function () {
@@ -17,7 +17,7 @@ describe('lib/http-proxy/passes/ws-incoming.js', function () {
1717
destroyCalled = true;
1818
}
1919
}
20-
returnValue = httpProxy.checkMethodAndHeader(stubRequest, stubSocket);
20+
returnValue = wsPasses.checkMethodAndHeader(stubRequest, stubSocket);
2121
expect(returnValue).to.be(true);
2222
expect(destroyCalled).to.be(true);
2323
})
@@ -34,7 +34,7 @@ describe('lib/http-proxy/passes/ws-incoming.js', function () {
3434
destroyCalled = true;
3535
}
3636
}
37-
returnValue = httpProxy.checkMethodAndHeader(stubRequest, stubSocket);
37+
returnValue = wsPasses.checkMethodAndHeader(stubRequest, stubSocket);
3838
expect(returnValue).to.be(true);
3939
expect(destroyCalled).to.be(true);
4040
})
@@ -53,7 +53,7 @@ describe('lib/http-proxy/passes/ws-incoming.js', function () {
5353
destroyCalled = true;
5454
}
5555
}
56-
returnValue = httpProxy.checkMethodAndHeader(stubRequest, stubSocket);
56+
returnValue = wsPasses.checkMethodAndHeader(stubRequest, stubSocket);
5757
expect(returnValue).to.be(true);
5858
expect(destroyCalled).to.be(true);
5959
})
@@ -72,14 +72,13 @@ describe('lib/http-proxy/passes/ws-incoming.js', function () {
7272
destroyCalled = true;
7373
}
7474
}
75-
returnValue = httpProxy.checkMethodAndHeader(stubRequest, stubSocket);
75+
returnValue = wsPasses.checkMethodAndHeader(stubRequest, stubSocket);
7676
expect(returnValue).to.be(undefined);
7777
expect(destroyCalled).to.be(false);
7878
})
7979

80-
8180
it('should detect a proxyWsReq event and modify headers', function (done) {
82-
var proxy = httpProxyLib.createProxyServer({
81+
var proxy = httpProxy.createProxyServer({
8382
target: 'http://127.0.0.1:8080',
8483
ws: true
8584
});
@@ -95,18 +94,18 @@ describe('lib/http-proxy/passes/ws-incoming.js', function () {
9594
var proxyServer = http.createServer(requestHandler);
9695

9796
proxyServer.on('upgrade', function(req, res, head){
98-
proxy.ws(req, res, head);
97+
proxy.ws(req, res, head);
9998
});
10099

101100
var source = http.createServer(function(req, res) {
102-
res.end();
101+
res.end();
103102
});
104103

105104
source.on('upgrade', function(req, res, head){
106-
expect(req.headers['x-special-proxy-header']).to.eql('foobar');
107-
source.close();
108-
proxyServer.close();
109-
done();
105+
expect(req.headers['x-special-proxy-header']).to.eql('foobar');
106+
source.close();
107+
proxyServer.close();
108+
done();
110109
});
111110

112111
source.on('error', function(){});
@@ -122,11 +121,11 @@ describe('lib/http-proxy/passes/ws-incoming.js', function () {
122121
method: 'GET',
123122
path: '/',
124123
headers: {
125-
'upgrade': 'websocket',
126-
'connection': 'Upgrade',
127-
'sec-websocket-key': 'dGhlIHNhbXBsZSBub25jZQ==',
128-
'sec-websocket-protocol': 'chat, superchat',
129-
'sec-websocket-version': 13
124+
'upgrade': 'websocket',
125+
'connection': 'Upgrade',
126+
'sec-websocket-key': 'dGhlIHNhbXBsZSBub25jZQ==',
127+
'sec-websocket-protocol': 'chat, superchat',
128+
'sec-websocket-version': 13
130129
}
131130
}, function() {});
132131
request.on('error', function(){});
@@ -136,7 +135,7 @@ describe('lib/http-proxy/passes/ws-incoming.js', function () {
136135

137136
describe('#XHeaders', function () {
138137
it('return if no forward request', function () {
139-
var returnValue = httpProxy.XHeaders({}, {}, {});
138+
var returnValue = wsPasses.XHeaders({}, {}, {});
140139
expect(returnValue).to.be(undefined);
141140
});
142141

@@ -149,8 +148,8 @@ describe('lib/http-proxy/passes/ws-incoming.js', function () {
149148
headers: {
150149
host: '192.168.1.2:8080'
151150
}
152-
}
153-
httpProxy.XHeaders(stubRequest, {}, { xfwd: true });
151+
};
152+
wsPasses.XHeaders(stubRequest, {}, { xfwd: true });
154153
expect(stubRequest.headers['x-forwarded-for']).to.be('192.168.1.2');
155154
expect(stubRequest.headers['x-forwarded-port']).to.be('8080');
156155
expect(stubRequest.headers['x-forwarded-proto']).to.be('ws');
@@ -169,7 +168,7 @@ describe('lib/http-proxy/passes/ws-incoming.js', function () {
169168
host: '192.168.1.3:8181'
170169
}
171170
};
172-
httpProxy.XHeaders(stubRequest, {}, { xfwd: true });
171+
wsPasses.XHeaders(stubRequest, {}, { xfwd: true });
173172
expect(stubRequest.headers['x-forwarded-for']).to.be('192.168.1.3');
174173
expect(stubRequest.headers['x-forwarded-port']).to.be('8181');
175174
expect(stubRequest.headers['x-forwarded-proto']).to.be('wss');

0 commit comments

Comments
 (0)