@@ -731,22 +731,30 @@ public async Task TestInitEmptyByInputStreamAsync()
731
731
public void TestReloadPolicy ( )
732
732
{
733
733
Enforcer e = new ( "Examples/rbac_model.conf" , "Examples/rbac_policy.csv" ) ;
734
-
735
734
e . LoadPolicy ( ) ;
736
- TestGetPolicy ( e ,
737
- AsList ( AsList ( "alice" , "data1" , "read" ) , AsList ( "bob" , "data2" , "write" ) ,
738
- AsList ( "data2_admin" , "data2" , "read" ) , AsList ( "data2_admin" , "data2" , "write" ) ) ) ;
735
+ e . TestGetPolicy (
736
+ [
737
+ [ "alice" , "data1" , "read" ] ,
738
+ [ "bob" , "data2" , "write" ] ,
739
+ [ "data2_admin" , "data2" , "read" ] ,
740
+ [ "data2_admin" , "data2" , "write" ]
741
+ ]
742
+ ) ;
739
743
}
740
744
741
745
[ Fact ]
742
746
public async Task TestReloadPolicyAsync ( )
743
747
{
744
748
Enforcer e = new ( "Examples/rbac_model.conf" , "Examples/rbac_policy.csv" ) ;
745
-
746
749
await e . LoadPolicyAsync ( ) ;
747
- TestGetPolicy ( e ,
748
- AsList ( AsList ( "alice" , "data1" , "read" ) , AsList ( "bob" , "data2" , "write" ) ,
749
- AsList ( "data2_admin" , "data2" , "read" ) , AsList ( "data2_admin" , "data2" , "write" ) ) ) ;
750
+ e . TestGetPolicy (
751
+ [
752
+ [ "alice" , "data1" , "read" ] ,
753
+ [ "bob" , "data2" , "write" ] ,
754
+ [ "data2_admin" , "data2" , "read" ] ,
755
+ [ "data2_admin" , "data2" , "write" ]
756
+ ]
757
+ ) ;
750
758
}
751
759
752
760
[ Fact ]
@@ -880,7 +888,7 @@ public void TestEnableAutoSave()
880
888
// Reload the policy from the storage to see the effect.
881
889
e . LoadPolicy ( ) ;
882
890
883
- Assert . True ( e . Enforce ( "alice" , "data1" , "read" ) ) ; // Will not be false here.
891
+ Assert . True ( e . Enforce ( "alice" , "data1" , "read" ) ) ; // Will not be false here.
884
892
Assert . False ( e . Enforce ( "alice" , "data1" , "write" ) ) ;
885
893
Assert . False ( e . Enforce ( "alice" , "data2" , "read" ) ) ;
886
894
Assert . False ( e . Enforce ( "alice" , "data2" , "write" ) ) ;
@@ -1068,22 +1076,21 @@ public async Task TestEnforceExApiAsync()
1068
1076
e . BuildRoleLinks ( ) ;
1069
1077
1070
1078
await e . TestEnforceExAsync ( "alice" , "data1" , "read" , new List < string > { "alice" , "data1" , "read" , "allow" } ) ;
1071
- await e . TestEnforceExAsync ( "alice" , "data1" , "write" , new List < string > { "data1_deny_group" , "data1" , "write" , "deny" } ) ;
1079
+ await e . TestEnforceExAsync ( "alice" , "data1" , "write" ,
1080
+ new List < string > { "data1_deny_group" , "data1" , "write" , "deny" } ) ;
1072
1081
await e . TestEnforceExAsync ( "alice" , "data2" , "read" , new List < string > ( ) ) ;
1073
1082
await e . TestEnforceExAsync ( "alice" , "data2" , "write" , new List < string > ( ) ) ;
1074
1083
await e . TestEnforceExAsync ( "bob" , "data1" , "write" , new List < string > ( ) ) ;
1075
- await e . TestEnforceExAsync ( "bob" , "data2" , "read" , new List < string > { "data2_allow_group" , "data2" , "read" , "allow" } ) ;
1084
+ await e . TestEnforceExAsync ( "bob" , "data2" , "read" ,
1085
+ new List < string > { "data2_allow_group" , "data2" , "read" , "allow" } ) ;
1076
1086
await e . TestEnforceExAsync ( "bob" , "data2" , "write" , new List < string > { "bob" , "data2" , "write" , "deny" } ) ;
1077
1087
}
1078
1088
1079
1089
#if ! NET452
1080
1090
[ Fact ]
1081
1091
public void TestEnforceExApiLog ( )
1082
1092
{
1083
- Enforcer e = new ( TestModelFixture . GetBasicTestModel ( ) )
1084
- {
1085
- Logger = new MockLogger < Enforcer > ( _testOutputHelper )
1086
- } ;
1093
+ Enforcer e = new ( TestModelFixture . GetBasicTestModel ( ) ) { Logger = new MockLogger < Enforcer > ( _testOutputHelper ) } ;
1087
1094
1088
1095
e . TestEnforceEx ( "alice" , "data1" , "read" , new List < string > { "alice" , "data1" , "read" } ) ;
1089
1096
e . TestEnforceEx ( "alice" , "data1" , "write" , new List < string > ( ) ) ;
0 commit comments