Skip to content

Commit 45f0cc1

Browse files
committed
Change tests using example.com to testserver.host
1 parent aaa0041 commit 45f0cc1

File tree

5 files changed

+26
-38
lines changed

5 files changed

+26
-38
lines changed

test/integration/https.spec.ts

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ describe("When configured for HTTPS", () => {
117117
keyPath: './test/fixtures/test-ca.key',
118118
certPath: './test/fixtures/test-ca.pem',
119119
tlsPassthrough: [
120-
{ hostname: 'example.com' },
120+
{ hostname: 'example.testserver.host' },
121121
// A convenient server that doesn't require SNI to serve the right cert:
122122
{ hostname: 'ip-api.com' }
123123
]
@@ -144,14 +144,12 @@ describe("When configured for HTTPS", () => {
144144
});
145145

146146
it("skips the server for matching HTTPS requests", async function () {
147-
this.retries(3); // Example.com can be unreliable
148-
149147
const response: http.IncomingMessage = await new Promise((resolve, reject) =>
150148
https.get({
151149
host: 'localhost',
152150
port: server.port,
153-
servername: 'example.com',
154-
headers: { 'Host': 'example.com' }
151+
servername: 'example.testserver.host',
152+
headers: { 'Host': 'example.testserver.host' }
155153
}).on('response', resolve).on('error', reject)
156154
);
157155

@@ -166,7 +164,7 @@ describe("When configured for HTTPS", () => {
166164
const response: http.IncomingMessage = await new Promise((resolve) =>
167165
http.get({
168166
port: server.port,
169-
headers: { 'Host': 'example.com' }
167+
headers: { 'Host': 'example.testserver.host' }
170168
}).on('response', resolve)
171169
);
172170

@@ -196,12 +194,12 @@ describe("When configured for HTTPS", () => {
196194

197195
it("bypasses Mockttp for TLS connections with matching SNI", async () => {
198196
const tlsSocket = await openRawTlsSocket(server, {
199-
servername: 'example.com'
197+
servername: 'example.testserver.host'
200198
});
201199

202200
const cert = tlsSocket.getPeerCertificate();
203-
expect(cert.subject.CN).to.equal('*.example.com');
204-
expect(cert.issuer.CN).to.include('DigiCert'); // <-- This is the real issuer, right now at least
201+
expect(cert.subject.CN).to.equal('example.testserver.host');
202+
expect(cert.issuer.CN).to.include('ZeroSSL RSA Domain Secure Site CA'); // <-- This is the real issuer, right now at least
205203
});
206204

207205
it("bypasses Mockttp for TLS connections inside matching HTTP/1 CONNECT tunnel", async () => {
@@ -227,7 +225,7 @@ describe("When configured for HTTPS", () => {
227225
it("still handles matching CONNECT-tunnelled plain-HTTP requests", async () => {
228226
const tunnel = await openRawSocket(server);
229227

230-
tunnel.write('CONNECT example.com:80 HTTP/1.1\r\n\r\n');
228+
tunnel.write('CONNECT example.testserver.host:80 HTTP/1.1\r\n\r\n');
231229

232230
await delay(50);
233231
const result = tunnel.read();
@@ -236,7 +234,7 @@ describe("When configured for HTTPS", () => {
236234
const response: http.IncomingMessage = await new Promise((resolve) =>
237235
http.get({
238236
createConnection: () => tunnel,
239-
headers: { 'Host': 'example.com' }
237+
headers: { 'Host': 'example.testserver.host' }
240238
}).on('response', resolve)
241239
);
242240

@@ -246,9 +244,7 @@ describe("When configured for HTTPS", () => {
246244
});
247245

248246
it("bypasses Mockttp for TLS connections inside matching HTTP/2 CONNECT tunnel", async function () {
249-
this.retries(3); // Example.com can be unreliable
250-
251-
const response = await http2ProxyRequest(server, 'https://example.com');
247+
const response = await http2ProxyRequest(server, 'https://example.testserver.host');
252248

253249
expect(response.body.toString()).to.include(
254250
"This domain is for use in illustrative examples in documents."
@@ -262,7 +258,7 @@ describe("When configured for HTTPS", () => {
262258
keyPath: './test/fixtures/test-ca.key',
263259
certPath: './test/fixtures/test-ca.pem',
264260
tlsPassthrough: [
265-
{ hostname: '*.com' }
261+
{ hostname: '*.testserver.host' }
266262
]
267263
}
268264
});
@@ -292,14 +288,12 @@ describe("When configured for HTTPS", () => {
292288
});
293289

294290
it("skips the server for non-matching HTTPS requests", async function () {
295-
this.retries(3); // Example.com can be unreliable
296-
297291
const response: http.IncomingMessage = await new Promise((resolve, reject) =>
298292
https.get({
299293
host: 'localhost',
300294
port: server.port,
301-
servername: 'example.com',
302-
headers: { 'Host': 'example.com' }
295+
servername: 'example.testserver.host',
296+
headers: { 'Host': 'example.testserver.host' }
303297
}).on('response', resolve).on('error', reject)
304298
);
305299

@@ -347,14 +341,12 @@ describe("When configured for HTTPS", () => {
347341
});
348342

349343
it("skips the server for non-matching HTTPS requests", async function () {
350-
this.retries(3); // Example.com can be unreliable
351-
352344
const response: http.IncomingMessage = await new Promise((resolve, reject) =>
353345
https.get({
354346
host: 'localhost',
355347
port: server.port,
356-
servername: 'example.com',
357-
headers: { 'Host': 'example.com' }
348+
servername: 'example.testserver.host',
349+
headers: { 'Host': 'example.testserver.host' }
358350
}).on('response', resolve).on('error', reject)
359351
);
360352

@@ -402,14 +394,12 @@ describe("When configured for HTTPS", () => {
402394
});
403395

404396
it("skips the server for non-matching HTTPS requests", async function () {
405-
this.retries(3); // Example.com can be unreliable
406-
407397
const response: http.IncomingMessage = await new Promise((resolve, reject) =>
408398
https.get({
409399
host: 'localhost',
410400
port: server.port,
411-
servername: 'example.com',
412-
headers: { 'Host': 'example.com' }
401+
servername: 'example.testserver.host',
402+
headers: { 'Host': 'example.testserver.host' }
413403
}).on('response', resolve).on('error', reject)
414404
);
415405

test/integration/port-configuration.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ describe("Port selection", function () {
2020
});
2121

2222
it("should use a fixed port if one is specified", async function () {
23-
this.retries(3); // Random ports can be in use, esp on Travis, so retry a little
23+
this.retries(3); // Random ports can be in use, so retry a little
2424

2525
const chosenPort = 10000 + _.random(1000);
2626
await server1.start(chosenPort);
2727
expect(server1.port).to.equal(chosenPort);
2828
});
2929

3030
it("should error if a fixed port is specified and unavailable", async function () {
31-
this.retries(3); // Random ports can be in use, esp on Travis, so retry a little
31+
this.retries(3); // Random ports can be in use, so retry a little
3232

3333
const chosenPort = 10000 + _.random(1000);
3434
await server1.start(chosenPort);

test/integration/proxying/http-proxying.spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,9 @@ nodeOnly(() => {
8989
});
9090

9191
it("should be able to pass through requests", async function () {
92-
this.retries(3); // Example.com can be unreliable
92+
await server.forGet("http://example.testserver.host/").thenPassThrough();
9393

94-
await server.forGet("http://example.com/").thenPassThrough();
95-
96-
let response = await request.get("http://example.com/");
94+
let response = await request.get("http://example.testserver.host/");
9795
expect(response).to.include(
9896
"This domain is for use in illustrative examples in documents."
9997
);

test/integration/proxying/proxy-transforms.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ nodeOnly(() => {
5454

5555
it("forwards to the location even if the port & protocol is implicit", async () => {
5656
await remoteServer.forGet('/').thenReply(200, "forwarded response");
57-
await server.forAnyRequest().thenForwardTo('example.com');
57+
await server.forAnyRequest().thenForwardTo('example.testserver.host');
5858

5959
let response = await request.get(server.urlFor("/"));
6060

test/integration/proxying/upstream-proxying.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ nodeOnly(() => {
135135
await server.forAnyRequest().thenPassThrough({
136136
proxyConfig: {
137137
proxyUrl: intermediateProxy.url,
138-
noProxy: ['example.com:80']
138+
noProxy: ['example.testserver.host:80']
139139
}
140140
});
141141

142-
await request.get('http://example.com/').catch(() => {});
142+
await request.get('http://example.testserver.host/').catch(() => {});
143143

144144
// And it didn't use the proxy
145145
expect((await proxyEndpoint.getSeenRequests()).length).to.equal(0);
@@ -176,7 +176,7 @@ nodeOnly(() => {
176176
await server.forAnyRequest().thenPassThrough({
177177
proxyConfig: {
178178
proxyUrl: intermediateProxy.url,
179-
noProxy: ['example.com']
179+
noProxy: ['example.testserver.host']
180180
}
181181
});
182182

@@ -215,7 +215,7 @@ nodeOnly(() => {
215215
await server.forAnyRequest().thenPassThrough({
216216
proxyConfig: {
217217
proxyUrl: intermediateProxy.url,
218-
noProxy: ['example.com:443']
218+
noProxy: ['example.testserver.host:443']
219219
}
220220
});
221221

0 commit comments

Comments
 (0)