File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -1425,3 +1425,23 @@ struct GetDistinctCmd {
14251425 }
14261426};
14271427REGISTER_CMD (GetDistinctCmd, " distinct" );
1428+
1429+ struct ConnectionStatusCmd {
1430+ static const char * name;
1431+ static Future<Reference<ExtMsgReply>> call (Reference<ExtConnection> ec,
1432+ Reference<ExtMsgQuery> query,
1433+ Reference<ExtMsgReply> reply) {
1434+ const bool showPrivileges = query->query .getBoolField (" showPrivileges" );
1435+
1436+ bson::BSONObjBuilder authInfo;
1437+ authInfo.append (" authenticatedUsers" , std::vector<std::string>());
1438+ authInfo.append (" authenticatedUserRoles" , std::vector<std::string>());
1439+ if (showPrivileges) {
1440+ authInfo.append (" authenticatedUserPrivileges" , std::vector<std::string>());
1441+ }
1442+ reply->addDocument (BSON (" authInfo" << authInfo.obj () << " ok" << 1 ));
1443+
1444+ return reply;
1445+ }
1446+ };
1447+ REGISTER_CMD (ConnectionStatusCmd, " connectionstatus" );
Original file line number Diff line number Diff line change @@ -60,3 +60,18 @@ def test_simple_coll_index(fixture_collection):
6060 returned = collection .find ({'a' : {'$gt' : 10 , '$lt' : 21 }}).count ()
6161 assert returned == 10 , "Expected: 10, Received: {}" .format (returned )
6262
63+
64+ def test_connection_status (fixture_db ):
65+ db = fixture_db
66+ status = db .command ("connectionStatus" , showPrivileges = True )
67+ assert status ['authInfo' ]['authenticatedUsers' ] == list ()
68+ assert status ['authInfo' ]['authenticatedUserRoles' ] == list ()
69+ assert status ['authInfo' ]['authenticatedUserPrivileges' ] == list ()
70+ assert status ['ok' ] == 1
71+
72+ status = db .command ("connectionStatus" , showPrivileges = False )
73+ assert status ['authInfo' ]['authenticatedUsers' ] == list ()
74+ assert status ['authInfo' ]['authenticatedUserRoles' ] == list ()
75+ assert 'authenticatedUserPrivileges' not in status ['authInfo' ]
76+ assert status ['ok' ] == 1
77+
You can’t perform that action at this time.
0 commit comments