diff options
author | 2019-01-30 16:01:19 -0500 | |
---|---|---|
committer | 2019-02-05 18:28:34 +0000 | |
commit | beac33deccb8b7f98e7f96a17541abb81b246d16 (patch) | |
tree | 1a3ce5be113934c9836634c46a3b6d72093ed390 /appc-config/appc-encryption-tool/provider/src/test | |
parent | 688a1bd4f99cb856b067c7b38c02cdab27070865 (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')
3 files changed, 204 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()); + } + + } + +} diff --git a/appc-config/appc-encryption-tool/provider/src/test/resources/org/onap/appc/adminartifcat.json b/appc-config/appc-encryption-tool/provider/src/test/resources/org/onap/appc/adminartifcat.json new file mode 100644 index 000000000..94c43df2b --- /dev/null +++ b/appc-config/appc-encryption-tool/provider/src/test/resources/org/onap/appc/adminartifcat.json @@ -0,0 +1,93 @@ +
+
+{"fqdn-list": [
+ {
+ "vnf-management-server-fqdn": "fqdn-value1 url:port",
+ "cloud-owner-list": [
+ {
+ "cloud-owner": "aic3.0",
+ "region-id-list": [
+ {
+ "region-id": "san4a",
+ "tenant-id-list": [
+ "tenantuuid1",
+ "tenantuuid2"
+ ]
+ },
+ {
+ "region-id": "san4b",
+ "tenant-id-list": [
+ "tenantuuid1",
+ "tenantuuid2"
+ ]
+ }
+ ]
+ },
+ {
+ "cloud-owner": "nc1.0",
+ "region-id-list": [
+ {
+ "region-id": "san4a",
+ "tenant-id-list": [
+
+ "tenantuuid3",
+ "tenantuuid4"
+
+ ]
+ }
+ ]
+ }
+ ],
+ "description": "fqdn for east zone vUSP Production",
+ "username": "albino attuid",
+ "create-date": "",
+ "modify-username": "",
+ "modify-date": ""
+ },
+ {
+ "vnf-management-server-fqdn": "fqdn-value2 url:port",
+ "cloud-owner-list": [
+ {
+ "cloud-owner": "aic3.0",
+ "region-id-list": [
+ {
+ "region-id": "san4a",
+ "tenant-id-list": [
+ "tenantuuid5",
+ "tenantuuid6"
+ ]
+ },
+ {
+ "region-id": "san4b",
+ "tenant-id-list": [
+ "tenantuuid5",
+ "tenantuuid6"
+ ]
+ }
+ ]
+ },
+ {
+ "cloud-owner": "nc1.0",
+ "region-id-list": [
+ {
+ "region-id": "san4a",
+ "tenant-id-list": [
+
+ "tenantuuid7",
+ "tenantuuid8"
+
+ ]
+ }
+ ]
+ }
+ ],
+ "description": "fqdn for east zone vUSP E2E",
+ "username": "albino attuid",
+ "create-date": "",
+ "modify-username": "",
+ "modify-date": ""
+ }
+
+ ]
+}
+
|