test-bad-credentials.js 657 B

12345678910111213141516171819202122232425262728
  1. var common = require('../../common');
  2. var connection = common.createConnection({password: 'INVALID PASSWORD'});
  3. var assert = require('assert');
  4. var endErr;
  5. connection.on('end', function(err) {
  6. assert.equal(endErr, undefined);
  7. endErr = err;
  8. });
  9. var connectErr;
  10. connection.connect(function(err) {
  11. assert.equal(connectErr, undefined);
  12. connectErr = err;
  13. connection.end();
  14. });
  15. process.on('exit', function() {
  16. if (process.env.NO_GRANT == '1' && typeof endErr == 'undefined') return;
  17. assert.equal(endErr.code, 'ER_ACCESS_DENIED_ERROR');
  18. assert.ok(/access denied/i.test(endErr.message));
  19. assert.strictEqual(endErr, connectErr);
  20. });