@@ -717,7 +717,7 @@ describe('Auth e2e', function() {
717
717
afterEach ( async ( ) => {
718
718
db . command ( { dropAllUsersFromDatabase : 1 } ) ;
719
719
} ) ;
720
- describe ( 'auth' , async ( ) => {
720
+ describe ( 'auth' , ( ) => {
721
721
it ( 'logs in with simple user/pwd' , async ( ) => {
722
722
shell . writeInputLine ( `use ${ dbName } ` ) ;
723
723
shell . writeInputLine (
@@ -796,7 +796,7 @@ describe('Auth e2e', function() {
796
796
} ) ;
797
797
} ) ;
798
798
} ) ;
799
- describe ( 'logout' , async ( ) => {
799
+ describe ( 'logout' , ( ) => {
800
800
it ( 'logs out after authenticating' , async ( ) => {
801
801
shell . writeInputLine ( `use ${ dbName } ` ) ;
802
802
shell . writeInputLine (
@@ -826,6 +826,35 @@ describe('Auth e2e', function() {
826
826
shell . assertNoErrors ( ) ;
827
827
} ) ;
828
828
} ) ;
829
+ describe ( 'resetting current cursor' , ( ) => {
830
+ beforeEach ( async ( ) => {
831
+ await db . collection ( 'test' ) . insertMany (
832
+ [ ...Array ( 200 ) . keys ( ) ] . map ( i => ( { i } ) )
833
+ ) ;
834
+ } ) ;
835
+ it ( 'is reset after auth, db reassign and logout' , async ( ) => {
836
+ await shell . executeLine ( `use ${ dbName } ` ) ;
837
+ expect ( await shell . executeLine ( 'db.test.find()' ) ) . to . include ( 'i: 10' ) ;
838
+ expect ( await shell . executeLine ( 'it' ) ) . to . include ( 'i: 30' ) ;
839
+
840
+ expect ( await shell . executeLine ( 'db.auth("anna", "pwd")' ) ) . to . include ( 'ok: 1' ) ;
841
+ expect ( await shell . executeLine ( 'it' ) ) . to . include ( 'no cursor' ) ;
842
+ expect ( await shell . executeLine ( 'db.test.find()' ) ) . to . include ( 'i: 10' ) ;
843
+ expect ( await shell . executeLine ( 'it' ) ) . to . include ( 'i: 30' ) ;
844
+
845
+ expect ( await shell . executeLine ( `db = db.getSiblingDB("${ dbName } ")` ) ) . to . include ( `${ dbName } \n` ) ;
846
+ expect ( await shell . executeLine ( 'it' ) ) . to . include ( 'no cursor' ) ;
847
+ expect ( await shell . executeLine ( 'db.test.find()' ) ) . to . include ( 'i: 10' ) ;
848
+ expect ( await shell . executeLine ( 'it' ) ) . to . include ( 'i: 30' ) ;
849
+
850
+ expect ( await shell . executeLine ( 'db.logout()' ) ) . to . include ( 'ok: 1' ) ;
851
+ expect ( await shell . executeLine ( 'it' ) ) . to . include ( 'no cursor' ) ;
852
+ expect ( await shell . executeLine ( 'db.test.find()' ) ) . to . include ( 'i: 10' ) ;
853
+ expect ( await shell . executeLine ( 'it' ) ) . to . include ( 'i: 30' ) ;
854
+
855
+ shell . assertNoErrors ( ) ;
856
+ } ) ;
857
+ } ) ;
829
858
} ) ;
830
859
} ) ;
831
860
describe ( 'with options in URI on on the command line' , ( ) => {
0 commit comments