diff options
Diffstat (limited to 'appc-config/appc-config-audit')
32 files changed, 1759 insertions, 0 deletions
diff --git a/appc-config/appc-config-audit/.gitignore b/appc-config/appc-config-audit/.gitignore new file mode 100644 index 000000000..b83d22266 --- /dev/null +++ b/appc-config/appc-config-audit/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/appc-config/appc-config-audit/features/.gitignore b/appc-config/appc-config-audit/features/.gitignore new file mode 100644 index 000000000..b83d22266 --- /dev/null +++ b/appc-config/appc-config-audit/features/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/appc-config/appc-config-audit/features/pom.xml b/appc-config/appc-config-audit/features/pom.xml new file mode 100644 index 000000000..4197f94ff --- /dev/null +++ b/appc-config/appc-config-audit/features/pom.xml @@ -0,0 +1,125 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.openecomp.appc</groupId> + <artifactId>appc-config-audit</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + <artifactId>appc-config-audit-features</artifactId> + <name>Config Audit Plugin - Features</name> + + <packaging>jar</packaging> + + <dependencies> + + <dependency> + <groupId>org.openecomp.appc</groupId> + <artifactId>appc-config-audit-provider</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.6</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.opendaylight.mdsal</groupId> + <artifactId>features-mdsal</artifactId> + <version>${odl.mdsal.version}</version> + <classifier>features</classifier> + <type>xml</type> + + <scope>runtime</scope> + </dependency> + + + <!-- dependency for opendaylight-karaf-empty for use by testing --> + <dependency> + <groupId>org.opendaylight.controller</groupId> + <artifactId>opendaylight-karaf-empty</artifactId> + <version>${odl.karaf.empty.distro.version}</version> + <type>zip</type> + </dependency> + + + <dependency> + <!-- Required for launching the feature tests --> + <groupId>org.opendaylight.odlparent</groupId> + <artifactId>features-test</artifactId> + <version>${odl.commons.opendaylight.version}</version> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + <resources> + <resource> + <filtering>true</filtering> + <directory>src/main/resources</directory> + </resource> + </resources> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> + <executions> + <execution> + <id>filter</id> + <goals> + <goal>resources</goal> + </goals> + <phase>generate-resources</phase> + </execution> + </executions> + </plugin> + <!-- launches the feature test, which validates that your karaf feature + can be installed inside of a karaf container. It doesn't validate that your + functionality works correctly, just that you have all of the dependent bundles + defined correctly. + <plugin> + + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.16</version> + <configuration> + <systemPropertyVariables> + <karaf.distro.groupId>org.opendaylight.controller</karaf.distro.groupId> + <karaf.distro.artifactId>opendaylight-karaf-empty</karaf.distro.artifactId> + <karaf.distro.version>${odl.karaf.empty.distro.version}</karaf.distro.version> + </systemPropertyVariables> + <dependenciesToScan> + <dependency>org.opendaylight.yangtools:features-test</dependency> + </dependenciesToScan> + </configuration> + </plugin> + --> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>attach-artifacts</id> + <goals> + <goal>attach-artifact</goal> + </goals> + <phase>package</phase> + <configuration> + <artifacts> + <artifact> + <file>${project.build.directory}/classes/${features.file}</file> + <type>xml</type> + <classifier>features</classifier> + </artifact> + </artifacts> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/appc-config/appc-config-audit/features/src/main/resources/features.xml b/appc-config/appc-config-audit/features/src/main/resources/features.xml new file mode 100644 index 000000000..5c07c6d0c --- /dev/null +++ b/appc-config/appc-config-audit/features/src/main/resources/features.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ============LICENSE_START======================================================= + ONAP : APP-C + ================================================================================ + Copyright (C) 2017 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. + ============LICENSE_END========================================================= + --> + + +<features name="appc-config-audit-${project.version}" + xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0"> + + <repository>mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.version}/xml/features</repository> + + <feature name='appc-config-audit' description="Application Controller Config Audit" + version='${project.version}'> + <!-- Most applications will have a dependency on the ODL MD-SAL Broker --> + <feature version="${broker-mdsal.version}">odl-mdsal-broker</feature> + <feature version='${sdnc.sli.version}'>sdnc-sli</feature> + <bundle>mvn:commons-lang/commons-lang/2.6</bundle> + <bundle>wrap:mvn:com.fasterxml.jackson.core/jackson-databind/${jackson.version}</bundle> + <bundle>wrap:mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson.version}</bundle> + <bundle>wrap:mvn:com.fasterxml.jackson.core/jackson-core/${jackson.version}</bundle> + + <bundle>wrap:mvn:com.att.eelf/eelf-core/${eelf.version}</bundle> + <bundle>mvn:ch.qos.logback/logback-core/${logback.version}</bundle> + <bundle>mvn:ch.qos.logback/logback-classic/${logback.version}</bundle> + <bundle>wrap:mvn:xmlunit/xmlunit/${xmlunit.version}</bundle> + <bundle>mvn:org.openecomp.appc/config-audit-provider/${project.version}</bundle> + </feature> +</features> diff --git a/appc-config/appc-config-audit/installer/pom.xml b/appc-config/appc-config-audit/installer/pom.xml new file mode 100644 index 000000000..c12576a2e --- /dev/null +++ b/appc-config/appc-config-audit/installer/pom.xml @@ -0,0 +1,148 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ============LICENSE_START======================================================= + APPC + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017 Amdocs + ================================================================================ + 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. + ============LICENSE_END========================================================= + ECOMP is a trademark and service mark of AT&T Intellectual Property. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.openecomp.appc</groupId> + <artifactId>appc-config-audit</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + + <artifactId>appc-config-audit-installer</artifactId> + <name>Config Component Audit - Installer</name> + <packaging>pom</packaging> + <properties> + <application.name>appc-config-audit</application.name> + <features.boot>appc-config-audit</features.boot> + <features.repositories>mvn:org.openecomp.appc/appc-config-audit-features/${project.version}/xml/features</features.repositories> + <include.transitive.dependencies>false</include.transitive.dependencies> + </properties> + <dependencies> + <dependency> + <groupId>org.openecomp.appc</groupId> + <artifactId>appc-config-audit-features</artifactId> + <classifier>features</classifier> + <type>xml</type> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.openecomp.appc</groupId> + <artifactId>appc-config-audit-provider</artifactId> + <version>1.1.0-SNAPSHOT</version> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <executions> + <execution> + <id>maven-repo-zip</id> + <goals> + <goal>single</goal> + </goals> + <phase>package</phase> + <configuration> + <appendAssemblyId>false</appendAssemblyId> + <attach>false</attach> + <finalName>stage/${application.name}-${project.version}</finalName> + <descriptors> + <descriptor>src/assembly/assemble_mvnrepo_zip.xml</descriptor> + </descriptors> + </configuration> + </execution> + <execution> + <id>installer-zip</id> + <goals> + <goal>single</goal> + </goals> + <phase>package</phase> + <configuration> + <appendAssemblyId>false</appendAssemblyId> + <attach>true</attach> + <finalName>${application.name}-${project.version}</finalName> + <descriptors> + <descriptor>src/assembly/assemble_installer_zip.xml</descriptor> + </descriptors> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>copy-dependencies</id> + <goals> + <goal>copy-dependencies</goal> + </goals> + <phase>prepare-package</phase> + <configuration> + <transitive>false</transitive> + <outputDirectory>${project.build.directory}/assembly/system</outputDirectory> + <overWriteReleases>false</overWriteReleases> + <overWriteSnapshots>true</overWriteSnapshots> + <overWriteIfNewer>true</overWriteIfNewer> + <useRepositoryLayout>true</useRepositoryLayout> + <addParentPoms>false</addParentPoms> + <copyPom>false</copyPom> + <excludeGroupIds>org.opendaylight</excludeGroupIds> + <scope>provided</scope> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <executions> + <execution> + <id>copy-version</id> + <goals> + <goal>copy-resources</goal> + </goals> + <!-- here the phase you need --> + <phase>validate</phase> + <configuration> + <outputDirectory>${basedir}/target/stage</outputDirectory> + <resources> + <resource> + <directory>src/main/resources/scripts</directory> + <includes> + <include>install-feature.sh</include> + </includes> + <filtering>true</filtering> + </resource> + </resources> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/appc-config/appc-config-audit/installer/src/assembly/assemble_installer_zip.xml b/appc-config/appc-config-audit/installer/src/assembly/assemble_installer_zip.xml new file mode 100644 index 000000000..f6495af19 --- /dev/null +++ b/appc-config/appc-config-audit/installer/src/assembly/assemble_installer_zip.xml @@ -0,0 +1,59 @@ +<!-- + ============LICENSE_START======================================================= + ONAP : APP-C + ================================================================================ + Copyright (C) 2017 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. + ============LICENSE_END========================================================= + ECOMP is a trademark and service mark of AT&T Intellectual Property. + --> + +<!-- Defines how we build the .zip file which is our distribution. --> + +<assembly + xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> + <id>audit</id> + <formats> + <format>zip</format> + </formats> + + <!-- we want "system" and related files right at the root level + as this file is suppose to be unzip on top of a karaf + distro. --> + <includeBaseDirectory>false</includeBaseDirectory> + + <fileSets> + <fileSet> + <directory>target/stage/</directory> + <outputDirectory>${application.name}</outputDirectory> + <fileMode>755</fileMode> + <includes> + <include>*.sh</include> + </includes> + </fileSet> + <fileSet> + <directory>target/stage/</directory> + <outputDirectory>${application.name}</outputDirectory> + <fileMode>644</fileMode> + <excludes> + <exclude>*.sh</exclude> + </excludes> + </fileSet> + </fileSets> + + + +</assembly> diff --git a/appc-config/appc-config-audit/installer/src/assembly/assemble_mvnrepo_zip.xml b/appc-config/appc-config-audit/installer/src/assembly/assemble_mvnrepo_zip.xml new file mode 100644 index 000000000..9f24d65b1 --- /dev/null +++ b/appc-config/appc-config-audit/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -0,0 +1,47 @@ +<!-- + ============LICENSE_START======================================================= + ONAP : APP-C + ================================================================================ + Copyright (C) 2017 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. + ============LICENSE_END========================================================= + ECOMP is a trademark and service mark of AT&T Intellectual Property. + --> + +<!-- Defines how we build the .zip file which is our distribution. --> + +<assembly + xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> + <id>audit</id> + <formats> + <format>zip</format> + </formats> + + <!-- we want "system" and related files right at the root level + as this file is suppose to be unzip on top of a karaf + distro. --> + <includeBaseDirectory>false</includeBaseDirectory> + + <fileSets> + <fileSet> + <directory>target/assembly/</directory> + <outputDirectory>.</outputDirectory> + <excludes> + </excludes> + </fileSet> + </fileSets> + +</assembly> diff --git a/appc-config/appc-config-audit/installer/src/main/resources/scripts/install-feature.sh b/appc-config/appc-config-audit/installer/src/main/resources/scripts/install-feature.sh new file mode 100644 index 000000000..d3d2ea6e7 --- /dev/null +++ b/appc-config/appc-config-audit/installer/src/main/resources/scripts/install-feature.sh @@ -0,0 +1,40 @@ +### +# ============LICENSE_START======================================================= +# ONAP : APP-C +# ================================================================================ +# Copyright (C) 2017 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. +# ============LICENSE_END========================================================= +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +### + +#!/bin/bash + +ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} +ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} +ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} +INSTALLERDIR=$(dirname $0) + +REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip + +if [ -f ${REPOZIP} ] +then + unzip -n -d ${ODL_HOME} ${REPOZIP} +else + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 +fi + +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} diff --git a/appc-config/appc-config-audit/pom.xml b/appc-config/appc-config-audit/pom.xml new file mode 100644 index 000000000..a0e7b4312 --- /dev/null +++ b/appc-config/appc-config-audit/pom.xml @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <parent> + <groupId>org.openecomp.appc</groupId> + <artifactId>appc-config</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <packaging>pom</packaging> + <artifactId>appc-config-audit</artifactId> + + <name>Config Audit Node</name> + <description>Common Utilities for DG</description> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <xmlunit.version>1.6</xmlunit.version> + </properties> + + <dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.openecomp.appc</groupId> + <artifactId>appc-config-audit-features</artifactId> + <classifier>features</classifier> + <type>xml</type> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.openecomp.appc</groupId> + <artifactId>appc-config-audit-provider</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + + </dependencyManagement> + + <profiles> + <profile> + <id>default</id> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + <modules> + <module>features</module> + <module>provider</module> + <module>installer</module> + </modules> + </profile> + <profile> + <id>all</id> + <modules> + <module>features</module> + <module>provider</module> + <module>installer</module> + </modules> + </profile> + </profiles> +</project> diff --git a/appc-config/appc-config-audit/provider/.gitignore b/appc-config/appc-config-audit/provider/.gitignore new file mode 100644 index 000000000..b83d22266 --- /dev/null +++ b/appc-config/appc-config-audit/provider/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/appc-config/appc-config-audit/provider/pom.xml b/appc-config/appc-config-audit/provider/pom.xml new file mode 100644 index 000000000..8ea4e11e9 --- /dev/null +++ b/appc-config/appc-config-audit/provider/pom.xml @@ -0,0 +1,118 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.openecomp.appc</groupId> + <artifactId>appc-config-audit</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + <artifactId>appc-config-audit-provider</artifactId> + <packaging>bundle</packaging> + <name>Config Audit - Provider</name> + <url>http://maven.apache.org</url> + + <dependencies> + <dependency> + <groupId>equinoxSDK381</groupId> + <artifactId>org.eclipse.osgi</artifactId> + <version>${equinox.osgi.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdnc.core</groupId> + <artifactId>sli-provider</artifactId> + </dependency> + <dependency> + <groupId>xmlunit</groupId> + <artifactId>xmlunit</artifactId> + <version>${xmlunit.version}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-annotations</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + </dependency> + + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </dependency> + <dependency> + <groupId>com.att.eelf</groupId> + <artifactId>eelf-core</artifactId> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <version>${bundle.plugin.version}</version> + <extensions>true</extensions> + <configuration> + <instructions> + <Bundle-SymbolicName>org.openecomp.sdnc.config.audit</Bundle-SymbolicName> + <Bundle-Activator>org.openecomp.sdnc.config.audit.SliAuditActivator</Bundle-Activator> + <Export-Package>org.openecomp.sdnc.config.audit,org.openecomp.sdnc.config.audit.node</Export-Package> + <Import-Package>*</Import-Package> + <DynamicImport-Package>*</DynamicImport-Package> + </instructions> + <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation> + </configuration> + </plugin> + + </plugins> + <pluginManagement> + <plugins> + <!--This plugin's configuration is used to store Eclipse m2e settings + only. It has no influence on the Maven build itself. --> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId> + com.brocade.developer + </groupId> + <artifactId> + providermodule-plugin + </artifactId> + <versionRange> + [1.2.0.100-SNAPSHOT,) + </versionRange> + <goals> + <goal>process</goal> + </goals> + </pluginExecutionFilter> + <action> + <ignore /> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> +</project> diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/SliAuditActivator.java b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/SliAuditActivator.java new file mode 100644 index 000000000..f4cfe1b37 --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/SliAuditActivator.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit; + +import java.util.LinkedList; +import java.util.List; + +import org.openecomp.sdnc.config.audit.node.CompareNode; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.openecomp.sdnc.sli.ConfigurationException; + +public class SliAuditActivator implements BundleActivator{ + + private List<ServiceRegistration> registrations = new LinkedList<ServiceRegistration>(); + + + private static final EELFLogger log = EELFManager.getInstance().getLogger(SliAuditActivator.class); + + @Override + public void start(BundleContext ctx) throws Exception + { + + CompareNode compareNodePlugin = new CompareNode(); + log.info("Registering service "+ compareNodePlugin.getClass().getName()); + registrations.add(ctx.registerService(compareNodePlugin.getClass().getName(), compareNodePlugin, null)); + + } + @Override + public void stop(BundleContext arg0) throws Exception + { + for (ServiceRegistration registration: registrations) + { + registration.unregister(); + registration = null; + } + + } + +} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/SliAuditConstant.java b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/SliAuditConstant.java new file mode 100644 index 000000000..0bfaa1e36 --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/SliAuditConstant.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit; + +public class SliAuditConstant { + + public static String STRING_ENCODING = "utf-8"; + public static String Y = "Y"; + public static String N = "N"; + public static String DATA_TYPE_TEXT = "TEXT"; + public static String DATA_TYPE_JSON = "JSON"; + public static String DATA_TYPE_XML = "XML"; + public static String DATA_TYPE_SQL = "SQL"; + + public static String INPUT_PARAM_JSON_DATA = "jsonData"; + public static String INPUT_PARAM_IS_ESCAPED = "isEscaped"; + public static String INPUT_PARAM_BLOCK_KEYS = "blockKeys"; + public static String INPUT_PARAM_LOG_DATA = "logData"; + public static String INPUT_PARAM_CHECK_DATA = "checkData"; + public static String INPUT_PARAM_ESCAPE_DATA = "escapeData"; + public static String INPUT_PARAM_UNESCAPE_DATA = "unEscapeData"; + public static String INPUT_PARAM_DATA_TYPE = "dataType"; + public static String INPUT_PARAM_FILE_NAME = "fileName"; + + public static String INPUT_PARAM_TEMPLATE_DATA = "templateData"; + public static String INPUT_PARAM_TEMPLATE_FILE = "templateFile"; + public static String INPUT_PARAM_TEMPLATE_TYPE = "templateType"; + public static String INPUT_PARAM_DO_PRETTY_OUTPUT = "doPrettyOutput"; + public static String INPUT_PARAM_REQUEST_DATA = "requestData"; + public static String INPUT_PARAM_RESPONSE_PRIFIX = "responsePrefix"; + + + public static String OUTPUT_PARAM_MERGED_DATA = "mergedData"; + public static String OUTPUT_PARAM_TRANSFORMED_DATA = "transformedData"; + public static String OUTPUT_PARAM_FILE_DATA = "fileData"; + public static String OUTPUT_PARAM_PARSED_ERROR = "parsedError"; + public static String OUTPUT_PARAM_DATA_TYPE = "dataType"; + public static String OUTPUT_PARAM_STATUS = "status"; + public static String OUTPUT_PARAM_ERROR_MESSAGE = "error-message"; + public static String OUTPUT_PARAM_ESCAPE_DATA = "escapeData"; + public static String OUTPUT_PARAM_UNESCAPE_DATA = "unEscapeData"; + + public static String OUTPUT_STATUS_SUCCESS = "success"; + public static String OUTPUT_STATUS_FAILURE = "failure"; + +} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareCliData.java b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareCliData.java new file mode 100644 index 000000000..969d126bb --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareCliData.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit.node; + +public class CompareCliData implements CompareDataInterface{ + + String payloadX; + String payloadY; + + public CompareCliData(String payloadX, String payloadY) + { + super(); + this.payloadX = payloadX; + this.payloadY = payloadY; + } + + @Override + public boolean compare() throws Exception + { + if(payloadX != null && payloadX.equals(payloadY)) + return true; + else + return false; + } +} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareConstants.java b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareConstants.java new file mode 100644 index 000000000..42b18d5c3 --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareConstants.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit.node; + +public class CompareConstants { + + + public static final String FORMAT_JSON = "RESTCONF"; + public static final String FORMAT_XML = "XML"; + public static final String FORMAT_CLI = "CLI"; + public static final String NETCONF_XML = "NETCONF-XML"; + public static final String RESTCONF_XML = "RESTCONF-XML"; + + + public static final String STATUS_FAILURE = "FAILURE"; + public static final String RESPONSE_STATUS = "STATUS"; + public static final String STATUS_SUCCESS = "SUCCESS"; + + public static final String ERROR_CODE = "Error-code"; + + public static final String ERROR_MESSAGE = "Error-Message"; + public static final String ERROR_MESSAGE_DEATIL = "Compare Node Failed-Internal Error.See karaf log file"; + + public static final String NO_MATCH_MESSAGE = "The configurations do not match"; +} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareDataInterface.java b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareDataInterface.java new file mode 100644 index 000000000..95f154e2e --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareDataInterface.java @@ -0,0 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit.node; + + +public interface CompareDataInterface +{ + boolean compare() throws Exception; +} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareJsonData.java b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareJsonData.java new file mode 100644 index 000000000..422ac30ac --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareJsonData.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit.node; + +import java.io.IOException; +import java.util.Map; + + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + + +public class CompareJsonData implements CompareDataInterface { + + private static final EELFLogger log = EELFManager.getInstance().getLogger(CompareJsonData.class); + + String payloadX; + String payloadY; + + public CompareJsonData(String payloadX, String payloadY) + { + this.payloadX = payloadX; + this.payloadY = payloadY; + } + + @Override + public boolean compare() throws Exception + { + + ObjectMapper dataMapper = new ObjectMapper(); + boolean match = false; + try + { + Map<String, Object> controlData = (Map<String, Object>)(dataMapper.readValue(payloadX, Map.class)); + Map<String, Object> testData = (Map<String, Object>)(dataMapper.readValue(payloadY, Map.class)); + + log.debug("Control Data :" + controlData); + log.debug("testData Data :" + testData); + + if(controlData.equals(testData)) + match=true; + } + catch(JsonParseException e) + { + throw new Exception(e.getMessage()); + } + catch(JsonMappingException e) + { + throw new Exception(e.getMessage()); + } + catch(IOException ioe) + { + throw new Exception(ioe.getMessage()); + } + + return match; + } + + + +} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareNode.java b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareNode.java new file mode 100644 index 000000000..4ef5e269f --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareNode.java @@ -0,0 +1,138 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit.node; + + +import java.util.HashMap; +import java.util.Map; + + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; + +public class CompareNode implements SvcLogicJavaPlugin +{ + + private static final EELFLogger log = EELFManager.getInstance().getLogger(CompareNode.class); + + public void compare( Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException + { + log.debug("Starting Compare Node Analysis"); + + HashMap<String, String> status = new HashMap<String, String>(); + Parameters params = new Parameters(inParams); + try + { + if(params.getCompareDataType() != null) + { + if(params.getPayloadX() !=null && params.getPayloadY() !=null) + { + status = getCompareResults(params); + log.debug("Compare Result : " + status); + } + else + { + status.put(CompareConstants.RESPONSE_STATUS, CompareConstants.STATUS_FAILURE); + status.put(CompareConstants.ERROR_CODE, "200"); + status.put(CompareConstants.ERROR_MESSAGE, "One of the Data Received by CompareNode is Empty"); + } + } + else + { + status.put(CompareConstants.RESPONSE_STATUS, CompareConstants.STATUS_FAILURE); + status.put(CompareConstants.ERROR_CODE, "200"); + status.put(CompareConstants.ERROR_MESSAGE, "Missing compareDataType value in input request: Expecting at least one of CLI/RESTCONF/XML"); + } + + } + catch(Exception e) + { + status.put(CompareConstants.RESPONSE_STATUS, CompareConstants.STATUS_FAILURE); + status.put(CompareConstants.ERROR_CODE, "200"); + status.put(CompareConstants.ERROR_MESSAGE, CompareConstants.ERROR_MESSAGE_DEATIL); + log.debug("Error in Comapre Node Execution " + e.getMessage()); + + } + + createContextReposne(status, ctx, params.getRequestIdentifier()); + } + + private HashMap<String, String> getCompareResults(Parameters params) throws Exception + { + HashMap<String, String> resultMap = new HashMap<String, String>(); + boolean cmpResult = false; + CompareDataInterface handler; + + + + if(params.getCompareDataType().equalsIgnoreCase(CompareConstants.FORMAT_JSON)) + handler = new CompareJsonData(params.getPayloadX(), params.getPayloadY()); + else if((params.getCompareDataType().equalsIgnoreCase(CompareConstants.FORMAT_XML)) + || (params.getCompareDataType().equalsIgnoreCase(CompareConstants.NETCONF_XML)) + || (params.getCompareDataType().equalsIgnoreCase(CompareConstants.RESTCONF_XML))) + handler = new CompareXmlData(params.getPayloadX(), params.getPayloadY()); + else if (params.getCompareDataType().equalsIgnoreCase(CompareConstants.FORMAT_CLI)) + handler = new CompareCliData(params.getPayloadX(), params.getPayloadY()); + else + { + throw new Exception("Format " + params.getCompareDataType() + " not supported"); + } + try + { + log.debug("Received Format to compare : " + params.getCompareDataType()); + + cmpResult = handler.compare(); + if(cmpResult) + { + resultMap.put(CompareConstants.RESPONSE_STATUS, CompareConstants.STATUS_SUCCESS); + + } + else + { + resultMap.put(CompareConstants.RESPONSE_STATUS, CompareConstants.STATUS_FAILURE); + resultMap.put(CompareConstants.ERROR_CODE, "500"); + resultMap.put(CompareConstants.ERROR_MESSAGE, CompareConstants.NO_MATCH_MESSAGE); + } + } + catch (Exception e) + { + throw e; + } + + return resultMap; + } + + private void createContextReposne(HashMap status, SvcLogicContext ctx, String requestIdentifier ) + { + if(requestIdentifier == null) + requestIdentifier = ""; + else + requestIdentifier = requestIdentifier + "."; + + ctx.setAttribute(requestIdentifier.concat( CompareConstants.RESPONSE_STATUS), (String) status.get(CompareConstants.RESPONSE_STATUS)); + ctx.setAttribute(requestIdentifier.concat(CompareConstants.ERROR_CODE), (String) status.get(CompareConstants.ERROR_CODE)); + ctx.setAttribute(requestIdentifier.concat(CompareConstants.ERROR_MESSAGE), (String) status.get(CompareConstants.ERROR_MESSAGE)); + } + +} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareXmlData.java b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareXmlData.java new file mode 100644 index 000000000..00837092f --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareXmlData.java @@ -0,0 +1,105 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit.node; + + +import java.io.IOException; +import java.io.StringReader; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.custommonkey.xmlunit.Diff; +import org.custommonkey.xmlunit.XMLUnit; +import org.w3c.dom.Document; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + + +public class CompareXmlData implements CompareDataInterface +{ + private static final EELFLogger log = EELFManager.getInstance().getLogger(CompareXmlData.class); + + + String controlXml; + String testXml; + + Document doc; + + public CompareXmlData(String controlXml, String testXml) { + super(); + this.controlXml = controlXml; + this.testXml = testXml; + } + + @Override + public boolean compare() throws Exception + { + + log.debug("controlXml : " + controlXml); + log.debug("testXml : " + testXml); + + doSetup(); + + try + { + Diff diff = new Diff(getCompareDoc(controlXml), getCompareDoc(testXml)); + if(diff.similar()) + return true; + else + return false; + } + catch(SAXException se) + { + se.printStackTrace(); + throw new Exception(se.getMessage()); + } + catch(Exception e) + { + e.printStackTrace(); + throw new Exception(e.getMessage()); + } + } + + private void doSetup() throws ParserConfigurationException, SAXException, IOException + { + + XMLUnit.setIgnoreAttributeOrder(true); + XMLUnit.setIgnoreComments(true); + XMLUnit.setIgnoreWhitespace(true); + } + + public Document getCompareDoc(String inXml) throws ParserConfigurationException, SAXException, IOException + { + DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); + StringReader reader = new StringReader(inXml); + InputSource inputSource = new InputSource(reader); + Document doc = dBuilder.parse(inputSource); + doc.getDocumentElement().normalize(); + + return doc; + } +} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/Parameters.java b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/Parameters.java new file mode 100644 index 000000000..e3358df11 --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/Parameters.java @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit.node; + + +import java.util.Map; + +public class Parameters +{ + + String payloadX ; + + public String getPayloadX() { + return payloadX; + } + public void setPayloadX(String payloadX) { + this.payloadX = payloadX; + } + + String payloadXtype; + + public String getPayloadXtype() { + return payloadXtype; + } + public void setPayloadXtype(String payloadXtype) { + this.payloadXtype = payloadXtype; + } + + String payloadY ; + + public String getPayloadY() { + return payloadY; + } + public void setPayloadY(String payloadY) { + this.payloadY = payloadY; + } + + String payloadYtype; + + public String getPayloadYtype() { + return payloadYtype; + } + public void setPayloadYtype(String payloadYtype) { + this.payloadYtype = payloadYtype; + } + + String compareDataType; + + public String getCompareDataType() { + return compareDataType; + } + public void setCompareDataType(String compareDataType) { + this.compareDataType = compareDataType; + } + + String compareType; + + public String getCompareType() { + return compareType; + } + public void setCompareType(String compareType) { + this.compareType = compareType; + } + + String requestIdentifier; + + public String getRequestIdentifier() { + return requestIdentifier; + } + public void setRequestIdentifier(String requestIdentifier) { + this.requestIdentifier = requestIdentifier; + } + public Parameters(Map<String, String> inParams) + { + this.compareType = inParams.get("compareType"); + this.compareDataType = inParams.get("compareDataType"); + this.payloadX= inParams.get("sourceData"); + this.payloadY= inParams.get("targetData"); + this.payloadXtype = inParams.get("sourceDataType"); + this.payloadYtype = inParams.get("targetDataType"); + this.requestIdentifier = inParams.get("requestIdentifier"); + + } +} diff --git a/appc-config/appc-config-audit/provider/src/main/resources/adaptor.properties b/appc-config/appc-config-audit/provider/src/main/resources/adaptor.properties new file mode 100644 index 000000000..b6261a303 --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/main/resources/adaptor.properties @@ -0,0 +1,25 @@ +### +# ============LICENSE_START======================================================= +# ONAP : APP-C +# ================================================================================ +# Copyright (C) 2017 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. +# ============LICENSE_END========================================================= +### + +adaptorName= +vSphere.url= +vSphere.user= +vSphere.passwd= +org.xml.sax.driver= diff --git a/appc-config/appc-config-audit/provider/src/test/java/org/openecomp/sdnc/config/audit/node/TestCompareNodeCli.java b/appc-config/appc-config-audit/provider/src/test/java/org/openecomp/sdnc/config/audit/node/TestCompareNodeCli.java new file mode 100644 index 000000000..ad1112ffc --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/test/java/org/openecomp/sdnc/config/audit/node/TestCompareNodeCli.java @@ -0,0 +1,100 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit.node; + +import java.util.HashMap; + +import org.junit.Test; +import org.openecomp.sdnc.config.audit.node.CompareNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; + +public class TestCompareNodeCli +{ +private static final Logger log = LoggerFactory.getLogger(TestCompareNodeCli.class); + + +//@Test + public void TestCompareCliForSamePayload() + { + SvcLogicContext ctx = new SvcLogicContext(); + HashMap<String, String> testMap = new HashMap<String, String>(); + CompareNode cmp = new CompareNode(); + try + { + testMap.put("compareDataType", "Cli"); + testMap.put("sourceData", "This is a Text Configuration of Device"); + testMap.put("targetData", "This is a Text Configuration of Device"); + cmp.compare(testMap, ctx); + assert(ctx.getAttribute("STATUS").equals("SUCCESS")); + } + catch (SvcLogicException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + //@Test + public void TestCompareCliFordifferentPayload() + { + SvcLogicContext ctx = new SvcLogicContext(); + HashMap<String, String> testMap = new HashMap<String, String>(); + CompareNode cmp = new CompareNode(); + try + { + testMap.put("compareDataType", "Cli"); + testMap.put("sourceData", "This is a Text Negative test Configuration of Device"); + testMap.put("targetData", "This is a Text Configuration of Device"); + cmp.compare(testMap, ctx); + assert(ctx.getAttribute("STATUS").equals("FAILURE")); + } + catch (SvcLogicException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + //@Test + public void TestCompareForMissingInput() + { + SvcLogicContext ctx = new SvcLogicContext(); + HashMap<String, String> testMap = new HashMap<String, String>(); + CompareNode cmp = new CompareNode(); + try + { + // testMap.put("compareDataType", "Cli"); Missing compareDataType from the input + testMap.put("sourceData", "This is a Text Negative test Configuration of Device"); + testMap.put("targetData.configuration-data", "This is a Text Configuration of Device"); + cmp.compare(testMap, ctx); + assert(ctx.getAttribute("STATUS").equals("FAILURE")); + } + catch (SvcLogicException e) + { + assert(ctx.getAttribute("STATUS").equals("FAILURE")); + } + } + +} diff --git a/appc-config/appc-config-audit/provider/src/test/java/org/openecomp/sdnc/config/audit/node/TestCompareNodeJson.java b/appc-config/appc-config-audit/provider/src/test/java/org/openecomp/sdnc/config/audit/node/TestCompareNodeJson.java new file mode 100644 index 000000000..cb1fd3795 --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/test/java/org/openecomp/sdnc/config/audit/node/TestCompareNodeJson.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit.node; + +import java.util.HashMap; + +import org.junit.Test; +import org.openecomp.sdnc.config.audit.node.CompareNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; + +public class TestCompareNodeJson +{ +private static final Logger log = LoggerFactory.getLogger(TestCompareNodeJson.class); + + //@Test + public void TestCompareJsonForSamePayload() + { + SvcLogicContext ctx = new SvcLogicContext(); + HashMap<String, String> testMap = new HashMap<String, String>(); + CompareNode cmp = new CompareNode(); + try + { + String controlJson = "{\n\"input\": {\n \"appc-request-header\": {\n \"svc-request-id\": \"000000000\", \n \"svc-action\": \"prepare\" \n }, \n\"request-information\": {\n \"request-id\": \"000000000\", \n\"request-action\": \"VsbgServiceActivateRequest\", \n\"request-sub-action\": \"PREPARE\", \n \"source\": \"Version2\" \n} \n} \n}"; + String testJson = "{\n\"input\": {\n \"appc-request-header\": {\n \"svc-request-id\": \"000000000\", \n \"svc-action\": \"prepare\" \n }, \n\"request-information\": {\n \"request-id\": \"000000000\", \n\"request-action\": \"VsbgServiceActivateRequest\", \n\"request-sub-action\": \"PREPARE\", \n \"source\": \"Version2\" \n} \n} \n}"; + testMap.put("compareDataType", "RestConf"); + testMap.put("sourceData", controlJson); + testMap.put("targetData", testJson); + cmp.compare(testMap, ctx); + assert(ctx.getAttribute("STATUS").equals("SUCCESS")); + } + catch (SvcLogicException e) + { + e.printStackTrace(); + } + } + + //@Test + public void TestCompareJsonFordifferentPayload() + { + SvcLogicContext ctx = new SvcLogicContext(); + HashMap<String, String> testMap = new HashMap<String, String>(); + CompareNode cmp = new CompareNode(); + try + { + String controlJson = "{\n\"input\": {\n \"appc-request-header\": {\n \"svc-request-id\": \"000000000\", \n \"svc-action\": \"prepare\" \n }, \n\"request-information\": {\n \"request-id\": \"000000000\", \n\"request-action\": \"VsbgServiceActivateRequest\", \n\"request-sub-action\": \"PREPARE\", \n \"source\": \"Version2\" \n} \n} \n}"; + String testJson = "{\n\"input\": {\n \"appc-request-header\": { \n \"svc-action\": \"prepare\" \n }, \n\"request-information\": {\n \"request-id\": \"0000000000\", \n\"request-action\": \"VsbgServiceActivateRequest\", \n\"request-sub-action\": \"PREPARE\", \n \"source\": \"Version2\" \n} \n} \n}"; + testMap.put("compareDataType", "RestConf"); + testMap.put("sourceData", controlJson); + testMap.put("targetData", testJson); + cmp.compare(testMap, ctx); + assert(ctx.getAttribute("STATUS").equals("FAILURE")); + } + catch (SvcLogicException e) + { + e.printStackTrace(); + } + } +} diff --git a/appc-config/appc-config-audit/provider/src/test/java/org/openecomp/sdnc/config/audit/node/TestCompareNodeXml.java b/appc-config/appc-config-audit/provider/src/test/java/org/openecomp/sdnc/config/audit/node/TestCompareNodeXml.java new file mode 100644 index 000000000..efd23439f --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/test/java/org/openecomp/sdnc/config/audit/node/TestCompareNodeXml.java @@ -0,0 +1,127 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit.node; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Properties; + +import org.junit.Test; +import org.openecomp.sdnc.config.audit.node.CompareNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; + + +public class TestCompareNodeXml +{ + private static final Logger log = LoggerFactory.getLogger(TestCompareNodeXml.class); + + //@Test + public void TestCompareExtactXML() + { + log.debug("TestCompareNode.TestCompareExtactXML()"); + SvcLogicContext ctx = new SvcLogicContext(); + HashMap<String, String> testMap = new HashMap<String, String>(); + CompareNode cmp = new CompareNode(); + try + { + String s="<configuration xmlns=" + + "\"http://xml.juniper.net/xnm/1.1/xnm\"" + + " junos:commit-seconds=" + +"\"1473957536\" " + +"junos:commit-localtime=" + +"\"2016-09-15 16:38:56 UTC\" " + + "junos:commit-user=" + +"\"root\"" + +"><name>Test</name></configuration>"; + + String t ="<configuration xmlns=" + + "\"http://xml.juniper.net/xnm/1.1/xnm\"" + + " junos:commit-seconds=" + +"\"1473957536\" " + +"junos:commit-localtime=" + +"\"2016-09-15 16:38:56 UTC\" " + + "junos:commit-user=" + +"\"root\"" + +"><name>Test</name></configuration>"; + + System.out.println("s=" + s); + + testMap.put("compareDataType", "RESTCONF-XML"); + testMap.put("requestIdentifier", "123"); + testMap.put("sourceData", s); + testMap.put("targetData", t); + cmp.compare(testMap, ctx); + assert(ctx.getAttribute("123." + "STATUS").equals("SUCCESS")); + } + catch (SvcLogicException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + //@Test + public void TestCompareforAttributeOrder() throws IOException + { + log.debug("TestCompareNode.TestCompareforAttributeOrder()"); + SvcLogicContext ctx = new SvcLogicContext(); + HashMap<String, String> testMap = new HashMap<String, String>(); + CompareNode cmp = new CompareNode(); + testMap.put("compareDataType", "XML"); + testMap.put("sourceData", "<SipIfTermination><id>2</id><udpPortInUse>true</udpPortInUse><udpPort>5060</udpPort><tcpPortInUse>true</tcpPortInUse><tcpPort>5060</tcpPort></SipIfTermination>"); + testMap.put("targetData", "<SipIfTermination><udpPortInUse>true</udpPortInUse><udpPort>5060</udpPort><tcpPortInUse>true</tcpPortInUse><tcpPort>5060</tcpPort><id>2</id></SipIfTermination>"); + try + { + cmp.compare(testMap, ctx); + } + catch (SvcLogicException e) + { + e.printStackTrace(); + } + assert(ctx.getAttribute("STATUS").equals("SUCCESS")); + } + + //@Test + public void TestCompareForComments() + { + log.debug("TestCompareNode.TestCompareForComments()"); + SvcLogicContext ctx = new SvcLogicContext(); + HashMap<String, String> testMap = new HashMap<String, String>(); + CompareNode cmp = new CompareNode(); + + try + { + testMap.put("compareDataType", "XML"); + testMap.put("sourceData", "<SipIfTermination><id>2</id><!--this is a commnect --></SipIfTermination>"); + testMap.put("targetData", "<SipIfTermination><id>2</id></SipIfTermination>"); + cmp.compare(testMap, ctx); + assert(ctx.getAttribute("STATUS").equals("SUCCESS")); + } + catch (SvcLogicException e) + { + e.printStackTrace(); + } + } + +} diff --git a/appc-config/appc-config-audit/provider/src/test/resources/convert/escape/config_msc.txt b/appc-config/appc-config-audit/provider/src/test/resources/convert/escape/config_msc.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/test/resources/convert/escape/config_msc.txt diff --git a/appc-config/appc-config-audit/provider/src/test/resources/convert/escape/config_ssc.txt b/appc-config/appc-config-audit/provider/src/test/resources/convert/escape/config_ssc.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/test/resources/convert/escape/config_ssc.txt diff --git a/appc-config/appc-config-audit/provider/src/test/resources/convert/escape/config_vdbe.xml b/appc-config/appc-config-audit/provider/src/test/resources/convert/escape/config_vdbe.xml new file mode 100644 index 000000000..787796704 --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/test/resources/convert/escape/config_vdbe.xml @@ -0,0 +1,19 @@ +<!-- + ============LICENSE_START======================================================= + ONAP : APP-C + ================================================================================ + Copyright (C) 2017 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. + ============LICENSE_END========================================================= + --> diff --git a/appc-config/appc-config-audit/provider/src/test/resources/convert/payload_cli_config.json b/appc-config/appc-config-audit/provider/src/test/resources/convert/payload_cli_config.json new file mode 100644 index 000000000..a82eaf0f1 --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/test/resources/convert/payload_cli_config.json @@ -0,0 +1,19 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 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. + * ============LICENSE_END========================================================= + */ diff --git a/appc-config/appc-config-audit/provider/src/test/resources/convert/payload_json_config.json b/appc-config/appc-config-audit/provider/src/test/resources/convert/payload_json_config.json new file mode 100644 index 000000000..a82eaf0f1 --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/test/resources/convert/payload_json_config.json @@ -0,0 +1,19 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 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. + * ============LICENSE_END========================================================= + */ diff --git a/appc-config/appc-config-audit/provider/src/test/resources/convert/payload_parameters_config.json b/appc-config/appc-config-audit/provider/src/test/resources/convert/payload_parameters_config.json new file mode 100644 index 000000000..a82eaf0f1 --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/test/resources/convert/payload_parameters_config.json @@ -0,0 +1,19 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 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. + * ============LICENSE_END========================================================= + */ diff --git a/appc-config/appc-config-audit/provider/src/test/resources/convert/payload_template_config.json b/appc-config/appc-config-audit/provider/src/test/resources/convert/payload_template_config.json new file mode 100644 index 000000000..a82eaf0f1 --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/test/resources/convert/payload_template_config.json @@ -0,0 +1,19 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 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. + * ============LICENSE_END========================================================= + */ diff --git a/appc-config/appc-config-audit/provider/src/test/resources/convert/payload_xml_config.json b/appc-config/appc-config-audit/provider/src/test/resources/convert/payload_xml_config.json new file mode 100644 index 000000000..a82eaf0f1 --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/test/resources/convert/payload_xml_config.json @@ -0,0 +1,19 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 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. + * ============LICENSE_END========================================================= + */ |