test-host-denied-error.js 715 B

123456789101112131415161718192021222324252627
  1. var common = require('../../common');
  2. var connection = common.createConnection({port: common.fakeServerPort});
  3. var assert = require('assert');
  4. var server = common.createFakeServer();
  5. var connectErr;
  6. server.listen(common.fakeServerPort, function(err) {
  7. if (err) throw err;
  8. connection.connect(function(err) {
  9. connectErr = err;
  10. server.destroy();
  11. });
  12. });
  13. server.on('connection', function(incomingConnection) {
  14. var errno = 1130; // ER_HOST_NOT_PRIVILEGED
  15. incomingConnection.deny('You suck.', errno);
  16. });
  17. process.on('exit', function() {
  18. assert.equal(connectErr.code, 'ER_HOST_NOT_PRIVILEGED');
  19. assert.ok(/You suck/.test(connectErr.message));
  20. assert.equal(connectErr.fatal, true);
  21. });