diff options
author | Kyle Suarez <kyle.suarez@mongodb.com> | 2016-12-12 17:50:48 -0500 |
---|---|---|
committer | Kyle Suarez <kyle.suarez@mongodb.com> | 2016-12-13 11:41:15 -0500 |
commit | 59d4a5c9f80078f73f81483ac807a25256d281bb (patch) | |
tree | 9e11d84b7e2d951770f7965a8c24a5907e04a4b9 | |
parent | cddba78fe2accf9dd942df5a6bc75adf97efcba6 (diff) | |
download | mongo-59d4a5c9f80078f73f81483ac807a25256d281bb.tar.gz |
SERVER-27256 run getMore test sharded in views_authz.js
-rw-r--r-- | jstests/auth/views_authz.js | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/jstests/auth/views_authz.js b/jstests/auth/views_authz.js index 6e797be6c8e..4134a983ce9 100644 --- a/jstests/auth/views_authz.js +++ b/jstests/auth/views_authz.js @@ -114,31 +114,26 @@ ErrorCodes.InvalidOptions, "modified a view without having to specify 'pipeline'"); - // Performing a find on a readable view returns a cursor that allows us to perform a getMore - // even if the underlying collection is unreadable. - // TODO(SERVER-24771): getMore does not work yet for sharded clusters + // Create a view on a forbidden collection and populate it. assert.eq(1, adminDB.auth("admin", "admin")); - let isMaster = adminDB.runCommand({isMaster: 1}); - assert.commandWorked(isMaster); - const isMongos = (isMaster.msg === "isdbgrid"); - if (!isMongos) { - assert.commandWorked(viewsDB.createView("view2", "forbidden", [])); - for (let i = 0; i < 10; i++) { - assert.writeOK(viewsDB.forbidden.insert({x: 1})); - } - adminDB.logout(); - assert.commandFailedWithCode( - viewsDB.runCommand({find: "forbidden"}), - ErrorCodes.Unauthorized, - "successfully performed a find on an unreadable namespace"); - let res = viewsDB.runCommand({find: "view2", batchSize: 1}); - assert.commandWorked(res, "could not perform a find on a readable view"); - assert.eq(res.cursor.ns, - "views_authz.view2", - "performing find on a view does not return a cursor on the view namespace"); - assert.commandWorked(viewsDB.runCommand({getMore: res.cursor.id, collection: "view2"}), - "could not perform getMore on a readable view"); + assert.commandWorked(viewsDB.createView("view2", "forbidden", [])); + for (let i = 0; i < 10; i++) { + assert.writeOK(viewsDB.forbidden.insert({x: 1})); } + adminDB.logout(); + + // Performing a find on a readable view returns a cursor that allows us to perform a getMore + // even if the underlying collection is unreadable. + assert.commandFailedWithCode(viewsDB.runCommand({find: "forbidden"}), + ErrorCodes.Unauthorized, + "successfully performed a find on an unreadable namespace"); + let res = viewsDB.runCommand({find: "view2", batchSize: 1}); + assert.commandWorked(res, "could not perform a find on a readable view"); + assert.eq(res.cursor.ns, + "views_authz.view2", + "performing find on a view does not return a cursor on the view namespace"); + assert.commandWorked(viewsDB.runCommand({getMore: res.cursor.id, collection: "view2"}), + "could not perform getMore on a readable view"); } // Run the test on a standalone. |