X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=docs%2Fxacml%2Ftutorial%2Fapp%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Ftutorial%2Ftutorial%2FTutorialApplicationTest.java;h=d20c1b38b2ae466c0768c4a2deb07634ef600cb4;hb=a242769ab10a570c7452023dcaa59d8ecefccc49;hp=7a1c2f94f417a0647234b09f2d2e9960b0c75cd2;hpb=0ac4c6a0a3c5eacf7db3b1766048a8d1405f3e96;p=policy%2Fparent.git diff --git a/docs/xacml/tutorial/app/src/test/java/org/onap/policy/tutorial/tutorial/TutorialApplicationTest.java b/docs/xacml/tutorial/app/src/test/java/org/onap/policy/tutorial/tutorial/TutorialApplicationTest.java index 7a1c2f94..d20c1b38 100644 --- a/docs/xacml/tutorial/app/src/test/java/org/onap/policy/tutorial/tutorial/TutorialApplicationTest.java +++ b/docs/xacml/tutorial/app/src/test/java/org/onap/policy/tutorial/tutorial/TutorialApplicationTest.java @@ -1,9 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.onap.policy.tutorial.tutorial; +import static org.junit.Assert.assertEquals; + import java.io.File; import java.io.IOException; import java.util.Iterator; -import java.util.List; import java.util.Properties; import java.util.ServiceLoader; @@ -12,16 +31,16 @@ import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; import org.junit.rules.TemporaryFolder; +import org.onap.policy.common.endpoints.parameters.RestServerParameters; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.resources.TextFileUtils; import org.onap.policy.models.decisions.concepts.DecisionRequest; import org.onap.policy.models.decisions.concepts.DecisionResponse; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; -import org.onap.policy.pdp.xacml.application.common.TestUtils; import org.onap.policy.pdp.xacml.application.common.XacmlApplicationException; import org.onap.policy.pdp.xacml.application.common.XacmlApplicationServiceProvider; import org.onap.policy.pdp.xacml.application.common.XacmlPolicyUtils; +import org.onap.policy.pdp.xacml.xacmltest.TestUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -67,9 +86,9 @@ public class TutorialApplicationTest { // Tell the application to initialize based on the properties file // we just built for it. // - service.initialize(propertiesFile.toPath().getParent()); - } - + service.initialize(propertiesFile.toPath().getParent(), new RestServerParameters()); + } + @Test public void test() throws CoderException, XacmlApplicationException, IOException { // @@ -83,11 +102,19 @@ public class TutorialApplicationTest { TextFileUtils .getTextFileAsString("src/test/resources/tutorial-decision-request.json"), DecisionRequest.class); - // - // Test a decision // - Pair decision = service.makeDecision(decisionRequest); + // Test a decision - should start with a permit + // + Pair decision = service.makeDecision(decisionRequest, null); + LOGGER.info(decision.getLeft().toString()); + assertEquals("Permit", decision.getLeft().getStatus()); + // + // This should be a deny + // + decisionRequest.getResource().put("user", "audit"); + decision = service.makeDecision(decisionRequest, null); LOGGER.info(decision.getLeft().toString()); + assertEquals("Deny", decision.getLeft().getStatus()); } }