2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 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=========================================================
22 package org.onap.policy.xacml.test.util;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertTrue;
26 import static org.junit.Assert.fail;
27 import java.util.Properties;
28 import org.junit.Test;
29 import org.onap.policy.xacml.std.pip.engines.aaf.AAFEngine;
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;
36 import com.att.research.xacml.api.XACML3;
38 public class AAFEngineTest {
40 public void aafEngineTest() {
41 String testId = "testId";
42 System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "xacml.properties");
43 AAFEngine aafEngine = new AAFEngine();
44 assertTrue(AAFEngine.DEFAULT_DESCRIPTION
45 .equals("PIP for authenticating aaf attributes using the AAF REST interface"));
46 assertTrue(AAFEngine.DEFAULT_ISSUER.equals("aaf"));
48 Properties props = new Properties();
50 aafEngine.configure(testId, props);
51 assertEquals(aafEngine.getName(), testId);
52 assertEquals(aafEngine.getDescription(), AAFEngine.DEFAULT_DESCRIPTION);
53 assertEquals(aafEngine.getIssuer(), AAFEngine.DEFAULT_ISSUER);
54 assertEquals(aafEngine.attributesProvided().size(), 2);
55 assertEquals(aafEngine.attributesRequired().size(), 5);
57 PIPRequest pipRequest = new StdPIPRequest(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE,
58 AAFEngine.AAF_RESPONSE_ID, XACML3.ID_DATATYPE_STRING);
59 StdPIPFinderFactory pipFactory = new StdPIPFinderFactory();
60 PIPFinder pipFinder = pipFactory.getFinder();
61 assertEquals(pipFinder.getPIPEngines().size(), 0);
62 PIPResponse pipResponse = aafEngine.getAttributes(pipRequest, pipFinder);
63 assertEquals(pipResponse.getStatus().isOk(), true);
64 } catch (Exception ex) {
65 fail("Not expecting any exceptions");