diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2021-02-16 15:33:27 -0600 |
---|---|---|
committer | Pamela Dragosh <pdragosh@research.att.com> | 2021-02-16 16:10:14 -0600 |
commit | 461cbe68a4a4cb85af39fc13e5d69ce84d5150c7 (patch) | |
tree | 7faa454bdee4f9ea88b92b7ffc236e4e95281e93 /main/src/test | |
parent | b860345c386ffbedd1afd6332a5630a9458a5dec (diff) |
Make xacml pdpType configurable
Adding code to enable the pdp type to be configurable.
Issue-ID: POLICY-3071
Change-Id: I51c873f68bff1866c6b2e96958b6c33872aea2c8
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'main/src/test')
10 files changed, 69 insertions, 17 deletions
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java b/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java index 86804425..43ccab04 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java @@ -48,7 +48,7 @@ import org.onap.policy.pdpx.main.startstop.XacmlPdpActivator; @RunWith(MockitoJUnitRunner.class) public class XacmlStateTest { - private static final String PDP_TYPE = "xacml"; + private static final String PDP_TYPE = "xacml-flavor"; private static final String GROUP = "my-group"; private static final String SUBGROUP = "my-subgroup"; private static final PdpState STATE = PdpState.SAFE; @@ -72,7 +72,7 @@ public class XacmlStateTest { XacmlPdpActivator.setCurrent(act); - state = new XacmlState(appmgr, GROUP); + state = new XacmlState(appmgr, GROUP, PDP_TYPE); } @AfterClass diff --git a/main/src/test/java/org/onap/policy/pdpx/main/parameters/CommonTestData.java b/main/src/test/java/org/onap/policy/pdpx/main/parameters/CommonTestData.java index 9b13a84f..6f73df56 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/parameters/CommonTestData.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/parameters/CommonTestData.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -61,6 +61,7 @@ public class CommonTestData { public static final String PDPX_PARAMETER_GROUP_NAME = "XacmlPdpParameters"; public static final String PDPX_GROUP = "XacmlPdpGroup"; + public static final String PDPX_TYPE = "xacml"; public static final List<TopicParameters> TOPIC_PARAMS = Collections.unmodifiableList(Arrays.asList(getTopicParams())); diff --git a/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java b/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java index 0eea10a1..dfd3216e 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -63,7 +63,7 @@ public class TestXacmlPdpParameterGroup { testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class); final XacmlPdpParameterGroup pdpxParameters = new XacmlPdpParameterGroup(CommonTestData.PDPX_PARAMETER_GROUP_NAME, - CommonTestData.PDPX_GROUP, restServerParameters, policyApiParameters, + CommonTestData.PDPX_GROUP, "flavor", restServerParameters, policyApiParameters, topicParameterGroup, applicationPath.getAbsolutePath()); final GroupValidationResult validationResult = pdpxParameters.validate(); assertTrue(validationResult.isValid()); @@ -72,6 +72,7 @@ public class TestXacmlPdpParameterGroup { assertEquals(restServerParameters.getUserName(), pdpxParameters.getRestServerParameters().getUserName()); assertEquals(restServerParameters.getPassword(), pdpxParameters.getRestServerParameters().getPassword()); assertEquals(CommonTestData.PDPX_PARAMETER_GROUP_NAME, pdpxParameters.getName()); + assertEquals("flavor", pdpxParameters.getPdpType()); assertFalse(pdpxParameters.getRestServerParameters().isHttps()); assertFalse(pdpxParameters.getRestServerParameters().isAaf()); } @@ -85,7 +86,8 @@ public class TestXacmlPdpParameterGroup { final TopicParameterGroup topicParameterGroup = testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class); final XacmlPdpParameterGroup pdpxParameters = new XacmlPdpParameterGroup(null, CommonTestData.PDPX_GROUP, - restServerParameters, policyApiParameters, topicParameterGroup, applicationPath.getAbsolutePath()); + null, restServerParameters, policyApiParameters, topicParameterGroup, + applicationPath.getAbsolutePath()); final GroupValidationResult validationResult = pdpxParameters.validate(); assertFalse(validationResult.isValid()); assertEquals(null, pdpxParameters.getName()); @@ -102,7 +104,8 @@ public class TestXacmlPdpParameterGroup { final TopicParameterGroup topicParameterGroup = testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class); final XacmlPdpParameterGroup pdpxParameters = new XacmlPdpParameterGroup("", CommonTestData.PDPX_GROUP, - restServerParameters, policyApiParameters, topicParameterGroup, applicationPath.getAbsolutePath()); + CommonTestData.PDPX_TYPE, restServerParameters, policyApiParameters, topicParameterGroup, + applicationPath.getAbsolutePath()); final GroupValidationResult validationResult = pdpxParameters.validate(); assertFalse(validationResult.isValid()); assertEquals("", pdpxParameters.getName()); @@ -119,7 +122,7 @@ public class TestXacmlPdpParameterGroup { final TopicParameterGroup topicParameterGroup = testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class); final XacmlPdpParameterGroup pdpxParameters = - new XacmlPdpParameterGroup(CommonTestData.PDPX_PARAMETER_GROUP_NAME, null, restServerParameters, + new XacmlPdpParameterGroup(CommonTestData.PDPX_PARAMETER_GROUP_NAME, null, null, restServerParameters, policyApiParameters, topicParameterGroup, applicationPath.getAbsolutePath()); final GroupValidationResult validationResult = pdpxParameters.validate(); assertFalse(validationResult.isValid()); @@ -138,7 +141,7 @@ public class TestXacmlPdpParameterGroup { final TopicParameterGroup topicParameterGroup = testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class); final XacmlPdpParameterGroup pdpxParameters = - new XacmlPdpParameterGroup(CommonTestData.PDPX_PARAMETER_GROUP_NAME, "", restServerParameters, + new XacmlPdpParameterGroup(CommonTestData.PDPX_PARAMETER_GROUP_NAME, "", null, restServerParameters, policyApiParameters, topicParameterGroup, applicationPath.getAbsolutePath()); final GroupValidationResult validationResult = pdpxParameters.validate(); assertFalse(validationResult.isValid()); @@ -158,7 +161,7 @@ public class TestXacmlPdpParameterGroup { testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class); final XacmlPdpParameterGroup pdpxParameters = new XacmlPdpParameterGroup(CommonTestData.PDPX_PARAMETER_GROUP_NAME, CommonTestData.PDPX_GROUP, - restServerParameters, policyApiParameters, + null, restServerParameters, policyApiParameters, topicParameterGroup, applicationPath.getAbsolutePath()); final GroupValidationResult validationResult = pdpxParameters.validate(); assertFalse(validationResult.isValid()); @@ -176,7 +179,7 @@ public class TestXacmlPdpParameterGroup { testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class); final XacmlPdpParameterGroup pdpxParameters = new XacmlPdpParameterGroup(CommonTestData.PDPX_PARAMETER_GROUP_NAME, CommonTestData.PDPX_GROUP, - restServerParameters, policyApiParameters, + null, restServerParameters, policyApiParameters, topicParameterGroup, applicationPath.getAbsolutePath()); final GroupValidationResult validationResult = pdpxParameters.validate(); assertFalse(validationResult.isValid()); @@ -194,7 +197,7 @@ public class TestXacmlPdpParameterGroup { testData.toObject(testData.getTopicParametersMap(true), TopicParameterGroup.class); final XacmlPdpParameterGroup pdpxParameters = new XacmlPdpParameterGroup(CommonTestData.PDPX_PARAMETER_GROUP_NAME, CommonTestData.PDPX_GROUP, - restServerParameters, policyApiParameters, + null, restServerParameters, policyApiParameters, topicParameterGroup, applicationPath.getAbsolutePath()); final GroupValidationResult validationResult = pdpxParameters.validate(); assertFalse(validationResult.isValid()); diff --git a/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterHandler.java b/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterHandler.java index 02c8d0c5..9a997194 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterHandler.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterHandler.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2020 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -102,6 +102,8 @@ public class TestXacmlPdpParameterHandler { + "must be a non-blank string\n" + " field \"pdpGroup\" type \"java.lang.String\" value \"null\" INVALID, " + "must be a non-blank string\n" + + " field \"pdpType\" type \"java.lang.String\" value \"null\" INVALID, " + + "must be a non-blank string\n" + " field \"applicationPath\" type \"java.lang.String\" value \"null\" INVALID, " + "must have application path for applications to store policies and data.\n"); } @@ -116,6 +118,7 @@ public class TestXacmlPdpParameterHandler { final XacmlPdpParameterGroup parGroup = new XacmlPdpParameterHandler().getParameters(minArguments); assertEquals(CommonTestData.PDPX_PARAMETER_GROUP_NAME, parGroup.getName()); assertEquals(CommonTestData.PDPX_GROUP, parGroup.getPdpGroup()); + assertEquals(CommonTestData.PDPX_TYPE, parGroup.getPdpType()); } @Test @@ -154,6 +157,17 @@ public class TestXacmlPdpParameterHandler { } @Test + public void testXacmlPdpParameterGroup_InvalidPdpType() throws PolicyXacmlPdpException { + final String[] xacmlPdpConfigParameters = {"-c", "parameters/XacmlPdpConfigParameters_InvalidPdpType.json"}; + + final XacmlPdpCommandLineArguments arguments = new XacmlPdpCommandLineArguments(); + arguments.parse(xacmlPdpConfigParameters); + + assertThatThrownBy(() -> new XacmlPdpParameterHandler().getParameters(arguments)).hasMessageContaining( + "field \"pdpType\" type \"java.lang.String\" value \"\" INVALID, must be a non-blank string"); + } + + @Test public void testXacmlPdpParameterGroup_InvalidRestServerParameters() throws PolicyXacmlPdpException, IOException { final String[] xacmlPdpConfigParameters = {"-c", "parameters/XacmlPdpConfigParameters_InvalidRestServerParameters.json"}; diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java index c9910349..dbf977f2 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2020 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -120,7 +120,7 @@ public class TestAbbreviateDecisionResults { TopicParameterGroup topicParameterGroup = testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class); XacmlPdpParameterGroup params = - new XacmlPdpParameterGroup("XacmlPdpParameters", "XacmlPdpGroup", rest, policyApiParameters, + new XacmlPdpParameterGroup("XacmlPdpParameters", "XacmlPdpGroup", "xacml", rest, policyApiParameters, topicParameterGroup, apps.getAbsolutePath()); StandardCoder gson = new StandardCoder(); File fileParams = appsFolder.newFile("params.json"); diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestDecision.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestDecision.java index 31d09799..2d71543c 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestDecision.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestDecision.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -109,7 +109,7 @@ public class TestDecision { TopicParameterGroup topicParameterGroup = testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class); XacmlPdpParameterGroup params = - new XacmlPdpParameterGroup("XacmlPdpParameters", "XacmlPdpGroup", rest, policyApiParameters, + new XacmlPdpParameterGroup("XacmlPdpParameters", "XacmlPdpGroup", "xacml", rest, policyApiParameters, topicParameterGroup, apps.getAbsolutePath()); final Gson gson = new GsonBuilder().create(); File fileParams = appsFolder.newFile("params.json"); diff --git a/main/src/test/resources/parameters/MinimumParameters.json b/main/src/test/resources/parameters/MinimumParameters.json index e547e7ee..487a18d1 100644 --- a/main/src/test/resources/parameters/MinimumParameters.json +++ b/main/src/test/resources/parameters/MinimumParameters.json @@ -1,6 +1,7 @@ { "name":"XacmlPdpParameters", "pdpGroup": "XacmlPdpGroup", + "pdpType": "xacml", "restServerParameters": { "host": "0.0.0.0", "port": 6969, diff --git a/main/src/test/resources/parameters/XacmlPdpConfigParameters.json b/main/src/test/resources/parameters/XacmlPdpConfigParameters.json index 5d0a103c..a1376464 100644 --- a/main/src/test/resources/parameters/XacmlPdpConfigParameters.json +++ b/main/src/test/resources/parameters/XacmlPdpConfigParameters.json @@ -1,6 +1,7 @@ { "name": "XacmlPdpParameters", "pdpGroup": "XacmlPdpGroup", + "pdpType": "xacml", "restServerParameters": { "host": "0.0.0.0", "port": 6969, diff --git a/main/src/test/resources/parameters/XacmlPdpConfigParameters_InvalidPdpType.json b/main/src/test/resources/parameters/XacmlPdpConfigParameters_InvalidPdpType.json new file mode 100644 index 00000000..803b789c --- /dev/null +++ b/main/src/test/resources/parameters/XacmlPdpConfigParameters_InvalidPdpType.json @@ -0,0 +1,31 @@ +{ + "name": "XacmlPdpParameters", + "pdpGroup": "defaultGroup", + "pdpType": "", + "restServerParameters":{ + "host":"0.0.0.0", + "port": 6969, + "userName":"healthcheck", + "password":"zb!XztG34", + "https":true + }, + "policyApiParameters": { + "host": "0.0.0.0", + "port": 6970, + "userName": "healthcheck", + "password": "zb!XztG34" + }, + "applicationPath": "src/test/resources/apps", + "topicParameterGroup": { + "topicSources" : [{ + "topic" : "POLICY-PDP-PAP", + "servers" : [ "anyserver" ], + "topicCommInfrastructure" : "noop" + }], + "topicSinks" : [{ + "topic" : "POLICY-PDP-PAP", + "servers" : [ "anyserver" ], + "topicCommInfrastructure" : "noop" + }] + } +}
\ No newline at end of file diff --git a/main/src/test/resources/parameters/XacmlPdpConfigParameters_Std.json b/main/src/test/resources/parameters/XacmlPdpConfigParameters_Std.json index 3f9e6cb1..ec898b6f 100644 --- a/main/src/test/resources/parameters/XacmlPdpConfigParameters_Std.json +++ b/main/src/test/resources/parameters/XacmlPdpConfigParameters_Std.json @@ -1,6 +1,7 @@ { "name":"XacmlPdpParameters", "pdpGroup": "XacmlPdpGroup", + "pdpType": "xacml", "restServerParameters":{ "host":"0.0.0.0", "port":${port}, |