Commit bf0829af authored by Spiros Koulouzis's avatar Spiros Koulouzis

added decryption in tests

parent 7ac714b8
...@@ -15,14 +15,12 @@ ...@@ -15,14 +15,12 @@
*/ */
package nl.uva.sne.drip.commons.utils; package nl.uva.sne.drip.commons.utils;
import java.util.Map;
import org.junit.After; import org.junit.After;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.springframework.web.multipart.MultipartFile;
/** /**
* *
...@@ -56,7 +54,7 @@ public class ConverterTest { ...@@ -56,7 +54,7 @@ public class ConverterTest {
public void testEncryptDecryptString() throws Exception { public void testEncryptDecryptString() throws Exception {
System.out.println("decryptString"); System.out.println("decryptString");
String contents = "this is very important information"; String contents = "this is very important information";
String secret = "1223"; String secret = "top_secret";
String expResult = contents; String expResult = contents;
String enc = Converter.encryptString(contents, secret); String enc = Converter.encryptString(contents, secret);
System.out.println("Encrypted String: " + enc); System.out.println("Encrypted String: " + enc);
......
{ {
"owner": "user", "owner": "user",
"creationDate": 1585660972026, "creationDate": 1591357712632,
"toscaTemplate": { "toscaTemplate": {
"tosca_definitions_version": "tosca_simple_yaml_1_0", "tosca_definitions_version": "tosca_simple_yaml_1_0",
"tosca_default_namespace": null, "tosca_default_namespace": null,
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"node_templates": { "node_templates": {
"compute": { "compute": {
"properties": { "properties": {
"disk_size": "10000 MB", "disk_size": "20000 MB",
"mem_size": "1000 MB", "mem_size": "1000 MB",
"num_cores": 1, "num_cores": 1,
"os": "Ubuntu 18.04", "os": "Ubuntu 18.04",
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
}, },
"compute_1": { "compute_1": {
"properties": { "properties": {
"disk_size": "10000 MB", "disk_size": "20000 MB",
"mem_size": "1000 MB", "mem_size": "1000 MB",
"num_cores": 1, "num_cores": 1,
"os": "Ubuntu 18.04", "os": "Ubuntu 18.04",
...@@ -39,7 +39,11 @@ ...@@ -39,7 +39,11 @@
}, },
"type": "tosca.nodes.QC.VM.Compute" "type": "tosca.nodes.QC.VM.Compute"
}, },
"kubernetes": { "glusterfs": {
"properties": {
"min_masters_num": 1,
"min_workers_num": 1
},
"requirements": [ "requirements": [
{ {
"host": { "host": {
...@@ -53,25 +57,60 @@ ...@@ -53,25 +57,60 @@
"Standard": { "Standard": {
"configure": { "configure": {
"inputs": { "inputs": {
"playbook": "k8s_dashboard.yaml", "repository": "https://github.com/QCDIS/mysome_glusterfs.git",
"repository": "https://github.com/skoulouzis/playbooks.git" "resources": [
"002.setup_glusterfs_infra.yml",
"003.setup_glusterfs_cluster.yml",
"004.mount_glusterfs.yml"
]
} }
}, },
"create": { "create": {
"inputs": { "inputs": {
"playbook": "install_k8s.yaml", "repository": "https://github.com/QCDIS/playbooks.git",
"repository": "https://github.com/skoulouzis/playbooks.git" "resources": [
"ec2/ec2_mount.yaml",
"install_glusterfs_prerequisites.yaml"
]
} }
}, }
"delete": { }
},
"type": "tosca.nodes.QC.Application.GlusterFS"
},
"tic": {
"requirements": [
{
"storage": {
"capability": "tosca.capabilities.QC.GlusterFS",
"node": "glusterfs",
"relationship": "tosca.relationships.DependsOn"
}
}
],
"interfaces": {
"Standard": {
"create": {
"inputs": { "inputs": {
"playbook": "k8s_delete.yaml", "repository": "https://github.com/bityoga/fabric_as_code.git",
"repository": "https://github.com/skoulouzis/playbooks.git" "resources": [
"011.initialize_hosts.yml",
"012.prepare_docker_images.yml",
"013.mount_fs.yml",
"014.spawn_swarm.yml",
"015.deploy_swarm_visualizer.yml",
"016.deploy_portainer.yml",
"100.deploy_ca.yml",
"101.deploy_orderer.yml",
"102.deploy_peers.yml",
"103.deploy_cli.yml",
"104.deploy_hlf_explorer.yml"
]
} }
} }
} }
}, },
"type": "tosca.nodes.QC.docker.Orchestrator.Kubernetes" "type": "tosca.nodes.QC.Application.TIC"
}, },
"topology": { "topology": {
"properties": { "properties": {
...@@ -133,9 +172,9 @@ ...@@ -133,9 +172,9 @@
"credential": { "credential": {
"cloud_provider_name": "EC2", "cloud_provider_name": "EC2",
"keys": { "keys": {
"aws_access_key_id": "XXXXXXXXXXXX" "aws_access_key_id": "BGCAc9htRRjcZx5uZ6aWnRo67tNAgk7M26DwuN3cZvypnCt6V56U9RbEuRpmXbER"
}, },
"token": "XXXXXXXXXXXXX", "token": "BGCAc9htRRjcZx5uZ6aWnRo67tNAgk7M26DwuN3cZvypnCt6V56U9RbEuRpmXbER",
"token_type": "access_key" "token_type": "access_key"
}, },
"desired_state": "RUNNING" "desired_state": "RUNNING"
...@@ -146,30 +185,6 @@ ...@@ -146,30 +185,6 @@
"type": "string" "type": "string"
} }
} }
},
"ws-pema": {
"properties": {
"ports": [
"30001:8080"
]
},
"requirements": [
{
"host": {
"capability": "tosca.capabilities.QC.docker.Orchestrator",
"node": "kubernetes",
"relationship": "tosca.relationships.HostedOn"
}
}
],
"type": "tosca.nodes.QC.Container.Application.Docker",
"artifacts": {
"image": {
"file": "alogo53/ws-pema-lifewatch",
"repository": "docker_hub",
"type": "tosca.artifacts.Deployment.Image.Container.Docker"
}
}
} }
}, },
"relationship_templates": null, "relationship_templates": null,
...@@ -183,19 +198,19 @@ ...@@ -183,19 +198,19 @@
"description": "TOSCA example", "description": "TOSCA example",
"imports": [ "imports": [
{ {
"nodes": "https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/nodes.yaml" "nodes": "https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/types/nodes.yaml"
}, },
{ {
"data": "https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/data.yml" "data": "https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/types/data.yml"
}, },
{ {
"capabilities": "https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/capabilities.yaml" "capabilities": "https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/types/capabilities.yaml"
}, },
{ {
"policies": "https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/policies.yaml" "policies": "https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/types/policies.yaml"
}, },
{ {
"interfaces": "https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/interfaces.yml" "interfaces": "https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/types/interfaces.yml"
} }
], ],
"dsl_definitions": null, "dsl_definitions": null,
......
...@@ -68,7 +68,7 @@ import topology.analysis.TopologyAnalysisMain; ...@@ -68,7 +68,7 @@ import topology.analysis.TopologyAnalysisMain;
*/ */
class CloudStormService { class CloudStormService {
private String secret; protected String secret;
private String credentialSecret; private String credentialSecret;
/** /**
...@@ -480,7 +480,7 @@ class CloudStormService { ...@@ -480,7 +480,7 @@ class CloudStormService {
userKyes.put("private_key", Converter.encodeFileToBase64Binary(userKyePairFolder + File.separator + "id_rsa")); userKyes.put("private_key", Converter.encodeFileToBase64Binary(userKyePairFolder + File.separator + "id_rsa"));
userKyes.put("public_key", Converter.encodeFileToBase64Binary(userKyePairFolder + File.separator + "id_rsa.pub")); userKyes.put("public_key", Converter.encodeFileToBase64Binary(userKyePairFolder + File.separator + "id_rsa.pub"));
userKeyPairCredential.setKeys(userKyes); userKeyPairCredential.setKeys(userKyes);
// userKeyPairCredential = Converter.encryptCredential(userKeyPairCredential, credentialSecret);
CloudsStormVMs cloudsStormVMs = objectMapper.readValue(new File(tempInputDirPath + TOPOLOGY_RELATIVE_PATH + File.separator + subTopology.getTopology() + ".yml"), CloudsStormVMs cloudsStormVMs = objectMapper.readValue(new File(tempInputDirPath + TOPOLOGY_RELATIVE_PATH + File.separator + subTopology.getTopology() + ".yml"),
CloudsStormVMs.class); CloudsStormVMs.class);
List<CloudsStormVM> vms = cloudsStormVMs.getVms(); List<CloudsStormVM> vms = cloudsStormVMs.getVms();
......
...@@ -284,6 +284,7 @@ public class CloudStormServiceTest { ...@@ -284,6 +284,7 @@ public class CloudStormServiceTest {
assertTrue(provisionedFiles.containsKey("file_contents")); assertTrue(provisionedFiles.containsKey("file_contents"));
String cloudStormZipFileContentsAsBase64 = provisionedFiles.get("file_contents"); String cloudStormZipFileContentsAsBase64 = provisionedFiles.get("file_contents");
cloudStormZipFileContentsAsBase64 = Converter.decryptString(cloudStormZipFileContentsAsBase64, instance.secret);
String testZipPath = tempInputDirPath + File.separator + "test.zip"; String testZipPath = tempInputDirPath + File.separator + "test.zip";
Converter.decodeBase64BToFile(cloudStormZipFileContentsAsBase64, testZipPath); Converter.decodeBase64BToFile(cloudStormZipFileContentsAsBase64, testZipPath);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment