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.api.XACML3;
35 public class AAFEngineTest {
37 public void aafEngineTest(){
38 String testId = "testId";
39 AAFEngine aafEngine = new AAFEngine();
40 assertTrue(AAFEngine.DEFAULT_DESCRIPTION.equals("PIP for authenticating aaf attributes using the AAF REST interface"));
41 assertTrue(AAFEngine.DEFAULT_ISSUER.equals("aaf"));
43 Properties props = new Properties();
45 aafEngine.configure(testId, props);
46 assertEquals(aafEngine.getName(), testId);
47 assertEquals(aafEngine.getDescription(), AAFEngine.DEFAULT_DESCRIPTION);
48 assertEquals(aafEngine.getIssuer(), AAFEngine.DEFAULT_ISSUER);
49 assertEquals(aafEngine.attributesProvided().size(), 2);
50 assertEquals(aafEngine.attributesRequired().size(), 5);
52 PIPRequest pipRequest = new StdPIPRequest(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, AAFEngine.AAF_RESPONSE_ID, XACML3.ID_DATATYPE_STRING);
53 StdPIPFinderFactory pipFactory = new StdPIPFinderFactory();
54 PIPFinder pipFinder = pipFactory.getFinder();
55 assertEquals(pipFinder.getPIPEngines().size(), 0);
56 PIPResponse pipResponse = aafEngine.getAttributes(pipRequest, pipFinder);
57 assertEquals(pipResponse.getStatus().isOk(), true);
59 catch (Exception ex) {
60 fail("Not expecting any exceptions");