summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests/directclienttests.cpp
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2012-05-25 14:16:15 -0400
committerRandolph Tan <randolph@10gen.com>2012-05-27 11:22:47 -0400
commit08e79fde14acc9eeaaf4364f9b95a2ade60a6832 (patch)
treea41d427f98008e26f04e1b8b2a742b07616cd9c5 /src/mongo/dbtests/directclienttests.cpp
parentea5f8bc08b8d9d68cdfd2d0c8c5e4962590f9b52 (diff)
downloadmongo-08e79fde14acc9eeaaf4364f9b95a2ade60a6832.tar.gz
SERVER-5926 Segfault when procesing a command with empty namespace
Added proper namespace checking before processing requests on mongod. Also added some fasserts on DBLocks
Diffstat (limited to 'src/mongo/dbtests/directclienttests.cpp')
-rw-r--r--src/mongo/dbtests/directclienttests.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/mongo/dbtests/directclienttests.cpp b/src/mongo/dbtests/directclienttests.cpp
index 744e49e9bb7..469a55c9b18 100644
--- a/src/mongo/dbtests/directclienttests.cpp
+++ b/src/mongo/dbtests/directclienttests.cpp
@@ -89,6 +89,54 @@ namespace DirectClientTests {
};
+ class BadNSCmd : ClientBase {
+ public:
+ virtual void run(){
+ BSONObj result;
+ BSONObj cmdObj = BSON( "count" << "" );
+ ASSERT_THROWS( client().runCommand( "", cmdObj, result ), UserException );
+ }
+ };
+
+ class BadNSQuery : ClientBase {
+ public:
+ virtual void run(){
+ BSONObj result = client().query( "", Query(), 1 )->next();
+ ASSERT( result.hasField( "$err" ));
+ }
+ };
+
+ class BadNSGetMore : ClientBase {
+ public:
+ virtual void run(){
+ ASSERT( !client().getMore( "", 1, 1 )->more() );
+ }
+ };
+
+ class BadNSInsert : ClientBase {
+ public:
+ virtual void run(){
+ client().insert( "", BSONObj(), 0 );
+ ASSERT( !client().getLastError().empty() );
+ }
+ };
+
+ class BadNSUpdate : ClientBase {
+ public:
+ virtual void run(){
+ client().update( "", Query(), BSON( "$set" << BSON( "x" << 1 )) );
+ ASSERT( !client().getLastError().empty() );
+ }
+ };
+
+ class BadNSRemove : ClientBase {
+ public:
+ virtual void run(){
+ client().remove( "", Query() );
+ ASSERT( !client().getLastError().empty() );
+ }
+ };
+
class All : public Suite {
public:
All() : Suite( "directclient" ) {
@@ -96,6 +144,12 @@ namespace DirectClientTests {
void setupTests() {
add< Capped >();
add< InsertMany >();
+ add< BadNSCmd >();
+ add< BadNSQuery >();
+ add< BadNSGetMore >();
+ add< BadNSInsert >();
+ add< BadNSUpdate >();
+ add< BadNSRemove >();
}
} myall;
}