-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix privilege checker when toCheck is empty
- Loading branch information
1 parent
eea7697
commit 91ed8f3
Showing
3 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/test/java/gov/nist/csd/pm/pap/op/PrivilegeCheckerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package gov.nist.csd.pm.pap.op; | ||
|
||
import gov.nist.csd.pm.impl.memory.pap.MemoryPAP; | ||
import gov.nist.csd.pm.pap.exception.PMException; | ||
import gov.nist.csd.pm.pap.query.model.context.UserContext; | ||
import gov.nist.csd.pm.pap.serialization.pml.PMLDeserializer; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class PrivilegeCheckerTest { | ||
|
||
@Test | ||
void testEmptyToCheck() throws PMException { | ||
String pml = """ | ||
set resource operations ["read"] | ||
create pc "pc1" | ||
create ua "ua1" in ["pc1"] | ||
create ua "ua2" in ["pc1"] | ||
create oa "oa1" in ["pc1"] | ||
associate "ua1" and "oa1" with ["read"] | ||
create u "u1" in ["ua1"] | ||
create u "u2" in ["ua2"] | ||
create o "o1" in ["oa1"] | ||
"""; | ||
|
||
MemoryPAP pap = new MemoryPAP(); | ||
pap.deserialize(new UserContext("u1"), pml, new PMLDeserializer()); | ||
|
||
PrivilegeChecker checker = new PrivilegeChecker(pap); | ||
assertDoesNotThrow(() -> checker.check(new UserContext("u1"), "o1", List.of())); | ||
assertThrows(PMException.class, () -> checker.check(new UserContext("u2"), "o1", List.of())); | ||
} | ||
|
||
} |