diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2019-03-09 11:48:44 -0500 |
---|---|---|
committer | Pamela Dragosh <pdragosh@research.att.com> | 2019-03-15 08:54:05 -0400 |
commit | b909b14fe88c5fe8f096cf8b471a2aa799d84739 (patch) | |
tree | 19de65fff7618bfad91acb0b803210a93dbb86cd /applications/monitoring/src/test/resources | |
parent | 4b2ef1a5a9bf92aeb7edc1512f7a6cd8e1be99d8 (diff) |
Monitoring policy creation foundation
Upgrde to xacml v2.0.0 release artifact.
Some re-arrangement of classes. New class to support a
common dictionary among the monitoring applications. I
may move it to a common under the main since some of the
values are shareable.
Created application service provider, so the XACML
main knows what policy types are pre-loaded and can
report them back to the PAP.
struggled with cucumber, which does not create
TemporaryFolder although the documentation says its
supported.
Added a new Policy Finder specific to ONAP which does
quicker job to load policies.
Issue-ID: POLICY-1273
Change-Id: I4af15a64da3b42d48f29809710421b1649625adc
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'applications/monitoring/src/test/resources')
13 files changed, 192 insertions, 7 deletions
diff --git a/applications/monitoring/src/test/resources/cucumber/decisions.feature b/applications/monitoring/src/test/resources/cucumber/decisions.feature index a23d965b..6a573d3c 100644 --- a/applications/monitoring/src/test/resources/cucumber/decisions.feature +++ b/applications/monitoring/src/test/resources/cucumber/decisions.feature @@ -18,10 +18,10 @@ # # SPDX-License-Identifier: Apache-2.0 # ============LICENSE_END========================================================= -Feature: Return a decision - Return a decision for a request - - Scenario: Return policy as a JSON - Given TCA Policy is loaded - When A Decision Request is received - Then I should return TCA Policy as JSON
\ No newline at end of file +#Feature: Return a decision +# Return a decision for a request +# +# Scenario: Return policy as a JSON +# Given TCA Policy is loaded +# When A Decision Request is received +# Then I should return TCA Policy as JSON
\ No newline at end of file diff --git a/applications/monitoring/src/test/resources/cucumber/load_policy.feature b/applications/monitoring/src/test/resources/cucumber/load_policy.feature new file mode 100644 index 00000000..9651ca91 --- /dev/null +++ b/applications/monitoring/src/test/resources/cucumber/load_policy.feature @@ -0,0 +1,35 @@ +# +# ============LICENSE_START======================================================= +# ONAP +# ================================================================================ +# Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +Feature: Loading TOSCA Policies + When a TOSCA Policy is received, convert it + to a XACML policy and then load it into the XACML PDP engine. + + Scenario: No Policies Loaded + Given Initialization + When Decision Requested + Then Decision Permit 0 Obligations + + Scenario: Load New Policy + Given Initialization + When The application gets new Tosca Policy + Then Load Policy + And Save Configuration diff --git a/applications/monitoring/src/test/resources/test.monitoring.policy.badmetadata.1.yaml b/applications/monitoring/src/test/resources/test.monitoring.policy.badmetadata.1.yaml new file mode 100644 index 00000000..a2631848 --- /dev/null +++ b/applications/monitoring/src/test/resources/test.monitoring.policy.badmetadata.1.yaml @@ -0,0 +1,10 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policies: + - + test.monitoring.policy.badmetadata.1: + type: onap.policies.monitoring.cdap.tca.hi.lo.app + version: 1.0.0 + metadata: + policy-id: test.monitoring.policy.badmetadata.1 + properties: + domain: measurementsForVfScaling diff --git a/applications/monitoring/src/test/resources/test.monitoring.policy.badmetadata.2.yaml b/applications/monitoring/src/test/resources/test.monitoring.policy.badmetadata.2.yaml new file mode 100644 index 00000000..7da2db38 --- /dev/null +++ b/applications/monitoring/src/test/resources/test.monitoring.policy.badmetadata.2.yaml @@ -0,0 +1,10 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policies: + - + onap.scaleout.tca: + type: onap.policies.monitoring.cdap.tca.hi.lo.app + version: 1.0.0 + metadata: + policy-version: 1 + properties: + domain: measurementsForVfScaling diff --git a/applications/monitoring/src/test/resources/test.monitoring.policy.missingmetadata.yaml b/applications/monitoring/src/test/resources/test.monitoring.policy.missingmetadata.yaml new file mode 100644 index 00000000..4984a1c3 --- /dev/null +++ b/applications/monitoring/src/test/resources/test.monitoring.policy.missingmetadata.yaml @@ -0,0 +1,9 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policies: + - + onap.scaleout.tca: + type: onap.policies.monitoring.test + description: I am a test policy + version: 1.0.0 + properties: + domain: measurementsForVfScaling diff --git a/applications/monitoring/src/test/resources/test.monitoring.policy.missingproperties.yaml b/applications/monitoring/src/test/resources/test.monitoring.policy.missingproperties.yaml new file mode 100644 index 00000000..d4132a28 --- /dev/null +++ b/applications/monitoring/src/test/resources/test.monitoring.policy.missingproperties.yaml @@ -0,0 +1,9 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policies: + - + onap.scaleout.tca: + type: onap.policies.monitoring.cdap.tca.hi.lo.app + version: 1.0.0 + metadata: + policy-id: onap.scaleout.tca + policy-version: 1 diff --git a/applications/monitoring/src/test/resources/test.monitoring.policy.missingtype.yaml b/applications/monitoring/src/test/resources/test.monitoring.policy.missingtype.yaml new file mode 100644 index 00000000..309d08c5 --- /dev/null +++ b/applications/monitoring/src/test/resources/test.monitoring.policy.missingtype.yaml @@ -0,0 +1,11 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policies: + - + onap.scaleout.tca: + description: I am a test policy + version: 1.0.0 + metadata: + policy-id: onap.scaleout.tca + policy-version: 10 + properties: + domain: measurementsForVfScaling diff --git a/applications/monitoring/src/test/resources/test.monitoring.policy.missingversion.yaml b/applications/monitoring/src/test/resources/test.monitoring.policy.missingversion.yaml new file mode 100644 index 00000000..ff378d92 --- /dev/null +++ b/applications/monitoring/src/test/resources/test.monitoring.policy.missingversion.yaml @@ -0,0 +1,11 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policies: + - + onap.scaleout.tca: + type: onap.policies.monitoring.test + description: I am a test policy + metadata: + policy-id: onap.scaleout.tca + policy-version: 10 + properties: + domain: measurementsForVfScaling diff --git a/applications/monitoring/src/test/resources/unsupportedpolicytype.yaml b/applications/monitoring/src/test/resources/unsupportedpolicytype.yaml new file mode 100644 index 00000000..0a895b38 --- /dev/null +++ b/applications/monitoring/src/test/resources/unsupportedpolicytype.yaml @@ -0,0 +1,11 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policies: + - + policy.name: + type: foo.bar + version: 1.0.0 + metadata: + policy-id: policy.name + policy-version: 1 + properties: + prop1: value1 diff --git a/applications/monitoring/src/test/resources/vDNS.policy.decision.payload.json b/applications/monitoring/src/test/resources/vDNS.policy.decision.payload.json new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/applications/monitoring/src/test/resources/vDNS.policy.decision.payload.json diff --git a/applications/monitoring/src/test/resources/vDNS.policy.input.yaml b/applications/monitoring/src/test/resources/vDNS.policy.input.yaml index ee149381..ee12c702 100644 --- a/applications/monitoring/src/test/resources/vDNS.policy.input.yaml +++ b/applications/monitoring/src/test/resources/vDNS.policy.input.yaml @@ -6,6 +6,7 @@ policies: version: 1.0.0 metadata: policy-id: onap.scaleout.tca + policy-version: 1 properties: domain: measurementsForVfScaling metricsPerEventName: diff --git a/applications/monitoring/src/test/resources/vDNS.policy.xml b/applications/monitoring/src/test/resources/vDNS.policy.xml new file mode 100644 index 00000000..14ad4603 --- /dev/null +++ b/applications/monitoring/src/test/resources/vDNS.policy.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="onap.scaleout.tca" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:deny-unless-permit"> + <Description>The root policy for supporting in-memory onap.Monitoring policy-type policies.</Description> + <Target> + <AnyOf> + <AllOf> + <!-- Exact policy-id value --> + <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal"> + <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">onap.scaleout.tca</AttributeValue> + <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/> + </Match> + </AllOf> + <AllOf> + <!-- Regular expression match on policy id --> + <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp"> + <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">onap.scaleout.tca</AttributeValue> + <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/> + </Match> + </AllOf> + <AllOf> + <!-- Exact policy-type value --> + <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal"> + <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">onap.policies.monitoring.cdap.tca.hi.lo.app</AttributeValue> + <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/> + </Match> + </AllOf> + <AllOf> + <!-- Regular expression match on policy-type --> + <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp"> + <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">onap.policies.monitoring.cdap.tca.hi.lo.app</AttributeValue> + <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/> + </Match> + </AllOf> + </AnyOf> + </Target> + <Rule RuleId="urn:org:onap:xacml:rule:id:74caee98-bd05-4bb5-917c-a26ef80bb0f4" Effect="Permit"> + <Description>Default is Permit</Description> + <!-- + + Add JSON as Obligation + + --> + </Rule> +</Policy> diff --git a/applications/monitoring/src/test/resources/xacml.properties b/applications/monitoring/src/test/resources/xacml.properties new file mode 100644 index 00000000..9b5330dc --- /dev/null +++ b/applications/monitoring/src/test/resources/xacml.properties @@ -0,0 +1,34 @@ +# +# Properties that the embedded PDP engine uses to configure and load +# +# Standard API Factories +# +xacml.dataTypeFactory=com.att.research.xacml.std.StdDataTypeFactory +xacml.pdpEngineFactory=com.att.research.xacmlatt.pdp.ATTPDPEngineFactory +xacml.pepEngineFactory=com.att.research.xacml.std.pep.StdEngineFactory +xacml.pipFinderFactory=com.att.research.xacml.std.pip.StdPIPFinderFactory +xacml.traceEngineFactory=com.att.research.xacml.std.trace.LoggingTraceEngineFactory +# +# AT&T PDP Implementation Factories +# +xacml.att.evaluationContextFactory=com.att.research.xacmlatt.pdp.std.StdEvaluationContextFactory +xacml.att.combiningAlgorithmFactory=com.att.research.xacmlatt.pdp.std.StdCombiningAlgorithmFactory +xacml.att.functionDefinitionFactory=com.att.research.xacmlatt.pdp.std.StdFunctionDefinitionFactory +# +# ONAP PDP Implementation Factories +# +xacml.att.policyFinderFactory=org.onap.policy.pdp.xacml.application.common.OnapPolicyFinderFactory + +# +# NOTE: If you are testing against a RESTful PDP, then the PDP must be configured with the +# policies and PIP configuration as defined below. Otherwise, this is the configuration that +# the embedded PDP uses. +# + +policytypes=onap.Monitoring, onap.policies.monitoring.cdap.tca.hi.lo.app + +# Policies to load +# +xacml.rootPolicies=monitoring +monitoring.file=src/main/resources/RootMonitoringPolicy.xml + |