-
Notifications
You must be signed in to change notification settings - Fork 446
Expand file tree
/
Copy pathconnection-test.js
More file actions
2323 lines (1839 loc) · 57.4 KB
/
Copy pathconnection-test.js
File metadata and controls
2323 lines (1839 loc) · 57.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// @ts-check
const async = require('async');
const assert = require('chai').assert;
const os = require('os');
import Connection from '../../src/connection';
import { ConnectionError, RequestError } from '../../src/errors';
import Request from '../../src/request';
import { versions } from '../../src/tds-versions';
import { debugOptionsFromEnv } from '../helpers/debug-options-from-env';
import defaultConfig from '../config';
function getConfig() {
const config = {
...defaultConfig,
options: {
...defaultConfig.options,
debug: debugOptionsFromEnv(),
tdsVersion: process.env.TEDIOUS_TDS_VERSION,
}
};
return config;
}
describe('Initiate Connect Test', function() {
it('should be bad server', function(done) {
const config = getConfig();
config.server = 'bad-server';
const connection = new Connection(config);
if (process.env.TEDIOUS_DEBUG) {
connection.on('debug', console.log);
}
connection.connect(function(err) {
assert.instanceOf(err, Error);
done();
});
});
it('should be bad port', function(done) {
const config = getConfig();
assert.throws(function() {
new Connection({
...config,
options: {
...config.options,
port: -1,
connectTimeout: 200
}
});
});
done();
});
it('should be bad credentials', function(done) {
const config = getConfig();
if (config.authentication && config.authentication.type !== 'default') {
return done();
}
const connection = new Connection({
...config,
authentication: {
...config.authentication,
options: {
...config.authentication?.options,
userName: 'bad-user',
password: 'bad-password'
}
}
});
connection.on('end', function() {
done();
});
connection.on('infoMessage', function(info) {
// console.log("#{info.number} : #{info.message}")
});
connection.on('errorMessage', function(error) {
// console.log(`${error.number} : ${error.message}`)
return assert.ok(~error.message.indexOf('failed') || ~error.message.indexOf('登录失败'));
});
if (process.env.TEDIOUS_DEBUG) {
connection.on('debug', console.log);
}
connection.connect(function(err) {
assert.ok(err);
connection.close();
});
});
it('should connect by port', function(done) {
const config = getConfig();
if ((config.options != null ? config.options.port : undefined) == null) {
// Config says don't do this test (probably because ports are dynamic).
return this.skip();
}
const connection = new Connection(config);
connection.connect(function(err) {
assert.ifError(err);
connection.on('end', function() {
done();
});
connection.on('databaseChange', function(database) {
if (config.options?.database) {
assert.strictEqual(database, config.options.database);
}
});
connection.on('infoMessage', function(info) {
// console.log("#{info.number} : #{info.message}")
});
if (process.env.TEDIOUS_DEBUG) {
connection.on('debug', console.log);
}
connection.close();
});
});
it('should fail connecting by invalid instance name', function(done) {
const config = getConfig();
if (!config.options?.instanceName) {
// Config says don't do this test (probably because SQL Server Browser is not available).
return this.skip();
}
const connection = new Connection({
...config,
options: {
...config.options,
port: undefined,
instanceName: `${config.options.instanceName}X`
}
});
connection.connect(function(err) {
assert.ok(err);
connection.close();
});
connection.on('end', function() {
done();
});
connection.on('infoMessage', function(info) {
// console.log("#{info.number} : #{info.message}")
});
if (process.env.TEDIOUS_DEBUG) {
connection.on('debug', console.log);
}
});
it('should allow connecting by calling `.connect` on the returned connection', function(done) {
const config = getConfig();
const connection = new Connection(config);
if (process.env.TEDIOUS_DEBUG) {
connection.on('debug', console.log);
}
connection.connect((err) => {
if (err) {
return done(err);
}
connection.on('end', () => { done(); });
connection.close();
});
});
it('should not allow calling `.connect` on a connected connection', function(done) {
const config = getConfig();
const connection = new Connection(config);
if (process.env.TEDIOUS_DEBUG) {
connection.on('debug', console.log);
}
connection.connect((err) => {
if (err) {
return done(err);
}
connection.on('end', () => { done(); });
process.nextTick(() => {
connection.close();
});
assert.throws(() => {
connection.connect();
}, '`.connect` can not be called on a Connection in `LoggedIn` state.');
});
});
it('should allow calling `.connect` without a callback', function(done) {
const config = getConfig();
const connection = new Connection(config);
if (process.env.TEDIOUS_DEBUG) {
connection.on('debug', console.log);
}
connection.on('connect', (err) => {
if (err) {
return done(err);
}
connection.on('end', () => { done(); });
connection.close();
});
connection.connect();
});
it('should fail if no cipher can be negotiated', function(done) {
const config = getConfig();
const connection = new Connection({
...config,
options: {
...config.options,
encrypt: true,
// Specify a cipher that should never be supported by SQL Server
cryptoCredentialsDetails: {
ciphers: 'NULL'
}
}
});
if (process.env.TEDIOUS_DEBUG) {
connection.on('debug', console.log);
}
connection.connect(function(err) {
assert.instanceOf(err, ConnectionError);
assert.strictEqual(/** @type {ConnectionError} */(err).code, 'ESOCKET');
assert.instanceOf(/** @type {ConnectionError} */(err).cause, Error);
console.log(/** @type {ConnectionError} */(err).cause);
assert.include(/** @type {Error} */(/** @type {ConnectionError} */(err).cause).message, 'no ciphers available');
});
connection.on('end', function() {
done();
});
});
it('should use the local hostname as the default workstation identifier', function(done) {
const config = getConfig();
const request = new Request('SELECT HOST_NAME()', function(err, rowCount) {
assert.ifError(err);
assert.strictEqual(rowCount, 1);
connection.close();
});
request.on('row', function(columns) {
assert.strictEqual(columns.length, 1);
assert.strictEqual(columns[0].value, os.hostname());
});
let connection = new Connection(config);
if (process.env.TEDIOUS_DEBUG) {
connection.on('debug', console.log);
}
connection.connect((err) => {
assert.ifError(err);
connection.execSql(request);
});
connection.on('end', () => {
done();
});
});
it('should allow specifying a custom workstation identifier', function(done) {
const config = getConfig();
const request = new Request('SELECT HOST_NAME()', function(err, rowCount) {
assert.ifError(err);
assert.strictEqual(rowCount, 1);
connection.close();
});
request.on('row', function(columns) {
assert.strictEqual(columns.length, 1);
assert.strictEqual(columns[0].value, 'foo.bar.baz');
});
let connection = new Connection({
...config,
options: {
...config.options,
workstationId: 'foo.bar.baz'
}
});
if (process.env.TEDIOUS_DEBUG) {
connection.on('debug', console.log);
}
connection.connect((err) => {
assert.ifError(err);
connection.execSql(request);
});
connection.on('end', () => {
done();
});
});
it('should not emit error after connect timeout', function(done) {
const config = getConfig();
const connection = new Connection({
...config,
options: {
...config.options,
connectTimeout: 1
}
});
if (process.env.TEDIOUS_DEBUG) {
connection.on('debug', console.log);
}
connection.on('error', (error) => { assert.ifError(error); });
connection.connect((err) => { });
setTimeout(() => { done(); }, 500);
});
it('should not leave any dangling sockets after connection timeout', function(done) {
// 192.0.2.0/24 is an IP address block reserved for documentation.
//
// Opening a connection to an address in that block should never be successfull
// and fail after a while with `ETIMEDOUT`.
//
// This test is supposed to show that we correctly clean up the socket(s)
// that got created after the `connectTimeout` was reached and no
// errors happen at a later time.
const conn = new Connection({
server: '192.0.2.1',
options: {
connectTimeout: 3000
}
});
if (process.env.TEDIOUS_DEBUG) {
conn.on('debug', console.log);
}
conn.connect((err) => {
conn.close();
assert.instanceOf(err, Error);
assert.strictEqual(/** @type {Error} */(err).message, 'Failed to connect to 192.0.2.1:1433 in 3000ms');
done();
});
});
});
describe('Ntlm Test', function() {
/**
* @enum {number}
*/
const DomainCaseEnum = {
AsIs: 0,
Lower: 1,
Upper: 2,
};
/**
* @this {Mocha.Context}
* @param {Mocha.Done} done
* @param {DomainCaseEnum} domainCase
* @returns {void}
*/
function runNtlmTest(done, domainCase) {
let config = getConfig();
if (config.authentication?.type !== 'ntlm') {
return this.skip();
}
switch (domainCase) {
case DomainCaseEnum.AsIs:
break;
case DomainCaseEnum.Lower:
config = {
...config,
authentication: {
...config.authentication,
options: {
...config.authentication.options,
domain: /** @type {string} */(config.authentication.options.domain).toLowerCase()
}
}
};
break;
case DomainCaseEnum.Upper:
config = {
...config,
authentication: {
...config.authentication,
options: {
...config.authentication.options,
domain: /** @type {string} */(config.authentication.options.domain).toUpperCase()
}
}
};
break;
default:
assert.ok(false, 'Unexpected value for domainCase: ' + domainCase);
}
let row = 0;
const request = new Request('select 1; select 2;', function(err, rowCount) {
assert.ifError(err);
assert.strictEqual(rowCount, 2);
connection.close();
});
request.on('doneInProc', function(rowCount, more) {
assert.strictEqual(rowCount, 1);
});
request.on('columnMetadata', function(columnsMetadata) {
assert.strictEqual(columnsMetadata.length, 1);
});
request.on('row', function(columns) {
assert.strictEqual(columns[0].value, ++row);
});
const connection = new Connection(config);
connection.connect(function(err) {
assert.ifError(err);
connection.execSql(request);
});
connection.on('end', function() {
done();
});
connection.on('infoMessage', function(info) {
// console.log("#{info.number} : #{info.message}")
});
if (process.env.TEDIOUS_DEBUG) {
connection.on('debug', console.log);
}
}
it('should ntlm', function(done) {
runNtlmTest.call(this, done, DomainCaseEnum.AsIs);
});
it('should ntlm lower', function(done) {
runNtlmTest.call(this, done, DomainCaseEnum.Lower);
});
it('should ntlm upper', function(done) {
runNtlmTest.call(this, done, DomainCaseEnum.Upper);
});
});
describe('Encrypt Test', function() {
/**
* @param {any} config
* @param {(err: Error | null, supportsTds8?: boolean) => void} callback
*/
function supportsTds8(config, callback) {
if (config.options.tdsVersion < '7_2') {
return callback(null, false);
}
const connection = new Connection(config);
if (process.env.TEDIOUS_DEBUG) {
connection.on('debug', console.log);
}
connection.connect((err) => {
if (err) {
return callback(err);
}
/**
* @type {string | undefined}
*/
let productMajorVersion;
const request = new Request("SELECT SERVERPROPERTY('ProductMajorVersion')", (err) => {
if (err) {
connection.close();
return callback(err);
}
if (!productMajorVersion || productMajorVersion < '16') {
connection.close();
return callback(null, false);
}
if (productMajorVersion > '16') {
connection.close();
return callback(null, true);
}
let supportsTds8 = false;
const request = new Request('SELECT host_platform FROM sys.dm_os_host_info', (err) => {
connection.close();
if (err) {
return callback(err);
}
callback(null, supportsTds8);
});
request.on('row', (row) => {
supportsTds8 = row[0].value !== 'Linux';
});
connection.execSql(request);
});
request.on('row', (row) => {
productMajorVersion = row[0].value;
});
connection.execSql(request);
});
}
describe('with strict encryption enabled (TDS 8.0)', function() {
/**
* @type {Connection}
*/
let connection;
beforeEach(function(done) {
const config = getConfig();
supportsTds8(config, (err, supportsTds8) => {
if (err) {
return done(err);
}
if (!supportsTds8) {
return this.skip();
}
connection = new Connection({
...config,
options: {
...config.options,
encrypt: 'strict'
}
});
if (process.env.TEDIOUS_DEBUG) {
connection.on('debug', console.log);
}
connection.connect(done);
});
});
afterEach(function() {
connection && connection.close();
});
it('opens an encrypted connection', function(done) {
const request = new Request(`
SELECT c.protocol_version, c.encrypt_option
FROM sys.dm_exec_connections AS c
WHERE c.session_id = @@SPID
`, (err, rowCount) => {
if (err) {
return done(err);
}
assert.ifError(err);
assert.strictEqual(rowCount, 1);
done();
});
request.on('row', function(columns) {
assert.strictEqual(columns.length, 2);
assert.strictEqual(versions['8_0'], columns[0].value);
assert.strictEqual('TRUE', columns[1].value);
});
connection.execSql(request);
});
});
describe('with encryption enabled', function() {
/**
* @type {Connection}
*/
let connection;
beforeEach(function(done) {
const config = getConfig();
connection = new Connection({
...config,
options: {
...config.options,
encrypt: true
}
});
if (process.env.TEDIOUS_DEBUG) {
connection.on('debug', console.log);
}
connection.connect(done);
});
afterEach(function() {
connection.close();
});
it('opens an encrypted connection', function(done) {
const request = new Request(`
SELECT c.protocol_version, c.encrypt_option
FROM sys.dm_exec_connections AS c
WHERE c.session_id = @@SPID
`, (err, rowCount) => {
if (err) {
return done(err);
}
assert.ifError(err);
assert.strictEqual(rowCount, 1);
done();
});
request.on('row', function(columns) {
assert.strictEqual(columns.length, 2);
assert.strictEqual(versions[connection.config.options.tdsVersion], columns[0].value);
assert.strictEqual('TRUE', columns[1].value);
});
connection.execSql(request);
});
});
});
describe('BeginTransaction Tests', function() {
/** @type {Connection} */
let connection;
beforeEach(function(done) {
const config = getConfig();
connection = new Connection(config);
if (process.env.TEDIOUS_DEBUG) {
connection.on('debug', console.log);
}
connection.connect(done);
});
afterEach(function(done) {
if (!connection.closed) {
connection.on('end', done);
connection.close();
} else {
done();
}
});
it('should validate isolation level is a number', function() {
assert.throws(() => {
const callback = () => { assert.fail('callback should not be executed'); };
connection.beginTransaction(callback, 'test', /** @type {any} */('some string'));
}, TypeError, 'The "isolationLevel" argument must be of type number. Received type string (some string)');
});
it('should validate isolation level is an integer', function() {
assert.throws(() => {
const callback = () => { assert.fail('callback should not be executed'); };
connection.beginTransaction(callback, 'test', 2.3);
}, RangeError, 'The value of "isolationLevel" is out of range. It must be an integer. Received: 2.3');
});
it('should validate isolation level is a valid isolation level value', function() {
assert.throws(() => {
const callback = () => { assert.fail('callback should not be executed'); };
connection.beginTransaction(callback, 'test', 9);
}, RangeError, 'The value of "isolationLevel" is out of range. It must be >= 0 && <= 5. Received: 9');
});
});
describe('Insertion Tests', function() {
it('should execSql', function(done) {
const config = getConfig();
const request = new Request('select 8 as C1', function(err, rowCount) {
assert.ifError(err);
assert.strictEqual(rowCount, 1);
connection.close();
});
request.on('doneInProc', function(rowCount, more) {
assert.ok(more);
assert.strictEqual(rowCount, 1);
});
request.on('columnMetadata', function(columnsMetadata) {
assert.strictEqual(columnsMetadata.length, 1);
});
request.on('row', function(columns) {
assert.strictEqual(columns.length, 1);
assert.strictEqual(columns[0].value, 8);
});
let connection = new Connection(config);
connection.connect(function(err) {
connection.execSql(request);
});
connection.on('end', function() {
done();
});
connection.on('infoMessage', function(info) {
// console.log("#{info.number} : #{info.message}")
});
if (process.env.TEDIOUS_DEBUG) {
connection.on('debug', console.log);
}
});
describe('when `useColumnNames` is `true`', function() {
it('should support numeric column names', function(done) {
const config = getConfig();
const connection = new Connection({
...config,
options: {
...config.options,
useColumnNames: true
}
});
if (process.env.TEDIOUS_DEBUG) {
connection.on('debug', console.log);
}
connection.connect((err) => {
if (err) {
return done(err);
}
const request = new Request('select 8 as [123]', (err, rowCount) => {
assert.ifError(err);
assert.strictEqual(rowCount, 1);
connection.close();
});
request.on('columnMetadata', (columnsMetadata) => {
assert.strictEqual(Object.keys(columnsMetadata).length, 1);
});
request.on('row', (columns) => {
assert.strictEqual(Object.keys(columns).length, 1);
assert.strictEqual(columns[123].value, 8);
});
connection.execSql(request);
});
connection.on('end', () => {
done();
});
});
it('supports duplicate column names', function(done) {
const config = getConfig();
const connection = new Connection({
...config,
options: {
...config.options,
useColumnNames: true
}
});
if (process.env.TEDIOUS_DEBUG) {
connection.on('debug', console.log);
}
connection.connect((err) => {
if (err) {
return done(err);
}
const request = new Request("select 1 as abc, 2 as xyz, '3' as abc", (err, rowCount) => {
assert.ifError(err);
assert.strictEqual(rowCount, 1);
connection.close();
});
request.on('columnMetadata', (columnsMetadata) => {
assert.strictEqual(Object.keys(columnsMetadata).length, 2);
});
request.on('row', (columns) => {
assert.strictEqual(Object.keys(columns).length, 2);
assert.strictEqual(columns.abc.value, 1);
assert.strictEqual(columns.xyz.value, 2);
});
connection.execSql(request);
});
connection.on('end', () => {
done();
});
});
describe('with a polluted `Object` prototype', function() {
beforeEach(function() {
({}).constructor.prototype.foo = 'bar';
});
afterEach(function() {
delete ({}).constructor.prototype.foo;
});
it('should not have column metadata or rows be affected by the pollution', function(done) {
const config = getConfig();
const connection = new Connection({
...config,
options: {
...config.options,
useColumnNames: true
}
});
if (process.env.TEDIOUS_DEBUG) {
connection.on('debug', console.log);
}
connection.connect((err) => {
if (err) {
return done(err);
}
const request = new Request('select 1 as abc', (err, rowCount) => {
assert.ifError(err);
assert.strictEqual(rowCount, 1);
connection.close();
});
request.on('columnMetadata', (columnsMetadata) => {
assert.property(columnsMetadata, 'abc');
assert.notProperty(columnsMetadata, 'foo');
});
request.on('row', (columns) => {
assert.property(columns, 'abc');
assert.notProperty(columns, 'foo');
});
connection.execSql(request);
});
connection.on('end', () => {
done();
});
});
});
});
it('should exec Sql multiple times', function(done) {
const timesToExec = 5;
let sqlExecCount = 0;
const config = getConfig();
function execSql() {
if (sqlExecCount === timesToExec) {
connection.close();
return;
}
const request = new Request('select 8 as C1', function(err, rowCount) {
assert.ifError(err);
assert.strictEqual(rowCount, 1);
sqlExecCount++;
execSql();
});
request.on('doneInProc', function(rowCount, more) {
assert.ok(more);
assert.strictEqual(rowCount, 1);
});
request.on('columnMetadata', function(columnsMetadata) {
assert.strictEqual(columnsMetadata.length, 1);
});
request.on('row', function(columns) {
assert.strictEqual(columns.length, 1);
assert.strictEqual(columns[0].value, 8);
});
connection.execSql(request);
}
let connection = new Connection(config);
connection.connect(function(err) {
execSql();
});
connection.on('end', function() {
done();
});
connection.on('infoMessage', function(info) {
// console.log("#{info.number} : #{info.message}")
});
if (process.env.TEDIOUS_DEBUG) {
connection.on('debug', console.log);
}
});
it('should exec sql with order', function(done) {
const config = getConfig();
const sql =
'select top 2 object_id, name, column_id, system_type_id from sys.columns order by name, system_type_id';
const request = new Request(sql, function(err, rowCount) {
assert.ifError(err);
assert.strictEqual(rowCount, 2);
connection.close();
});
request.on('doneInProc', function(rowCount, more) {
assert.ok(more);
assert.strictEqual(rowCount, 2);
});
request.on('columnMetadata', function(columnsMetadata) {
assert.strictEqual(columnsMetadata.length, 4);
});
request.on('order', function(orderColumns) {
assert.strictEqual(orderColumns.length, 2);
assert.strictEqual(orderColumns[0], 2);
assert.strictEqual(orderColumns[1], 4);
});
request.on('row', function(columns) {
assert.strictEqual(columns.length, 4);
});
let connection = new Connection(config);