5df2552d284a4e692f51b55565cca88fbe96b409
[policy/xacml-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP
4  * ================================================================================
5  * Copyright (C) 2019-2021 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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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  *
19  * SPDX-License-Identifier: Apache-2.0
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.policy.pdp.xacml.application.common;
24
25 import static org.assertj.core.api.Assertions.assertThat;
26
27 import java.io.FileInputStream;
28 import java.util.Properties;
29 import org.junit.Test;
30
31 public class OnapPolicyFinderFactoryTest {
32
33     @Test
34     public void testFinder() throws Exception {
35         //
36         // Load our test properties to use
37         //
38         Properties properties = new Properties();
39         try (FileInputStream is = new FileInputStream("src/test/resources/finder.test.properties")) {
40             properties.load(is);
41         }
42         OnapPolicyFinderFactory finder = new OnapPolicyFinderFactory(properties);
43         assertThat(finder).isNotNull();
44
45         assertThat(finder.getPolicyFinder()).isNotNull();
46         assertThat(finder.getPolicyFinder(properties)).isNotNull();
47     }
48
49     @Test
50     public void testFinderWithCombiningAlgorithm() throws Exception {
51         //
52         // Load our test properties to use
53         //
54         Properties properties = new Properties();
55         try (FileInputStream is = new FileInputStream("src/test/resources/finder.test.properties")) {
56             properties.load(is);
57         }
58         //
59         // Set a combining algorithm
60         //
61         properties.put("xacml.att.policyFinderFactory.combineRootPolicies",
62                 "urn:com:att:xacml:3.0:policy-combining-algorithm:combined-permit-overrides");
63         OnapPolicyFinderFactory finder = new OnapPolicyFinderFactory(properties);
64         assertThat(finder).isNotNull();
65     }
66
67 }