6e98b225b0fd42e2de7438c386b735a2661e8b31
[policy/distribution.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2018 Ericsson. All rights reserved.
4  *  Modifications Copyright (C) 2019 Nordix Foundation.
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.distribution.forwarding.xacml.pdp.engine;
23
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertFalse;
26 import static org.junit.Assert.assertTrue;
27
28 import org.junit.Test;
29 import org.onap.policy.common.parameters.ValidationStatus;
30 import org.onap.policy.distribution.forwarding.xacml.pdp.XacmlPdpPolicyForwarderParameterGroup;
31 import org.onap.policy.distribution.forwarding.xacml.pdp.testclasses.CommonTestData;
32
33 public class XacmlPdpPolicyForwarderParameterGroupTest {
34
35     private static final String CLIENT_AUTH = "myClientAuth";
36     private static final String PASSWORD = "myPassword";
37     private static final String USER = "myUser";
38     private static final int PORT = 1234;
39     private static final String HOST_NAME = "10.10.10.10";
40
41     @Test
42     public void testValidParameters() {
43         final XacmlPdpPolicyForwarderParameterGroup configurationParameters = CommonTestData
44                 .getPolicyForwarderParameters("src/test/resources/parameters/XacmlPdpPolicyForwarderParameters.json",
45                         XacmlPdpPolicyForwarderParameterGroup.class);
46
47         assertTrue(configurationParameters.isUseHttps());
48         assertEquals(HOST_NAME, configurationParameters.getHostname());
49         assertEquals(PORT, configurationParameters.getPort());
50         assertEquals(USER, configurationParameters.getUserName());
51         assertEquals(PASSWORD, configurationParameters.getPassword());
52         assertEquals(CLIENT_AUTH, configurationParameters.getClientAuth());
53         assertFalse(configurationParameters.isManaged());
54     }
55
56     @Test
57     public void testInvalidParameters() {
58         final XacmlPdpPolicyForwarderParameterGroup configurationParameters =
59                 CommonTestData.getPolicyForwarderParameters(
60                         "src/test/resources/parameters/XacmlPdpPolicyForwarderParametersInvalid.json",
61                         XacmlPdpPolicyForwarderParameterGroup.class);
62
63         assertEquals(ValidationStatus.INVALID, configurationParameters.validate().getStatus());
64     }
65
66     @Test
67     public void testEmptyParameters() {
68         final XacmlPdpPolicyForwarderParameterGroup configurationParameters =
69                 CommonTestData.getPolicyForwarderParameters("src/test/resources/parameters/EmptyParameters.json",
70                         XacmlPdpPolicyForwarderParameterGroup.class);
71
72         assertEquals(ValidationStatus.INVALID, configurationParameters.validate().getStatus());
73     }
74 }