- public void test5MissingFields() throws FileNotFoundException, IOException, XacmlApplicationException,
- CoderException {
- LOGGER.info("**************** Running test5 ****************");
- //
- // Most likely we would not get a policy with missing fields passed to
- // us from the API. But in case that happens, or we decide that some fields
- // will be optional due to re-working of how the XACML policies are built,
- // let's add support in for that.
- //
- TestUtils.loadPolicies("src/test/resources/guard.policy-minmax-missing-fields1.yaml", service);
- //
- // We can create a DecisionRequest on the fly - no need
- // to have it in the .json files
- //
- DecisionRequest request = new DecisionRequest();
- request.setOnapName("JUnit");
- request.setOnapComponent("test5MissingFields");
- request.setRequestId(UUID.randomUUID().toString());
- request.setAction("guard");
- Map<String, Object> guard = new HashMap<>();
- guard.put("actor", "FOO");
- guard.put("recipe", "bar");
- guard.put("vfCount", "4");
- Map<String, Object> resource = new HashMap<>();
- resource.put("guard", guard);
- request.setResource(resource);
- //
- // Ask for a decision - should get permit
- //
- DecisionResponse response = service.makeDecision(request);
- LOGGER.info("Looking for Permit Decision {}", response);
- assertThat(response).isNotNull();
- assertThat(response.getStatus()).isNotNull();
- assertThat(response.getStatus()).isEqualTo("Permit");