BalanaPDP implements PDP { @Override public Response evaluate(Request request) { return evaluate(request, vf.createIRI(POLICY_DENY_OVERRIDES)); }  @Activate void setUp(); @Override Request createRequest(IRI subjectId, Map<String, Literal> subjectAttrs, IRI resourceId,
                                 Map<String, Literal> resourceAttrs, IRI actionId, Map<String, Literal> actionAttrs); @Override Response evaluate(Request request); @Override Response evaluate(Request request, IRI policyAlgorithm);  }
@Test public void simplePermitTest() throws Exception { loadPolicy(policy1); BalanaRequest request = new BalanaRequest.Builder(userX, resource, createAction, OffsetDateTime.now(), VALUE_FACTORY, jaxbContext).build(); Response result = pdp.evaluate(request); assertEquals(Decision.PERMIT, result.getDecision()); assertEquals(Status.OK, result.getStatus()); assertTrue(result.getPolicyIds().contains(policy1)); }
@Test public void missingAttributeTest() throws Exception { loadPolicy(policy2); BalanaRequest.Builder builder = new BalanaRequest.Builder(userX, resource, createAction, OffsetDateTime.now(), VALUE_FACTORY, jaxbContext); builder.addActionAttr(Resource.type_IRI, actionType); Response result = pdp.evaluate(builder.build()); assertEquals(Decision.DENY, result.getDecision()); assertEquals(Status.OK, result.getStatus()); assertTrue(result.getPolicyIds().contains(policy2)); }
@Test public void unsupportedCategoryInRuleTest() throws Exception { loadPolicy(policy3); BalanaRequest.Builder builder = new BalanaRequest.Builder(userX, resource, createAction, OffsetDateTime.now(), VALUE_FACTORY, jaxbContext); builder.addActionAttr(Resource.type_IRI, actionType); Response result = pdp.evaluate(builder.build()); assertEquals(Decision.DENY, result.getDecision()); assertEquals(Status.OK, result.getStatus()); assertTrue(result.getPolicyIds().contains(policy3)); }
@Test public void noPolicyTest() throws Exception { BalanaRequest request = new BalanaRequest.Builder(userX, resource, createAction, OffsetDateTime.now(), VALUE_FACTORY, jaxbContext).build(); Response result = pdp.evaluate(request); assertEquals(Status.OK, result.getStatus()); assertEquals(Decision.NOT_APPLICABLE, result.getDecision()); assertTrue(result.getPolicyIds().isEmpty()); }