Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into upgrade-xmldom
- Loading branch information
Showing
19 changed files
with
14,122 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,7 +88,7 @@ jobs: | |
|
||
mac: | ||
macos: | ||
xcode: 11.3.0 | ||
xcode: 12.5.1 | ||
steps: | ||
- checkout | ||
- run: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'), | ||
api = require('../../api').create(), | ||
BaseHttpClient = require('../../baseHttpClient'), | ||
port = api.port + 1, | ||
timeout = parseInt(process.env.MB_SLOW_TEST_TIMEOUT || 2000); | ||
|
||
['http', 'https'].forEach(protocol => { | ||
const client = BaseHttpClient.create(protocol); | ||
|
||
describe(`${protocol} imposter`, function () { | ||
this.timeout(timeout); | ||
|
||
afterEach(async function () { | ||
await api.del('/imposters'); | ||
}); | ||
|
||
describe('POST /imposters with stubs', function () { | ||
it('should drop the connection when fault CONNECTION_RESET_BY_PEER is specified', async function () { | ||
const stub = { responses: [{ fault: 'CONNECTION_RESET_BY_PEER' }] }, | ||
request = { protocol, port, stubs: [stub] }; | ||
await api.createImposter(request); | ||
|
||
try { | ||
await client.get('/', port); | ||
assert.fail('did not close socket'); | ||
} | ||
catch (error) { | ||
assert.strictEqual(error.code, 'ECONNRESET'); | ||
} | ||
}); | ||
|
||
it('should write garbage then drop the connection when fault RANDOM_DATA_THEN_CLOSE is specified', async function () { | ||
const stub = { responses: [{ fault: 'RANDOM_DATA_THEN_CLOSE' }] }, | ||
request = { protocol, port, stubs: [stub] }; | ||
await api.createImposter(request); | ||
|
||
try { | ||
await client.get('/', port); | ||
assert.fail('did not close socket'); | ||
} | ||
catch (error) { | ||
assert.strictEqual(error.code, 'HPE_INVALID_CONSTANT'); | ||
} | ||
}); | ||
|
||
it('should do nothing when undefined fault is specified', async function () { | ||
const stub = { responses: [{ fault: 'NON_EXISTENT_FAULT' }] }, | ||
request = { protocol, port, stubs: [stub] }; | ||
await api.createImposter(request); | ||
const response = await client.get('/', port); | ||
assert.strictEqual(response.statusCode, 200); | ||
assert.strictEqual(response.body, ''); | ||
}); | ||
|
||
}); | ||
}); | ||
}); |
Oops, something went wrong.