2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (C) 2019 Samsung
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.policy.xacml.test.util;
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertTrue;
27 import static org.junit.Assert.fail;
29 import com.att.research.xacml.api.XACML3;
30 import com.att.research.xacml.api.pip.PIPFinder;
31 import com.att.research.xacml.api.pip.PIPRequest;
32 import com.att.research.xacml.api.pip.PIPResponse;
33 import com.att.research.xacml.std.pip.StdPIPFinderFactory;
34 import com.att.research.xacml.std.pip.StdPIPRequest;
35 import com.att.research.xacml.util.XACMLProperties;
37 import java.util.Properties;
39 import org.junit.Test;
40 import org.onap.policy.xacml.std.pip.engines.aaf.AAFEngine;
42 public class AAFEngineTest {
44 public void aafEngineTest() {
45 String testId = "testId";
46 System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "xacml.properties");
47 AAFEngine aafEngine = new AAFEngine();
48 assertTrue(AAFEngine.DEFAULT_DESCRIPTION
49 .equals("PIP for authenticating aaf attributes using the AAF REST interface"));
50 assertTrue(AAFEngine.DEFAULT_ISSUER.equals("aaf"));
52 Properties props = new Properties();
54 aafEngine.configure(testId, props);
55 assertEquals(aafEngine.getName(), testId);
56 assertEquals(aafEngine.getDescription(), AAFEngine.DEFAULT_DESCRIPTION);
57 assertEquals(aafEngine.getIssuer(), AAFEngine.DEFAULT_ISSUER);
58 assertEquals(aafEngine.attributesProvided().size(), 2);
59 assertEquals(aafEngine.attributesRequired().size(), 5);
61 PIPRequest pipRequest = new StdPIPRequest(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, AAFEngine.AAF_RESPONSE_ID,
62 XACML3.ID_DATATYPE_STRING);
63 StdPIPFinderFactory pipFactory = new StdPIPFinderFactory();
64 PIPFinder pipFinder = pipFactory.getFinder();
65 assertEquals(pipFinder.getPIPEngines().size(), 0);
66 PIPResponse pipResponse = aafEngine.getAttributes(pipRequest, pipFinder);
67 assertEquals(pipResponse.getStatus().isOk(), true);
68 } catch (Exception ex) {
69 fail("Not expecting any exceptions");