diff options
author | Spencer Jackson <spencer.jackson@mongodb.com> | 2015-12-14 12:22:16 -0500 |
---|---|---|
committer | Spencer Jackson <spencer.jackson@mongodb.com> | 2015-12-15 15:59:58 -0500 |
commit | 21bcf6b127c1bb24e74845327e8d20df26e560bc (patch) | |
tree | 0a034064354ab57e70c37dc1daca1e7dafca2334 /jstests/tool | |
parent | 1ef94fe1099da7b6396bf9c0ddf93747c8b80f2a (diff) | |
download | mongo-21bcf6b127c1bb24e74845327e8d20df26e560bc.tar.gz |
SERVER-21724 Let backup role read system.profile
Diffstat (limited to 'jstests/tool')
-rw-r--r-- | jstests/tool/dumpauth.js | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/jstests/tool/dumpauth.js b/jstests/tool/dumpauth.js index 17cf5c19de7..ba8ee9a5f81 100644 --- a/jstests/tool/dumpauth.js +++ b/jstests/tool/dumpauth.js @@ -4,6 +4,8 @@ var m = MongoRunner.runMongod({auth: "", bind_ip: "127.0.0.1"}); var dbName = "admin" var colName = "testcol" +var profileName = "system.profile" +var dumpDir = MongoRunner.dataPath + "jstests_tool_dumprestore_dump_system_profile/"; db = m.getDB(dbName); db.createUser({user: "testuser" , pwd: "testuser", roles: jsTest.adminUserRoles}); @@ -11,16 +13,32 @@ assert( db.auth( "testuser" , "testuser" ) , "auth failed" ); t = db[colName]; t.drop(); +profile = db[profileName]; +profile.drop(); +// Activate profiling, to ensure that system.profile can be dumped with the backup role +db.setProfilingLevel(2); + +// Populate the database for(var i = 0; i < 100; i++) { t.save({ "x": i }); } +assert.gt(profile.count(), 0, "admin.system.profile should have documents"); +assert.eq(t.count(), 100, "testcol should have documents"); + +// Create a user with backup permissions +db.createUser({user: "backup" , pwd: "password", roles: ["backup"]}); +// Backup the database with the backup user x = runMongoProgram( "mongodump", "--db", dbName, + "--out", dumpDir, "--authenticationDatabase=admin", - "-u", "testuser", - "-p", "testuser", - "-h", "127.0.0.1:"+m.port, - "--collection", colName); + "-u", "backup", + "-p", "password", + "-h", "127.0.0.1:"+m.port); assert.eq(x, 0, "mongodump should succeed with authentication"); + +// Assert that a BSON document for admin.system.profile has been produced +x = runMongoProgram( "bsondump", dumpDir + "/" + dbName + "/" + profileName + ".bson" ); +assert.eq(x, 0, "bsondump should succeed parsing the profile data"); |