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