Skip to content
This repository was archived by the owner on Feb 4, 2022. It is now read-only.

Commit 9719c45

Browse files
malexandertmbroadst
authored andcommittedAug 18, 2017
test(basic_replset_server_auth_tests): convert basic_replset_server_auth_tests to run with mocha
NODE-1096
1 parent 1602e4d commit 9719c45

File tree

2 files changed

+259
-574
lines changed

2 files changed

+259
-574
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,66 @@
1-
"use strict";
1+
'use strict';
22

3-
var f = require('util').format,
4-
locateAuthMethod = require('./shared').locateAuthMethod,
5-
executeCommand = require('./shared').executeCommand;
3+
var expect = require('chai').expect,
4+
f = require('util').format,
5+
locateAuthMethod = require('./shared').locateAuthMethod,
6+
executeCommand = require('./shared').executeCommand,
7+
ReplSet = require('../../../lib/topologies/replset'),
8+
Connection = require('../../../lib/connection/connection');
69

710
var setUp = function(configuration, options, callback) {
811
var ReplSetManager = require('mongodb-topology-manager').ReplSet;
912

1013
// Check if we have any options
11-
if(typeof options == 'function') callback = options, options = null;
14+
if (typeof options === 'function') {
15+
callback = options;
16+
options = null;
17+
}
1218

1319
// Override options
14-
if(options) {
15-
var rsOptions = options;
20+
var rsOptions;
21+
if (options) {
22+
rsOptions = options;
1623
} else {
17-
var rsOptions = {
24+
rsOptions = {
1825
server: {
1926
keyFile: __dirname + '/key/keyfile.key',
2027
auth: null, replSet: 'rs'
2128
},
2229
client: { replSet: 'rs' }
23-
}
30+
};
2431
}
2532

2633
// Set up the nodes
2734
var nodes = [{
2835
options: {
2936
bind_ip: 'localhost', port: 31000,
30-
dbpath: f('%s/../db/31000', __dirname),
37+
dbpath: f('%s/../db/31000', __dirname)
3138
}
3239
}, {
3340
options: {
3441
bind_ip: 'localhost', port: 31001,
35-
dbpath: f('%s/../db/31001', __dirname),
42+
dbpath: f('%s/../db/31001', __dirname)
3643
}
3744
}, {
3845
options: {
3946
bind_ip: 'localhost', port: 31002,
40-
dbpath: f('%s/../db/31002', __dirname),
47+
dbpath: f('%s/../db/31002', __dirname)
4148
}
4249
}, {
4350
options: {
4451
bind_ip: 'localhost', port: 31003,
45-
dbpath: f('%s/../db/31003', __dirname),
52+
dbpath: f('%s/../db/31003', __dirname)
4653
}
4754
}, {
4855
options: {
4956
bind_ip: 'localhost', port: 31004,
50-
dbpath: f('%s/../db/31004', __dirname),
57+
dbpath: f('%s/../db/31004', __dirname)
5158
}
52-
}]
59+
}];
5360

5461
// Merge in any node start up options
55-
for(var i = 0; i < nodes.length; i++) {
56-
for(var name in rsOptions.server) {
62+
for (var i = 0; i < nodes.length; i++) {
63+
for (var name in rsOptions.server) {
5764
nodes[i].options[name] = rsOptions.server[name];
5865
}
5966
}
@@ -71,605 +78,283 @@ var setUp = function(configuration, options, callback) {
7178
console.dir(e);
7279
});
7380
});
74-
}
75-
76-
exports['Should fail to authenticat emitting an error due to it being the initial connect'] = {
77-
metadata: { requires: { topology: "auth" } },
78-
79-
test: function(configuration, test) {
80-
var ReplSet = require('../../../lib/topologies/replset')
81-
, Connection = require('../../../lib/connection/connection')
82-
, bson = require('bson')
83-
, Query = require('../../../lib/connection/commands').Query;
84-
85-
setUp(configuration, function(err, replicasetManager) {
86-
// Enable connections accounting
87-
Connection.enableConnectionAccounting();
88-
89-
// Get right auth method
90-
locateAuthMethod(configuration, function(err, method) {
91-
test.equal(null, err);
92-
93-
executeCommand(configuration, 'admin', {
94-
createUser: 'root',
95-
pwd: "root",
96-
roles: [ { role: "root", db: "admin" } ],
97-
digestPassword: true
98-
}, {
99-
host: 'localhost', port: 31000
100-
}, function(err, r) {
101-
test.equal(null, err);
102-
103-
// Attempt to connect
104-
var server = new ReplSet([{
105-
host: 'localhost'
106-
, port: 31000
107-
}, {
108-
host: 'localhost'
109-
, port: 31001
110-
}], {
111-
setName: 'rs'
112-
});
81+
};
11382

114-
server.on('connect', function(_server) {
115-
});
83+
describe.skip('Basic replica set server auth tests', function() {
84+
it('should fail to authenticat emitting an error due to it being the initial connect', {
85+
metadata: { requires: { topology: 'auth' } },
11686

117-
server.on('error', function() {
118-
// console.log("=================== " + Object.keys(Connection.connections()).length)
119-
test.equal(0, Object.keys(Connection.connections()).length);
120-
Connection.disableConnectionAccounting();
87+
test: function(done) {
88+
var self = this;
89+
90+
setUp(self.configuration, function(err, replicasetManager) {
91+
// Enable connections accounting
92+
Connection.enableConnectionAccounting();
93+
94+
// Get right auth method
95+
locateAuthMethod(self.configuration, function(locateErr, method) {
96+
expect(locateErr).to.be.null;
97+
98+
executeCommand(self.configuration, 'admin', {
99+
createUser: 'root',
100+
pwd: 'root',
101+
roles: [ { role: 'root', db: 'admin' } ],
102+
digestPassword: true
103+
}, {
104+
host: 'localhost', port: 31000
105+
}, function(createUserErr, createUserRes) {
106+
expect(createUserErr).to.be.null;
121107

122-
executeCommand(configuration, 'admin', {
123-
dropUser: 'root'
108+
// Attempt to connect
109+
var server = new ReplSet([{
110+
host: 'localhost',
111+
port: 31000
124112
}, {
125-
auth: [method, 'admin', 'root', 'root']
126-
, host: 'localhost', port: 31000
127-
}, function(err, r) {
128-
replicasetManager.stop().then(function() {
129-
test.done();
130-
});
113+
host: 'localhost',
114+
port: 31001
115+
}], {
116+
setName: 'rs'
131117
});
132-
});
133118

134-
server.connect({auth: [method, 'admin', 'root2', 'root']});
135-
});
136-
});
137-
});
138-
}
139-
}
140-
141-
exports['Should correctly authenticate server using scram-sha-1 using connect auth'] = {
142-
metadata: { requires: { topology: "auth" } },
143-
144-
test: function(configuration, test) {
145-
var ReplSet = require('../../../lib/topologies/replset')
146-
, Connection = require('../../../lib/connection/connection')
147-
, bson = require('bson')
148-
, Query = require('../../../lib/connection/commands').Query;
149-
150-
setUp(configuration, function(err, replicasetManager) {
151-
// Enable connections accounting
152-
Connection.enableConnectionAccounting();
153-
154-
locateAuthMethod(configuration, function(err, method) {
155-
test.equal(null, err);
156-
157-
executeCommand(configuration, 'admin', {
158-
createUser: 'root',
159-
pwd: "root",
160-
roles: [ { role: "root", db: "admin" } ],
161-
digestPassword: true
162-
}, {
163-
host: 'localhost', port: 31000
164-
}, function(err, r) {
165-
test.equal(null, err);
166-
167-
// Attempt to connect
168-
var server = new ReplSet([{
169-
host: 'localhost', port: 31000
170-
}, {
171-
host: 'localhost', port: 31001
172-
}], {
173-
setName: 'rs'
174-
});
119+
server.on('connect', function(_server) {
120+
});
175121

176-
server.on('connect', function(_server) {
177-
_server.insert('test.test', [{a:1}], function(err, r) {
178-
test.equal(null, err);
179-
test.equal(1, r.result.n);
122+
server.on('error', function() {
123+
// console.log('=================== ' + Object.keys(Connection.connections()).length)
124+
expect(Object.keys(Connection.connections()).length).to.equal(0);
125+
Connection.disableConnectionAccounting();
180126

181-
executeCommand(configuration, 'admin', {
127+
executeCommand(self.configuration, 'admin', {
182128
dropUser: 'root'
183129
}, {
184-
auth: [method, 'admin', 'root', 'root']
185-
, host: 'localhost', port: 31000
186-
}, function(err, r) {
187-
test.equal(null, err);
188-
189-
_server.destroy();
190-
// console.log("=================== " + Object.keys(Connection.connections()).length)
191-
test.equal(0, Object.keys(Connection.connections()).length);
192-
Connection.disableConnectionAccounting();
193-
130+
auth: [method, 'admin', 'root', 'root'],
131+
host: 'localhost', port: 31000
132+
}, function(dropUserErr, dropUserRes) {
194133
replicasetManager.stop().then(function() {
195-
test.done();
134+
done();
196135
});
197136
});
198137
});
199-
});
200138

201-
server.connect({auth: [method, 'admin', 'root', 'root']});
139+
server.connect({auth: [method, 'admin', 'root2', 'root']});
140+
});
202141
});
203142
});
204-
});
205-
}
206-
}
207-
208-
exports['Should correctly authenticate using auth method instead of connect'] = {
209-
metadata: { requires: { topology: "auth" } },
210-
211-
test: function(configuration, test) {
212-
var ReplSet = require('../../../lib/topologies/replset')
213-
, Connection = require('../../../lib/connection/connection')
214-
, bson = require('bson')
215-
, Query = require('../../../lib/connection/commands').Query;
216-
217-
setUp(configuration, function(err, replicasetManager) {
218-
// Enable connections accounting
219-
Connection.enableConnectionAccounting();
220-
221-
locateAuthMethod(configuration, function(err, method) {
222-
test.equal(null, err);
223-
224-
executeCommand(configuration, 'admin', {
225-
createUser: 'root',
226-
pwd: "root",
227-
roles: [ { role: "root", db: "admin" } ],
228-
digestPassword: true
229-
}, {
230-
host: 'localhost', port: 31000
231-
}, function(err, r) {
232-
test.equal(null, err);
233-
// process.exit(0)
234-
235-
// Attempt to connect
236-
var server = new ReplSet([{
143+
}
144+
});
145+
146+
it('should correctly authenticate server using scram-sha-1 using connect auth', {
147+
metadata: { requires: { topology: 'auth' } },
148+
149+
test: function(done) {
150+
var self = this;
151+
152+
setUp(self.configuration, function(err, replicasetManager) {
153+
// Enable connections accounting
154+
Connection.enableConnectionAccounting();
155+
156+
locateAuthMethod(self.configuration, function(locateErr, method) {
157+
expect(locateErr).to.be.null;
158+
159+
executeCommand(self.configuration, 'admin', {
160+
createUser: 'root',
161+
pwd: 'root',
162+
roles: [ { role: 'root', db: 'admin' } ],
163+
digestPassword: true
164+
}, {
237165
host: 'localhost', port: 31000
238-
}], {
239-
setName: 'rs'
240-
});
166+
}, function(createUserErr, createUserRes) {
167+
expect(createUserErr).to.be.null;
168+
169+
// Attempt to connect
170+
var server = new ReplSet([{
171+
host: 'localhost', port: 31000
172+
}, {
173+
host: 'localhost', port: 31001
174+
}], {
175+
setName: 'rs'
176+
});
241177

242-
server.on('connect', function(_server) {
243-
//{auth: [method, 'admin', 'root', 'root']}
244-
// Attempt authentication
245-
_server.auth(method, 'admin', 'root', 'root', function(err, r) {
246-
_server.insert('test.test', [{a:1}], function(err, r) {
247-
test.equal(null, err);
248-
test.equal(1, r.result.n);
178+
server.on('connect', function(_server) {
179+
_server.insert('test.test', [{a: 1}], function(insertErr, insertRes) {
180+
expect(err).to.be.null;
181+
expect(insertRes.result.n).to.equal(1);
249182

250-
executeCommand(configuration, 'admin', {
183+
executeCommand(self.configuration, 'admin', {
251184
dropUser: 'root'
252185
}, {
253-
auth: [method, 'admin', 'root', 'root']
254-
, host: 'localhost', port: 31000
255-
}, function(err, r) {
256-
test.equal(null, err);
186+
auth: [method, 'admin', 'root', 'root'],
187+
host: 'localhost', port: 31000
188+
}, function(dropUserErr, dropUserRes) {
189+
expect(dropUserErr).to.be.null;
257190

258191
_server.destroy();
259-
// console.log("=================== " + Object.keys(Connection.connections()).length)
260-
test.equal(0, Object.keys(Connection.connections()).length);
192+
// console.log('=================== ' + Object.keys(Connection.connections()).length)
193+
expect(Object.keys(Connection.connections()).length).to.equal(0);
261194
Connection.disableConnectionAccounting();
262195

263196
replicasetManager.stop().then(function() {
264-
test.done();
197+
done();
265198
});
266199
});
267200
});
268201
});
269-
});
270202

271-
server.connect();
203+
server.connect({auth: [method, 'admin', 'root', 'root']});
204+
});
272205
});
273206
});
274-
});
275-
}
276-
}
277-
278-
exports['Should correctly authenticate using auth method instead of connect and logout user'] = {
279-
metadata: { requires: { topology: "auth" } },
280-
281-
test: function(configuration, test) {
282-
var ReplSet = require('../../../lib/topologies/replset')
283-
, Connection = require('../../../lib/connection/connection')
284-
, bson = require('bson')
285-
, Query = require('../../../lib/connection/commands').Query;
286-
287-
// console.log("------------------------------ -3")
288-
setUp(configuration, function(err, replicasetManager) {
289-
// console.log("------------------------------ -2")
290-
// Enable connections accounting
291-
Connection.enableConnectionAccounting();
292-
293-
locateAuthMethod(configuration, function(err, method) {
294-
test.equal(null, err);
295-
296-
executeCommand(configuration, 'admin', {
297-
createUser: 'root',
298-
pwd: "root",
299-
roles: [ { role: "root", db: "admin" } ],
300-
digestPassword: true
301-
}, {
302-
host: 'localhost', port: 31000
303-
}, function(err, r) {
304-
test.equal(null, err);
305-
// process.exit(0)
306-
307-
// console.log("------------------------------ -1")
308-
// Attempt to connect
309-
var server = new ReplSet([{
207+
}
208+
});
209+
210+
it('should correctly authenticate using auth method instead of connect', {
211+
metadata: { requires: { topology: 'auth' } },
212+
213+
test: function(done) {
214+
var self = this;
215+
216+
setUp(self.configuration, function(err, replicasetManager) {
217+
// Enable connections accounting
218+
Connection.enableConnectionAccounting();
219+
220+
locateAuthMethod(self.configuration, function(locateErr, method) {
221+
expect(locateErr).to.be.null;
222+
223+
executeCommand(self.configuration, 'admin', {
224+
createUser: 'root',
225+
pwd: 'root',
226+
roles: [ { role: 'root', db: 'admin' } ],
227+
digestPassword: true
228+
}, {
310229
host: 'localhost', port: 31000
311-
}], {
312-
setName: 'rs'
230+
}, function(createUserErr, createUserRes) {
231+
expect(createUserErr).to.be.null;
232+
// process.exit(0)
233+
234+
// Attempt to connect
235+
var server = new ReplSet([{
236+
host: 'localhost', port: 31000
237+
}], {
238+
setName: 'rs'
239+
});
240+
241+
server.on('connect', function(_server) {
242+
//{auth: [method, 'admin', 'root', 'root']}
243+
// Attempt authentication
244+
_server.auth(method, 'admin', 'root', 'root', function(authErr, authRes) {
245+
_server.insert('test.test', [{a: 1}], function(insertErr, insertRes) {
246+
expect(insertErr).to.be.null;
247+
expect(insertRes.result.n).to.equal(1);
248+
249+
executeCommand(self.configuration, 'admin', {
250+
dropUser: 'root'
251+
}, {
252+
auth: [method, 'admin', 'root', 'root'],
253+
host: 'localhost', port: 31000
254+
}, function(dropUserErr, dropUserRes) {
255+
expect(dropUserErr).to.be.null;
256+
257+
_server.destroy();
258+
// console.log('=================== ' + Object.keys(Connection.connections()).length)
259+
expect(Object.keys(Connection.connections()).length).to.equal(0);
260+
Connection.disableConnectionAccounting();
261+
262+
replicasetManager.stop().then(function() {
263+
done();
264+
});
265+
});
266+
});
267+
});
268+
});
269+
270+
server.connect();
313271
});
272+
});
273+
});
274+
}
275+
});
314276

315-
server.on('connect', function(_server) {
316-
// console.log("----------------- 0")
317-
//{auth: [method, 'admin', 'root', 'root']}
318-
// Attempt authentication
319-
_server.auth(method, 'admin', 'root', 'root', function(err, r) {
320-
// console.log("----------------- 1")
321-
_server.insert('test.test', [{a:1}], function(err, r) {
322-
// console.log("----------------- 2")
323-
test.equal(null, err);
324-
test.equal(1, r.result.n);
325-
326-
// console.log("----------------- 3")
327-
_server.logout('admin', function(err ,r) {
328-
// console.log("----------------- 4")
329-
test.equal(null, err);
330-
331-
_server.insert('test.test', [{a:1}], function(err, r) {
332-
// console.log("=====================================")
333-
// console.dir(err)
334-
if(r) console.dir(r.result)
335-
336-
executeCommand(configuration, 'admin', {
337-
dropUser: 'root'
338-
}, {
339-
auth: [method, 'admin', 'root', 'root']
340-
, host: 'localhost', port: 31000
341-
}, function(err, r) {
342-
test.equal(null, err);
343-
344-
_server.destroy();
345-
// console.log("=================== " + Object.keys(Connection.connections()).length)
346-
test.equal(0, Object.keys(Connection.connections()).length);
347-
Connection.disableConnectionAccounting();
348-
349-
replicasetManager.stop().then(function() {
350-
test.done();
277+
it('should correctly authenticate using auth method instead of connect and logout user', {
278+
metadata: { requires: { topology: 'auth' } },
279+
280+
test: function(done) {
281+
var self = this;
282+
283+
setUp(self.configuration, function(err, replicasetManager) {
284+
// console.log('------------------------------ -2')
285+
// Enable connections accounting
286+
Connection.enableConnectionAccounting();
287+
288+
locateAuthMethod(self.configuration, function(locateErr, method) {
289+
expect(locateErr).to.be.null;
290+
291+
executeCommand(self.configuration, 'admin', {
292+
createUser: 'root',
293+
pwd: 'root',
294+
roles: [ { role: 'root', db: 'admin' } ],
295+
digestPassword: true
296+
}, {
297+
host: 'localhost', port: 31000
298+
}, function(createUserErr, createUserRes) {
299+
expect(createUserErr).to.be.null;
300+
// process.exit(0)
301+
302+
// console.log('------------------------------ -1')
303+
// Attempt to connect
304+
var server = new ReplSet([{
305+
host: 'localhost', port: 31000
306+
}], {
307+
setName: 'rs'
308+
});
309+
310+
server.on('connect', function(_server) {
311+
// console.log('----------------- 0')
312+
//{auth: [method, 'admin', 'root', 'root']}
313+
// Attempt authentication
314+
_server.auth(method, 'admin', 'root', 'root', function(authErr, authRes) {
315+
// console.log('----------------- 1')
316+
_server.insert('test.test', [{a: 1}], function(insertErr, insertRes) {
317+
// console.log('----------------- 2')
318+
expect(insertErr).to.be.null;
319+
expect(insertRes.result.n).to.equal(1);
320+
321+
// console.log('----------------- 3')
322+
_server.logout('admin', function(logoutErr, logoutRes) {
323+
// console.log('----------------- 4')
324+
expect(logoutErr).to.be.null;
325+
326+
_server.insert('test.test', [{a: 1}], function(secondInsertErr, secondInsertRes) {
327+
// console.log('=====================================')
328+
// console.dir(err)
329+
if (secondInsertRes) console.dir(secondInsertRes.result);
330+
331+
executeCommand(self.configuration, 'admin', {
332+
dropUser: 'root'
333+
}, {
334+
auth: [method, 'admin', 'root', 'root'],
335+
host: 'localhost', port: 31000
336+
}, function(dropUserErr, dropUserRes) {
337+
expect(dropUserErr).to.be.null;
338+
339+
_server.destroy();
340+
// console.log('=================== ' + Object.keys(Connection.connections()).length)
341+
expect(Object.keys(Connection.connections()).length).to.equal(0);
342+
Connection.disableConnectionAccounting();
343+
344+
replicasetManager.stop().then(function() {
345+
done();
346+
});
351347
});
352348
});
353349
});
354350
});
355351
});
356352
});
357-
});
358353

359-
server.connect();
354+
server.connect();
355+
});
360356
});
361357
});
362-
});
363-
}
364-
}
365-
366-
367-
368-
369-
370-
371-
372-
373-
374-
375-
376-
377-
378-
379-
380-
381-
382-
383-
384-
// exports['Should correctly authenticate server using scram-sha-1 using connect auth and maintain auth on new connections'] = {
385-
// metadata: { requires: { topology: "auth" } },
386-
//
387-
// test: function(configuration, test) {
388-
// var Server = require('../../../lib/topologies/server')
389-
// , Connection = require('../../../lib/connection/connection')
390-
// , bson = require('bson')
391-
// , Query = require('../../../lib/connection/commands').Query;
392-
//
393-
// // Enable connections accounting
394-
// Connection.enableConnectionAccounting();
395-
//
396-
// // Restart instance
397-
// configuration.manager.restart(true).then(function() {
398-
// locateAuthMethod(configuration, function(err, method) {
399-
// test.equal(null, err);
400-
//
401-
// executeCommand(configuration, 'admin', {
402-
// createUser: 'root', pwd: "root", roles: [ { role: "root", db: "admin" } ], digestPassword: true
403-
// }, function(err, r) {
404-
// test.equal(null, err);
405-
//
406-
// executeCommand(configuration, 'test', {
407-
// createUser: 'admin', pwd: "admin", roles: [ "readWrite", "dbAdmin" ], digestPassword: true
408-
// }, { auth: [method, 'admin', 'root', 'root'] }, function(err, r) {
409-
// test.equal(null, err);
410-
//
411-
// // Attempt to connect
412-
// var server = new Server({
413-
// host: configuration.host, port: configuration.port, bson: new bson()
414-
// })
415-
//
416-
// var index = 0;
417-
//
418-
// var messageHandler = function(err, result) {
419-
// index = index + 1;
420-
//
421-
// // Tests
422-
// test.equal(null, err);
423-
// test.equal(1, result.result.n);
424-
// // Did we receive an answer for all the messages
425-
// if(index == 100) {
426-
// test.equal(5, server.s.pool.socketCount());
427-
//
428-
// server.destroy();
429-
// // console.log("=================== " + Object.keys(Connection.connections()).length)
430-
// test.equal(0, Object.keys(Connection.connections()).length);
431-
// Connection.disableConnectionAccounting();
432-
// test.done();
433-
// }
434-
// }
435-
//
436-
// // Add event listeners
437-
// server.on('connect', function(_pool) {
438-
// for(var i = 0; i < 10; i++)
439-
// process.nextTick(function() {
440-
// server.insert('test.test', [{a:1}], messageHandler);
441-
// server.insert('test.test', [{a:1}], messageHandler);
442-
// server.insert('test.test', [{a:1}], messageHandler);
443-
// server.insert('test.test', [{a:1}], messageHandler);
444-
// server.insert('test.test', [{a:1}], messageHandler);
445-
// server.insert('test.test', [{a:1}], messageHandler);
446-
// server.insert('test.test', [{a:1}], messageHandler);
447-
// server.insert('test.test', [{a:1}], messageHandler);
448-
// server.insert('test.test', [{a:1}], messageHandler);
449-
// server.insert('test.test', [{a:1}], messageHandler);
450-
// });
451-
// });
452-
//
453-
// // Start connection
454-
// server.connect({auth: [method, 'test', 'admin', 'admin']});
455-
// });
456-
// });
457-
// });
458-
// });
459-
// }
460-
// }
461-
//
462-
// exports['Should correctly authenticate server using scram-sha-1 using auth method'] = {
463-
// metadata: { requires: { topology: "auth" } },
464-
//
465-
// test: function(configuration, test) {
466-
// var Server = require('../../../lib/topologies/server')
467-
// , Connection = require('../../../lib/connection/connection')
468-
// , bson = require('bson')
469-
// , Query = require('../../../lib/connection/commands').Query;
470-
//
471-
// // Enable connections accounting
472-
// Connection.enableConnectionAccounting();
473-
//
474-
// // Restart instance
475-
// configuration.manager.restart(true).then(function() {
476-
// locateAuthMethod(configuration, function(err, method) {
477-
// test.equal(null, err);
478-
//
479-
// executeCommand(configuration, 'admin', {
480-
// createUser: 'root', pwd: "root", roles: [ { role: "root", db: "admin" } ], digestPassword: true
481-
// }, function(err, r) {
482-
// test.equal(null, err);
483-
//
484-
// executeCommand(configuration, 'test', {
485-
// createUser: 'admin', pwd: "admin", roles: [ "readWrite", "dbAdmin" ], digestPassword: true
486-
// }, { auth: [method, 'admin', 'root', 'root'] }, function(err, r) {
487-
// test.equal(null, err);
488-
//
489-
// // Attempt to connect
490-
// var server = new Server({
491-
// host: configuration.host, port: configuration.port, bson: new bson()
492-
// })
493-
//
494-
// var index = 0;
495-
// var error = false;
496-
//
497-
// var messageHandler = function(err, result) {
498-
// index = index + 1;
499-
//
500-
// // Tests
501-
// test.equal(null, err);
502-
// test.equal(1, result.result.n);
503-
// // Did we receive an answer for all the messages
504-
// if(index == 100) {
505-
// test.equal(5, server.s.pool.socketCount());
506-
// test.equal(false, error);
507-
//
508-
// server.destroy();
509-
// // console.log("=================== " + Object.keys(Connection.connections()).length)
510-
// test.equal(0, Object.keys(Connection.connections()).length);
511-
// Connection.disableConnectionAccounting();
512-
// test.done();
513-
// }
514-
// }
515-
//
516-
// // Add event listeners
517-
// server.on('connect', function(_server) {
518-
// _server.auth(method, 'test', 'admin', 'admin', function(err, r) {
519-
// for(var i = 0; i < 100; i++) {
520-
// // console.log("!!!!!!!!!!! 1")
521-
// process.nextTick(function() {
522-
// server.insert('test.test', [{a:1}], messageHandler);
523-
// });
524-
// }
525-
// });
526-
//
527-
// for(var i = 0; i < 100; i++) {
528-
// process.nextTick(function() {
529-
// // console.log("!!!!!!!!!!! 0")
530-
// _server.command('admin.$cmd', {ismaster:true}, function(e, r) {
531-
// // console.dir(e)
532-
// if(e) error = e;
533-
// });
534-
// });
535-
// }
536-
// });
537-
//
538-
// // Start connection
539-
// server.connect();
540-
// });
541-
// });
542-
// });
543-
// });
544-
// }
545-
// }
546-
//
547-
// exports['Should correctly authenticate server using scram-sha-1 using connect auth then logout'] = {
548-
// metadata: { requires: { topology: "auth" } },
549-
//
550-
// test: function(configuration, test) {
551-
// var Server = require('../../../lib/topologies/server')
552-
// , Connection = require('../../../lib/connection/connection')
553-
// , bson = require('bson')
554-
// , Query = require('../../../lib/connection/commands').Query;
555-
//
556-
// // Enable connections accounting
557-
// Connection.enableConnectionAccounting();
558-
//
559-
// // Restart instance
560-
// configuration.manager.restart(true).then(function() {
561-
// locateAuthMethod(configuration, function(err, method) {
562-
// test.equal(null, err);
563-
//
564-
// executeCommand(configuration, 'admin', {
565-
// createUser: 'root', pwd: "root", roles: [ { role: "root", db: "admin" } ], digestPassword: true
566-
// }, function(err, r) {
567-
// test.equal(null, err);
568-
//
569-
// executeCommand(configuration, 'test', {
570-
// createUser: 'admin', pwd: "admin", roles: [ "readWrite", "dbAdmin" ], digestPassword: true
571-
// }, { auth: [method, 'admin', 'root', 'root'] }, function(err, r) {
572-
// test.equal(null, err);
573-
// // Attempt to connect
574-
// var server = new Server({
575-
// host: configuration.host, port: configuration.port, bson: new bson()
576-
// })
577-
//
578-
// // Add event listeners
579-
// server.on('connect', function(_server) {
580-
// _server.insert('test.test', [{a:1}], function(err, r) {
581-
// // console.dir(err)
582-
// test.equal(null, err);
583-
//
584-
// // Logout pool
585-
// _server.logout('test', function(err) {
586-
// test.equal(null, err);
587-
//
588-
// _server.insert('test.test', [{a:1}], function(err, r) {
589-
// test.ok(err != null);
590-
//
591-
// _server.destroy();
592-
// // console.log("=================== " + Object.keys(Connection.connections()).length)
593-
// test.equal(0, Object.keys(Connection.connections()).length);
594-
// // console.log("============================ 5")
595-
// Connection.disableConnectionAccounting();
596-
// test.done();
597-
// });
598-
// });
599-
// });
600-
// });
601-
//
602-
// // Start connection
603-
// server.connect({auth: [method, 'test', 'admin', 'admin']});
604-
// });
605-
// });
606-
// });
607-
// });
608-
// }
609-
// }
610-
//
611-
// exports['Should correctly have server auth wait for logout to finish'] = {
612-
// metadata: { requires: { topology: "auth" } },
613-
//
614-
// test: function(configuration, test) {
615-
// var Server = require('../../../lib/topologies/server')
616-
// , Connection = require('../../../lib/connection/connection')
617-
// , bson = require('bson')
618-
// , Query = require('../../../lib/connection/commands').Query;
619-
//
620-
// // Enable connections accounting
621-
// Connection.enableConnectionAccounting();
622-
//
623-
// // Restart instance
624-
// configuration.manager.restart(true).then(function() {
625-
// locateAuthMethod(configuration, function(err, method) {
626-
// test.equal(null, err);
627-
//
628-
// executeCommand(configuration, 'admin', {
629-
// createUser: 'root', pwd: "root", roles: [ { role: "root", db: "admin" } ], digestPassword: true
630-
// }, function(err, r) {
631-
// test.equal(null, err);
632-
//
633-
// executeCommand(configuration, 'test', {
634-
// createUser: 'admin', pwd: "admin", roles: [ "readWrite", "dbAdmin" ], digestPassword: true
635-
// }, { auth: [method, 'admin', 'root', 'root'] }, function(err, r) {
636-
// test.equal(null, err);
637-
// // Attempt to connect
638-
// var server = new Server({
639-
// host: configuration.host, port: configuration.port, bson: new bson()
640-
// })
641-
//
642-
// // Add event listeners
643-
// server.on('connect', function(_server) {
644-
// _server.insert('test.test', [{a:1}], function(err, r) {
645-
// test.equal(null, err);
646-
//
647-
// // Logout pool
648-
// _server.logout('test', function(err) {
649-
// test.equal(null, err);
650-
// });
651-
//
652-
// _server.auth(method, 'test', 'admin', 'admin', function(err, r) {
653-
// test.equal(null, err);
654-
//
655-
// _server.insert('test.test', [{a:1}], function(err, r) {
656-
// test.equal(null, err);
657-
//
658-
// _server.destroy();
659-
// // console.log("=================== " + Object.keys(Connection.connections()).length)
660-
// test.equal(0, Object.keys(Connection.connections()).length);
661-
// Connection.disableConnectionAccounting();
662-
// test.done();
663-
// });
664-
// });
665-
// });
666-
// });
667-
//
668-
// // Start connection
669-
// server.connect({auth:[method, 'test', 'admin', 'admin']});
670-
// });
671-
// });
672-
// });
673-
// });
674-
// }
675-
// }
358+
}
359+
});
360+
});

‎test/tests/functional/basic_single_server_auth_tests.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var expect = require('chai').expect,
77
Connection = require('../../../lib/connection/connection'),
88
Bson = require('bson');
99

10-
describe.only('Basic single server auth tests', function() {
10+
describe('Basic single server auth tests', function() {
1111
it('should fail to authenticate server using scram-sha-1 using connect auth', {
1212
metadata: { requires: { topology: 'auth' } },
1313

0 commit comments

Comments
 (0)
This repository has been archived.