aboutsummaryrefslogtreecommitdiffstats
path: root/appc-config/appc-encryption-tool/provider/src/test/java
diff options
context:
space:
mode:
authorGeorge, Lina (lg941u) <lg941u@att.com>2019-01-30 16:01:19 -0500
committerPatrick Brady <patrick.brady@att.com>2019-02-05 18:28:34 +0000
commitbeac33deccb8b7f98e7f96a17541abb81b246d16 (patch)
tree1a3ce5be113934c9836634c46a3b6d72093ed390 /appc-config/appc-encryption-tool/provider/src/test/java
parent688a1bd4f99cb856b067c7b38c02cdab27070865 (diff)
Encryption tool changes for multiple ansibleserver
Issue-ID: APPC-1342 Change-Id: Ib1ff7845ad65cf13c06a96d6dcce023b06064dfa Signed-off-by: George, Lina (lg941u) <lg941u@att.com>
Diffstat (limited to 'appc-config/appc-encryption-tool/provider/src/test/java')
-rw-r--r--appc-config/appc-encryption-tool/provider/src/test/java/org/onap/appc/encryptiontool/MockParseAdminArtifcat.java48
-rw-r--r--appc-config/appc-encryption-tool/provider/src/test/java/org/onap/appc/encryptiontool/TestParseAdminArtifact.java63
2 files changed, 111 insertions, 0 deletions
diff --git a/appc-config/appc-encryption-tool/provider/src/test/java/org/onap/appc/encryptiontool/MockParseAdminArtifcat.java b/appc-config/appc-encryption-tool/provider/src/test/java/org/onap/appc/encryptiontool/MockParseAdminArtifcat.java
new file mode 100644
index 000000000..8f00e5fd3
--- /dev/null
+++ b/appc-config/appc-encryption-tool/provider/src/test/java/org/onap/appc/encryptiontool/MockParseAdminArtifcat.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018-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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.encryptiontool;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import org.apache.commons.io.IOUtils;
+import org.onap.appc.encryptiontool.fqdn.ParseAdminArtifcat;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+
+public class MockParseAdminArtifcat extends ParseAdminArtifcat {
+
+ @Override
+ public String getAdminArtifact(SvcLogicContext ctx) {
+ try {
+ return readInput("src/test/resources/org/onap/appc/adminartifcat.json");
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private String readInput(String inputFile) throws IOException {
+ String file = null;
+ FileInputStream fileInputStream = new FileInputStream(inputFile);
+ file = IOUtils.toString(fileInputStream, "UTF-8");
+ return file;
+ }
+
+}
diff --git a/appc-config/appc-encryption-tool/provider/src/test/java/org/onap/appc/encryptiontool/TestParseAdminArtifact.java b/appc-config/appc-encryption-tool/provider/src/test/java/org/onap/appc/encryptiontool/TestParseAdminArtifact.java
new file mode 100644
index 000000000..79c658c55
--- /dev/null
+++ b/appc-config/appc-encryption-tool/provider/src/test/java/org/onap/appc/encryptiontool/TestParseAdminArtifact.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018-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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.encryptiontool;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.apache.commons.lang3.StringUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.appc.encryptiontool.fqdn.ParseAdminArtifcat;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+
+public class TestParseAdminArtifact {
+ SvcLogicContext ctx = null;
+ ParseAdminArtifcat parseAdminArtifact = null;
+
+ @Before
+ public void setup() throws IOException {
+ parseAdminArtifact = new MockParseAdminArtifcat();
+ }
+
+ @Test
+ public void testRetrieveFqdn() throws Exception {
+ ctx = new SvcLogicContext();
+ ctx.setAttribute("tenantAai", "tenantuuid1");
+ ctx.setAttribute("cloudOwneraai", "aic3.0");
+ ctx.setAttribute("cloudRegionAai", "san4a");
+ try {
+ String fqdnMatchPayload = parseAdminArtifact.retrieveFqdn(ctx);
+ assertEquals("fqdn-value1 url:port", fqdnMatchPayload);
+
+ } catch (SvcLogicException | RuntimeException | IOException e) {
+ e.printStackTrace();
+ throw new Exception("Failed to retrieve fqdn:"+ e.getMessage());
+ }
+
+ }
+
+}