diff options
author | Jonathan Abrahams <jonathan@mongodb.com> | 2016-03-09 12:17:50 -0500 |
---|---|---|
committer | Jonathan Abrahams <jonathan@mongodb.com> | 2016-03-09 12:18:14 -0500 |
commit | 4ae691e8edc87d0e3cfb633bb91c328426be007b (patch) | |
tree | 52079a593f54382ca13a2e741633eab1b6271893 /jstests/tool/restorewithauth.js | |
parent | a025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff) | |
download | mongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz |
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/tool/restorewithauth.js')
-rw-r--r-- | jstests/tool/restorewithauth.js | 66 |
1 files changed, 38 insertions, 28 deletions
diff --git a/jstests/tool/restorewithauth.js b/jstests/tool/restorewithauth.js index 6db4b0bf359..0fd29706ee1 100644 --- a/jstests/tool/restorewithauth.js +++ b/jstests/tool/restorewithauth.js @@ -1,5 +1,5 @@ /* SERVER-4972 - * Test for mongorestore on server with --auth allows restore without credentials of colls + * Test for mongorestore on server with --auth allows restore without credentials of colls * with no index */ /* @@ -14,14 +14,13 @@ * 9) Try restore with correct auth credentials. The restore should succeed this time. */ - baseName = "jstests_restorewithauth"; var conn = MongoRunner.runMongod({nojournal: "", bind_ip: "127.0.0.1"}); // write to ns foo.bar -var foo = conn.getDB( "foo" ); -for( var i = 0; i < 4; i++ ) { - foo["bar"].save( { "x": i } ); +var foo = conn.getDB("foo"); +for (var i = 0; i < 4; i++) { + foo["bar"].save({"x": i}); foo["baz"].save({"x": i}); } @@ -29,18 +28,18 @@ for( var i = 0; i < 4; i++ ) { var collNames = foo.getCollectionNames(); assert.neq(-1, collNames.indexOf("bar"), "bar collection doesn't exist"); -//make sure it has no index except _id +// make sure it has no index except _id assert.eq(foo.bar.getIndexes().length, 1); assert.eq(foo.baz.getIndexes().length, 1); -foo.bar.createIndex({x:1}); +foo.bar.createIndex({x: 1}); assert.eq(foo.bar.getIndexes().length, 2); assert.eq(foo.baz.getIndexes().length, 1); // get data dump var dumpdir = MongoRunner.dataDir + "/restorewithauth-dump1/"; -resetDbpath( dumpdir ); -x = runMongoProgram("mongodump", "--db", "foo", "-h", "127.0.0.1:"+ conn.port, "--out", dumpdir); +resetDbpath(dumpdir); +x = runMongoProgram("mongodump", "--db", "foo", "-h", "127.0.0.1:" + conn.port, "--out", dumpdir); // now drop the db foo.dropDatabase(); @@ -52,11 +51,11 @@ MongoRunner.stopMongod(conn); conn = MongoRunner.runMongod({auth: "", nojournal: "", bind_ip: "127.0.0.1"}); // admin user -var admin = conn.getDB( "admin" ); -admin.createUser({user: "admin" , pwd: "admin", roles: jsTest.adminUserRoles}); -admin.auth( "admin" , "admin" ); +var admin = conn.getDB("admin"); +admin.createUser({user: "admin", pwd: "admin", roles: jsTest.adminUserRoles}); +admin.auth("admin", "admin"); -var foo = conn.getDB( "foo" ); +var foo = conn.getDB("foo"); // make sure no collection with the same name exists collNames = foo.getCollectionNames(); @@ -64,7 +63,7 @@ assert.eq(-1, collNames.indexOf("bar"), "bar collection already exists"); assert.eq(-1, collNames.indexOf("baz"), "baz collection already exists"); // now try to restore dump -x = runMongoProgram( "mongorestore", "-h", "127.0.0.1:" + conn.port, "--dir" , dumpdir, "-vvvvv" ); +x = runMongoProgram("mongorestore", "-h", "127.0.0.1:" + conn.port, "--dir", dumpdir, "-vvvvv"); // make sure that the collection isn't restored collNames = foo.getCollectionNames(); @@ -72,14 +71,19 @@ assert.eq(-1, collNames.indexOf("bar"), "bar collection was restored"); assert.eq(-1, collNames.indexOf("baz"), "baz collection was restored"); // now try to restore dump with correct credentials -x = runMongoProgram( "mongorestore", - "-h", "127.0.0.1:" + conn.port, - "-d", "foo", - "--authenticationDatabase=admin", - "-u", "admin", - "-p", "admin", - "--dir", dumpdir + "foo/", - "-vvvvv"); +x = runMongoProgram("mongorestore", + "-h", + "127.0.0.1:" + conn.port, + "-d", + "foo", + "--authenticationDatabase=admin", + "-u", + "admin", + "-p", + "admin", + "--dir", + dumpdir + "foo/", + "-vvvvv"); // make sure that the collection was restored collNames = foo.getCollectionNames(); @@ -96,11 +100,16 @@ foo.createUser({user: 'user', pwd: 'password', roles: jsTest.basicUserRoles}); // now try to restore dump with foo database credentials x = runMongoProgram("mongorestore", - "-h", "127.0.0.1:" + conn.port, - "-d", "foo", - "-u", "user", - "-p", "password", - "--dir", dumpdir + "foo/", + "-h", + "127.0.0.1:" + conn.port, + "-d", + "foo", + "-u", + "user", + "-p", + "password", + "--dir", + dumpdir + "foo/", "-vvvvv"); // make sure that the collection was restored @@ -109,6 +118,7 @@ assert.neq(-1, collNames.indexOf("bar"), "bar collection was not restored"); assert.neq(-1, collNames.indexOf("baz"), "baz collection was not restored"); assert.eq(foo.bar.count(), 4); assert.eq(foo.baz.count(), 4); -assert.eq(foo.bar.getIndexes().length + foo.baz.getIndexes().length, 3); // _id on foo, _id on bar, x on foo +assert.eq(foo.bar.getIndexes().length + foo.baz.getIndexes().length, + 3); // _id on foo, _id on bar, x on foo MongoRunner.stopMongod(conn); |