Meteor Velocity testing with mocha fails after securing mongo with authorisation

227 Views Asked by At

After securing mongo with the --auth parameter, I get the following error message:

MongoError: not authorized on mocha to execute command { listIndexes: "users", cursor: {} }

mongo is on my local machine on the default port localhost:27017. A google and stackexchange search reveals nothing similar, so any help with this would be appreciated.

Presumably all I need to do is give authorisation to whoever the user is on the 'mocha' db. Who is the user?

The full stack trace:

W20150822-22:58:09.173(1)? (STDERR) 

/Users/malcolm/.meteor/packages/velocity_meteor-tool/.1.1.3_2.1uk1vnq++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:278
W20150822-22:58:09.173(1)? (STDERR)                         throw(ex);
W20150822-22:58:09.173(1)? (STDERR)                               ^
W20150822-22:58:09.214(1)? (STDERR) MongoError: not authorized on mocha to execute command { listIndexes: "users", cursor: {} }
W20150822-22:58:09.214(1)? (STDERR)     at Object.Future.wait (/Users/malcolm/.meteor/packages/velocity_meteor-tool/.1.1.3_2.1uk1vnq++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:398:15)
W20150822-22:58:09.214(1)? (STDERR)     at [object Object].MongoConnection._ensureIndex (packages/mongo/mongo_driver.js:733:1)
W20150822-22:58:09.214(1)? (STDERR)     at [object Object].Mongo.Collection._ensureIndex (packages/mongo/collection.js:620:1)
W20150822-22:58:09.215(1)? (STDERR)     at Accounts.urls (packages/accounts-base/accounts_server.js:1309:1)
W20150822-22:58:09.215(1)? (STDERR)     at /private/var/folders/3n/2yry_ys510q6dx0frpznpc4c0000z_/T/meteor-test-run15cht13/.meteor/local/build/programs/server/packages/accounts-base.js:1616:4
W20150822-22:58:09.215(1)? (STDERR)     at /private/var/folders/3n/2yry_ys510q6dx0frpznpc4c0000z_/T/meteor-test-run15cht13/.meteor/local/build/programs/server/packages/accounts-base.js:1659:3
W20150822-22:58:09.215(1)? (STDERR)     at /private/var/folders/3n/2yry_ys510q6dx0frpznpc4c0000z_/T/meteor-test-run15cht13/.meteor/local/build/programs/server/boot.js:222:10
W20150822-22:58:09.215(1)? (STDERR)     at Array.forEach (native)
W20150822-22:58:09.215(1)? (STDERR)     at Function._.each._.forEach (/Users/malcolm/.meteor/packages/velocity_meteor-tool/.1.1.3_2.1uk1vnq++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20150822-22:58:09.215(1)? (STDERR)     at /private/var/folders/3n/2yry_ys510q6dx0frpznpc4c0000z_/T/meteor-test-run15cht13/.meteor/local/build/programs/server/boot.js:117:5
W20150822-22:58:09.215(1)? (STDERR)     - - - - -
W20150822-22:58:09.216(1)? (STDERR)     at Object.toError (/Users/malcolm/.meteor/packages/mongo/.1.1.0.1ruc6ua++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/utils.js:114:11)
W20150822-22:58:09.216(1)? (STDERR)     at /Users/malcolm/.meteor/packages/mongo/.1.1.0.1ruc6ua++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/db.js:1194:31
W20150822-22:58:09.216(1)? (STDERR)     at /Users/malcolm/.meteor/packages/mongo/.1.1.0.1ruc6ua++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/db.js:1903:9
W20150822-22:58:09.216(1)? (STDERR)     at Server.Base._callHandler (/Users/malcolm/.meteor/packages/mongo/.1.1.0.1ruc6ua++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/connection/base.js:453:41)
W20150822-22:58:09.216(1)? (STDERR)     at /Users/malcolm/.meteor/packages/mongo/.1.1.0.1ruc6ua++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/connection/server.js:487:18
W20150822-22:58:09.216(1)? (STDERR)     at [object Object].MongoReply.parseBody (/Users/malcolm/.meteor/packages/mongo/.1.1.0.1ruc6ua++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5)
W20150822-22:58:09.216(1)? (STDERR)     at [object Object].<anonymous> (/Users/malcolm/.meteor/packages/mongo/.1.1.0.1ruc6ua++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/connection/server.js:445:20)
W20150822-22:58:09.216(1)? (STDERR)     at [object Object].emit (events.js:95:17)
W20150822-22:58:09.216(1)? (STDERR)     at [object Object].<anonymous> (/Users/malcolm/.meteor/packages/mongo/.1.1.0.1ruc6ua++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:207:13)
W20150822-22:58:09.217(1)? (STDERR)     at [object Object].emit (events.js:98:17)
1

There are 1 best solutions below

0
On

The answer seems obvious now that I've worked it out.

The user who cannot read the mocha db is the user in the MONGO_URL, which in this example is myUser

export MONGO_URL="mongodb://myUser:password@localhost/mydb/?authSource=admin"

You have to give myUser a readWrite role for both your production db (mydb in this example) and to the mocha db.