-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bugfix/ARSN-4-exceptionWhenKMSIsDown' into tmp/octopus/…
…w/8.1/bugfix/ARSN-4-exceptionWhenKMSIsDown
- Loading branch information
Showing
3 changed files
with
85 additions
and
72 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
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,43 @@ | ||
const assert = require('assert'); | ||
const net = require('net'); | ||
const tls = require('tls'); | ||
const TransportTemplate = | ||
require('../../../lib/network/kmip/transport/TransportTemplate.js'); | ||
const { logger } = require('../../utils/kmip/ersatz.js'); | ||
|
||
describe('KMIP Connection Management', () => { | ||
let server; | ||
before(done => { | ||
server = net.createServer(conn => { | ||
// abort the connection as soon as it is accepted | ||
conn.destroy(); | ||
}); | ||
server.listen(5696); | ||
server.on('listening', done); | ||
}); | ||
after(done => { | ||
server.close(done); | ||
}); | ||
|
||
it('should gracefully handle connection errors', done => { | ||
const transport = new TransportTemplate( | ||
tls, | ||
{ | ||
pipelineDepth: 1, | ||
tls: { | ||
port: 5696, | ||
}, | ||
}); | ||
const request = Buffer.alloc(10).fill(6); | ||
/* Using a for loop here instead of anything | ||
* asynchronous, the callbacks get stuck in | ||
* the conversation queue and are unwind with | ||
* an error. It is the purpose of this test */ | ||
transport.send(logger, request, (err, conversation, response) => { | ||
assert(err); | ||
assert(!response); | ||
done(); | ||
}); | ||
transport.end(); | ||
}); | ||
}); |
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