Skip to content

Commit

Permalink
[CONJS-203] encoding error when using changeUser with connection attr…
Browse files Browse the repository at this point in the history
…ibutes
  • Loading branch information
rusher committed Jun 7, 2022
1 parent 8d3c0e9 commit 8cc784f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ install:
connector-test-machine/launch.bat -t "$srv" -v "$v" -d testn
;;
linux)
source connector-test-machine/launch.sh -t "$srv" -v "$v" -d testn -l "$local"
source connector-test-machine/launch.sh -t "$srv" -v "$v" -d testn -l "$local" -c "$CLEAR_TEXT"
;;
esac
env:
global:
- RUN_LONG_TEST=1
- CLEAR_TEXT=0
jobs:
fast_finish: true
allow_failures:
Expand All @@ -44,7 +45,7 @@ jobs:
- env: srv=mariadb v=10.7 local=1
- env: srv=mariadb v=10.6 local=1
node_js: 14
- env: srv=mariadb v=10.6 local=1
- env: srv=mariadb v=10.6 local=1 CLEAR_TEXT=1
node_js: 16
- env: srv=mariadb v=10.6 local=1
node_js: 18
Expand Down
2 changes: 1 addition & 1 deletion lib/cmd/change-user.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class ChangeUser extends Handshake {
let initPos = out.pos; //save position, assuming connection attributes length will be less than 2 bytes length
out.writeInt16(0);

const encoding = this.opts.collation.charset;
const encoding = info.collation.charset;

writeParam(out, '_client_name', encoding);
writeParam(out, 'MariaDB connector/Node', encoding);
Expand Down
4 changes: 4 additions & 0 deletions test/integration/test-auth-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ describe('authentication plugin', () => {
user: 'verificationEd25519AuthPlugin',
password: 'MySup8%rPassw@ord'
});
await conn.changeUser({
user: 'verificationEd25519AuthPlugin',
password: 'MySup8%rPassw@ord'
});
conn.end();
try {
conn = await base.createConnection({
Expand Down
39 changes: 39 additions & 0 deletions test/integration/test-change-user.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,45 @@ describe('change user', () => {
.catch(done);
});

it('change user using connection attributes', function (done) {
if (process.env.srv === 'maxscale' || process.env.srv === 'skysql-ha' || isXpand()) this.skip();
if (!shareConn.info.isMariaDB()) this.skip();

base
.createConnection({ connectAttributes: { param1: 'test' } })
.then((conn) => {
return conn
.changeUser({
user: 'ChangeUser',
password: 'm1P4ssw0@rd',
connectAttributes: { par1: 'bouh', par2: 'bla' }
})
.then(() => {
return conn.query('SELECT CURRENT_USER');
})
.then((res) => {
const user = res[0]['CURRENT_USER'];
assert.equal(user, 'ChangeUser@%');
return conn.changeUser({
user: 'ChangeUser2',
password: 'm1SecondP@rd',
connectAttributes: true
});
})
.then(() => {
return conn.query('SELECT CURRENT_USER');
})
.then((res) => {
const user = res[0]['CURRENT_USER'];
assert.equal(user, 'ChangeUser2@%');
conn.end();
done();
})
.catch(done);
})
.catch(done);
});

it('basic change user using promise non node.js encoding', function (done) {
if (process.env.srv === 'maxscale' || process.env.srv === 'skysql-ha' || isXpand()) this.skip();
if (!shareConn.info.isMariaDB()) this.skip();
Expand Down

0 comments on commit 8cc784f

Please sign in to comment.