@@ -157,32 +157,27 @@ var testOps = function(db, allowedActions) {
157
157
var dbName = db . getName ( ) ;
158
158
var db2 = newConn . getDB ( dbName ) ;
159
159
160
- if ( db2 == 'admin' ) {
160
+ if ( db2 . getName ( ) == 'admin' ) {
161
161
assert . eq ( 1 , db2 . auth ( 'aro' , AUTH_INFO . admin . aro . pwd ) ) ;
162
162
} else {
163
163
assert . eq ( 1 , db2 . auth ( 'ro' , AUTH_INFO . test . ro . pwd ) ) ;
164
164
}
165
165
166
- var cursor = db2 . kill_cursor . find ( ) . batchSize ( 2 ) ;
167
-
168
- db . killCursor ( cursor . id ( ) ) ;
169
- // Send a synchronous message to make sure that kill cursor was processed
170
- // before proceeding.
171
- db . runCommand ( { whatsmyuri : 1 } ) ;
172
-
173
- checkErr ( ! allowedActions . hasOwnProperty ( 'killCursor' ) , function ( ) {
174
- while ( cursor . hasNext ( ) ) {
175
- var next = cursor . next ( ) ;
176
-
177
- // This is a failure in mongos case. Standalone case will fail
178
- // when next() was called.
179
- if ( next . code == 16336 ) {
180
- // could not find cursor in cache for id
181
- throw next . $err ;
182
- }
183
- }
166
+ // Create cursor from db2.
167
+ var cmdRes = db2 . runCommand ( { find : db2 . kill_cursor . getName ( ) , batchSize : 2 } ) ;
168
+ assert . commandWorked ( cmdRes ) ;
169
+ var cursorId = cmdRes . cursor . id ;
170
+ assert ( ! bsonBinaryEqual ( { cursorId : cursorId } , { cursorId : NumberLong ( 0 ) } ) ,
171
+ "find command didn't return a cursor: " + tojson ( cmdRes ) ) ;
172
+
173
+ checkErr ( allowedActions . hasOwnProperty ( 'killCursor' ) , function ( ) {
174
+ // Issue killCursor command from db.
175
+ cmdRes = db . runCommand ( { killCursors : db2 . kill_cursor . getName ( ) , cursors : [ cursorId ] } ) ;
176
+ assert . commandWorked ( cmdRes ) ;
177
+ assert ( bsonBinaryEqual ( { cursorId : cmdRes . cursorsKilled } , { cursorId : [ cursorId ] } ) ,
178
+ "unauthorized to kill cursor: " + tojson ( cmdRes ) ) ;
184
179
} ) ;
185
- } ) ; // TODO: enable test after SERVER-5813 is fixed.
180
+ } ) ( ) ;
186
181
187
182
var isMongos = db . runCommand ( { isdbgrid : 1 } ) . isdbgrid ;
188
183
// Note: fsyncUnlock is not supported in mongos.
@@ -192,7 +187,7 @@ var testOps = function(db, allowedActions) {
192
187
var errorCodeUnauthorized = 13 ;
193
188
194
189
if ( res . code == errorCodeUnauthorized ) {
195
- throw Error ( "unauthorized unauthorized fsyncUnlock" ) ;
190
+ throw Error ( "unauthorized fsyncUnlock" ) ;
196
191
}
197
192
} ) ;
198
193
}
0 commit comments