@@ -479,8 +479,7 @@ TEST(TestModelEnforcer, TestRBACModelWithPattern) {
479479 // You can see in policy that: "g2, /book/:id, book_group", so in "g2()" function in the matcher, instead
480480 // of checking whether "/book/:id" equals the obj: "/book/1", it checks whether the pattern matches.
481481 // You can see it as normal RBAC: "/book/:id" == "/book/1" becomes KeyMatch2("/book/:id", "/book/1")
482- casbin::DefaultRoleManager* rm_tmp = dynamic_cast <casbin::DefaultRoleManager*>(e.rm .get ());
483- rm_tmp->AddMatchingFunc (casbin::KeyMatch2);
482+ e.AddNamedMatchingFunc (" p" , " " , casbin::KeyMatch2);
484483 casbin::Scope scope = InitializeParams (" alice" , " /book/1" , " GET" );
485484 TestEnforce (e, scope, true );
486485 scope = InitializeParams (" alice" , " /book/2" , " GET" );
@@ -500,7 +499,7 @@ TEST(TestModelEnforcer, TestRBACModelWithPattern) {
500499
501500 // AddMatchingFunc() is actually setting a function because only one function is allowed,
502501 // so when we set "KeyMatch3", we are actually replacing "KeyMatch2" with "KeyMatch3".
503- rm_tmp-> AddMatchingFunc ( casbin::KeyMatch3);
502+ e. AddNamedMatchingFunc ( " p " , " " , casbin::KeyMatch3);
504503 scope = InitializeParams (" alice" , " /book2/1" , " GET" );
505504 TestEnforce (e, scope, true );
506505 scope = InitializeParams (" alice" , " /book2/2" , " GET" );
0 commit comments