diff options
author | Andy Schwerin <schwerin@10gen.com> | 2013-08-23 17:13:35 -0400 |
---|---|---|
committer | Andy Schwerin <schwerin@10gen.com> | 2013-09-03 18:14:01 -0400 |
commit | 5fb2c2c35426d907057bccf6ffefec0493897af6 (patch) | |
tree | 3f4106feb72f3d3eb1f769a98c9b12de65dad785 /src/mongo/db/auth/authz_manager_external_state_mock.h | |
parent | 2f0c929ee17921cf122a3f3fb73f826841126a0c (diff) | |
download | mongo-5fb2c2c35426d907057bccf6ffefec0493897af6.tar.gz |
SERVER-9516 Logic of system.users schema upgrade process.
Includes AuthorizationManagerExternalState interface changes and implementation
in the mock, plus unit tests.
Diffstat (limited to 'src/mongo/db/auth/authz_manager_external_state_mock.h')
-rw-r--r-- | src/mongo/db/auth/authz_manager_external_state_mock.h | 58 |
1 files changed, 44 insertions, 14 deletions
diff --git a/src/mongo/db/auth/authz_manager_external_state_mock.h b/src/mongo/db/auth/authz_manager_external_state_mock.h index 7551af9c427..e835966929e 100644 --- a/src/mongo/db/auth/authz_manager_external_state_mock.h +++ b/src/mongo/db/auth/authz_manager_external_state_mock.h @@ -17,13 +17,14 @@ #pragma once #include <string> +#include <map> #include <vector> #include "mongo/base/disallow_copying.h" #include "mongo/base/status.h" #include "mongo/db/auth/authz_manager_external_state.h" #include "mongo/db/jsobj.h" -#include "mongo/platform/unordered_map.h" +#include "mongo/db/namespace_string.h" namespace mongo { @@ -37,35 +38,64 @@ namespace mongo { AuthzManagerExternalStateMock() {}; - // no-op for the mock virtual Status insertPrivilegeDocument(const std::string& dbname, - const BSONObj& userObj) const; + const BSONObj& userObj); - // no-op for the mock virtual Status updatePrivilegeDocument(const UserName& user, - const BSONObj& updateObj) const; + const BSONObj& updateObj); - // no-op for the mock virtual Status removePrivilegeDocuments(const std::string& dbname, - const BSONObj& query) const; - - // Non-const version that puts document into a vector that can be accessed later - Status insertPrivilegeDocument(const std::string& dbname, const BSONObj& userObj); + const BSONObj& query); void clearPrivilegeDocuments(); - virtual Status getAllDatabaseNames(std::vector<std::string>* dbnames) const; + virtual Status getAllDatabaseNames(std::vector<std::string>* dbnames); virtual Status getAllV1PrivilegeDocsForDB(const std::string& dbname, - std::vector<BSONObj>* privDocs) const; + std::vector<BSONObj>* privDocs); virtual Status _findUser(const std::string& usersNamespace, const BSONObj& query, - BSONObj* result) const; + BSONObj* result); + + virtual Status findOne(const NamespaceString& collectionName, + const BSONObj& query, + BSONObj* result); + + // This implementation does not understand uniqueness constraints. + virtual Status insert(const NamespaceString& collectionName, + const BSONObj& document); + // This implementation does not understand uniqueness constraints, + // and only correctly handles some upsert behaviors. + virtual Status updateOne(const NamespaceString& collectionName, + const BSONObj& query, + const BSONObj& updatePattern, + bool upsert); + virtual Status remove(const NamespaceString& collectionName, + const BSONObj& query); + virtual Status createIndex(const NamespaceString& collectionName, + const BSONObj& pattern, + bool unique); + virtual Status dropCollection(const NamespaceString& collectionName); + virtual Status renameCollection(const NamespaceString& oldName, + const NamespaceString& newName); + virtual Status copyCollection(const NamespaceString& fromName, + const NamespaceString& toName); + virtual bool tryLockUpgradeProcess(); + virtual void unlockUpgradeProcess(); + + std::vector<BSONObj> getCollectionContents(const NamespaceString& collectionName); private: - unordered_map<std::string, std::vector<BSONObj> > _userDocuments; // dbname to user docs + typedef std::vector<BSONObj> BSONObjCollection; + typedef std::map<NamespaceString, BSONObjCollection> NamespaceDocumentMap; + + Status _findOneIter(const NamespaceString& collectionName, + const BSONObj& query, + BSONObjCollection::iterator* result); + + NamespaceDocumentMap _documents; // Mock database. }; } // namespace mongo |