@@ -32,4 +32,20 @@ public void testABAC() throws ParseException {
3232 assertEquals (Client .clientEnforce (new String []{"-m" ,"examples/abac_rule_with_domains_model.conf" ,"-p" ,"examples/abac_rule_with_domains_policy.csv" ,"-e" ,"bob,domain2,data2,read" }), true );
3333 }
3434
35+ @ Test
36+ public void testEnforceEx () throws ParseException {
37+ testEnforceExCli ((EnforceResult )Client .clientEnforce (new String []{"-m" , "examples/basic_model.conf" , "-p" , "examples/basic_policy.csv" , "-ex" , "alice,data1,read" }),true , new String []{"alice" , "data1" , "read" });
38+ testEnforceExCli ((EnforceResult )Client .clientEnforce (new String []{"-m" , "examples/basic_model.conf" , "-p" , "examples/basic_policy.csv" , "-ex" , "bob,data2,write" }),true , new String []{"bob" , "data2" , "write" });
39+ testEnforceExCli ((EnforceResult )Client .clientEnforce (new String []{"-m" , "examples/basic_model.conf" , "-p" , "examples/basic_policy.csv" , "-ex" , "root,data2,read" }),false , new String []{});
40+ testEnforceExCli ((EnforceResult )Client .clientEnforce (new String []{"-m" , "examples/basic_model.conf" , "-p" , "examples/basic_policy.csv" , "-ex" , "root,data3,read" }),false , new String []{});
41+ testEnforceExCli ((EnforceResult )Client .clientEnforce (new String []{"-m" , "examples/basic_model.conf" , "-p" , "examples/basic_policy.csv" , "-ex" , "jack,data3,read" }),false , new String []{});
42+ }
43+
44+ private void testEnforceExCli (EnforceResult enforceResult , boolean res , String [] explain ) {
45+ assertEquals (res , enforceResult .isAllow ());
46+ for (int i = 0 ; i < explain .length ; i ++) {
47+ assertEquals (explain [i ], enforceResult .getExplain ().get (i ));
48+ }
49+ }
50+
3551}
0 commit comments