Skip to content

Commit c767f15

Browse files
committed
Change tests to be able to be runned on mysql instances with --skip-grant-tables
Some auth tests won't have the expected 'access denied' because mysql instance will accept any user/password combination (fixes #312)
1 parent b9d7edd commit c767f15

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

test/integration/connection/test-bad-credentials.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ var connectErr;
1212
connection.connect(function(err) {
1313
assert.equal(connectErr, undefined);
1414
connectErr = err;
15+
16+
connection.end();
1517
});
1618

1719
process.on('exit', function() {
20+
if (process.env.NO_GRANT == '1' && typeof endErr == 'undefined') return;
21+
1822
assert.equal(endErr.code, 'ER_ACCESS_DENIED_ERROR');
1923
assert.ok(/access denied/i.test(endErr.message));
2024

test/integration/connection/test-change-user-fatal-error.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ if (common.isTravis()) {
1414
var err;
1515
connection.changeUser({user: 'does-not-exist'}, function(_err) {
1616
err = _err;
17+
connection.end();
1718
});
18-
connection.end();
1919

2020
process.on('exit', function() {
21-
if (err === null) return;
21+
if (process.env.NO_GRANT == '1' && err === null) return;
2222
assert.equal(err.code, 'ER_ACCESS_DENIED_ERROR');
2323
assert.equal(err.fatal, true);
2424
});

test/integration/connection/test-fatal-auth-error-going-to-all-callbacks.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ connection.connect(function(err) {
1212
connection.query('SELECT 1', function(err) {
1313
assert.equal(errors.b, undefined);
1414
errors.b = err;
15+
16+
connection.end();
1517
});
1618

1719
process.on('exit', function() {
20+
if (process.env.NO_GRANT == '1' && errors.a === null) return;
21+
1822
assert.equal(errors.a.code, 'ER_ACCESS_DENIED_ERROR');
1923
assert.equal(errors.a.fatal, true);
2024
assert.strictEqual(errors.a, errors.b);

test/integration/connection/test-fatal-auth-error-without-handlers.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ connection.on('error', function(_err) {
1010
assert.equal(err, undefined);
1111
err = _err;
1212
});
13+
connection.end();
1314

1415
process.on('exit', function() {
16+
if (process.env.NO_GRANT == '1' && typeof err == 'undefined') return;
17+
1518
assert.equal(err.code, 'ER_ACCESS_DENIED_ERROR');
1619
assert.equal(err.fatal, true);
1720
});

0 commit comments

Comments
 (0)