diff --git a/casbin/enforcer.cpp b/casbin/enforcer.cpp index 8a1be294..d52ac186 100644 --- a/casbin/enforcer.cpp +++ b/casbin/enforcer.cpp @@ -25,6 +25,7 @@ #include "./enforcer.h" #include "./persist/watcher_ex.h" #include "./persist/file_adapter/file_adapter.h" +#include "./persist/file_adapter/batch_file_adapter.h" #include "./rbac/default_role_manager.h" #include "./effect/default_effector.h" #include "./exception/casbin_adapter_exception.h" @@ -179,7 +180,7 @@ Enforcer ::Enforcer() { * @param policyFile the path of the policy file. */ Enforcer ::Enforcer(const std::string& model_path, const std::string& policy_file) - : Enforcer(model_path, std::make_shared(policy_file)) { + : Enforcer(model_path, std::make_shared(policy_file)) { } /** @@ -233,14 +234,14 @@ Enforcer ::Enforcer(const std::string& model_path): Enforcer(model_path, "") { * @param enableLog whether to enable Casbin's log. */ Enforcer::Enforcer(const std::string& model_path, const std::string& policy_file, bool enable_log) - : Enforcer(model_path, std::make_shared(policy_file)) { + : Enforcer(model_path, std::make_shared(policy_file)) { this->EnableLog(enable_log); } // InitWithFile initializes an enforcer with a model file and a policy file. void Enforcer::InitWithFile(const std::string& model_path, const std::string& policy_path) { - std::shared_ptr a = std::make_shared(policy_path); + std::shared_ptr a = std::make_shared(policy_path); this->InitWithAdapter(model_path, a); } diff --git a/tests/rbac_api_test.cpp b/tests/rbac_api_test.cpp index 41d68041..93cb5ddc 100644 --- a/tests/rbac_api_test.cpp +++ b/tests/rbac_api_test.cpp @@ -222,8 +222,10 @@ TEST(TestRBACAPI, TestImplicitUserAPI) { e.ClearPolicy(); e.AddPolicy({ "admin", "data1", "read" }); e.AddPolicy({ "bob", "data1", "read" }); + e.AddPolicies({{ "tom", "data1", "read" }, {"john", "data1", "read" }}); e.AddGroupingPolicy({ "alice", "admin" }); - ASSERT_TRUE(casbin::ArrayEquals({ "alice", "bob" }, e.GetImplicitUsersForPermission({ "data1", "read" }))); + + ASSERT_TRUE(casbin::ArrayEquals({ "alice", "bob", "tom", "john"}, e.GetImplicitUsersForPermission({ "data1", "read" }))); } } // namespace