Commit bf0829af authored by Spiros Koulouzis's avatar Spiros Koulouzis

added decryption in tests

parent 7ac714b8
......@@ -15,14 +15,12 @@
*/
package nl.uva.sne.drip.commons.utils;
import java.util.Map;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
import org.springframework.web.multipart.MultipartFile;
/**
*
......@@ -56,7 +54,7 @@ public class ConverterTest {
public void testEncryptDecryptString() throws Exception {
System.out.println("decryptString");
String contents = "this is very important information";
String secret = "1223";
String secret = "top_secret";
String expResult = contents;
String enc = Converter.encryptString(contents, secret);
System.out.println("Encrypted String: " + enc);
......
{
"owner": "user",
"creationDate": 1585660972026,
"creationDate": 1591357712632,
"toscaTemplate": {
"tosca_definitions_version": "tosca_simple_yaml_1_0",
"tosca_default_namespace": null,
......@@ -11,7 +11,7 @@
"node_templates": {
"compute": {
"properties": {
"disk_size": "10000 MB",
"disk_size": "20000 MB",
"mem_size": "1000 MB",
"num_cores": 1,
"os": "Ubuntu 18.04",
......@@ -26,7 +26,7 @@
},
"compute_1": {
"properties": {
"disk_size": "10000 MB",
"disk_size": "20000 MB",
"mem_size": "1000 MB",
"num_cores": 1,
"os": "Ubuntu 18.04",
......@@ -39,7 +39,11 @@
},
"type": "tosca.nodes.QC.VM.Compute"
},
"kubernetes": {
"glusterfs": {
"properties": {
"min_masters_num": 1,
"min_workers_num": 1
},
"requirements": [
{
"host": {
......@@ -53,25 +57,60 @@
"Standard": {
"configure": {
"inputs": {
"playbook": "k8s_dashboard.yaml",
"repository": "https://github.com/skoulouzis/playbooks.git"
"repository": "https://github.com/QCDIS/mysome_glusterfs.git",
"resources": [
"002.setup_glusterfs_infra.yml",
"003.setup_glusterfs_cluster.yml",
"004.mount_glusterfs.yml"
]
}
},
"create": {
"inputs": {
"playbook": "install_k8s.yaml",
"repository": "https://github.com/skoulouzis/playbooks.git"
"repository": "https://github.com/QCDIS/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": {
"playbook": "k8s_delete.yaml",
"repository": "https://github.com/skoulouzis/playbooks.git"
"repository": "https://github.com/bityoga/fabric_as_code.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": {
"properties": {
......@@ -133,9 +172,9 @@
"credential": {
"cloud_provider_name": "EC2",
"keys": {
"aws_access_key_id": "XXXXXXXXXXXX"
"aws_access_key_id": "BGCAc9htRRjcZx5uZ6aWnRo67tNAgk7M26DwuN3cZvypnCt6V56U9RbEuRpmXbER"
},
"token": "XXXXXXXXXXXXX",
"token": "BGCAc9htRRjcZx5uZ6aWnRo67tNAgk7M26DwuN3cZvypnCt6V56U9RbEuRpmXbER",
"token_type": "access_key"
},
"desired_state": "RUNNING"
......@@ -146,30 +185,6 @@
"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,
......@@ -183,19 +198,19 @@
"description": "TOSCA example",
"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,
......
......@@ -68,7 +68,7 @@ import topology.analysis.TopologyAnalysisMain;
*/
class CloudStormService {
private String secret;
protected String secret;
private String credentialSecret;
/**
......@@ -480,7 +480,7 @@ class CloudStormService {
userKyes.put("private_key", Converter.encodeFileToBase64Binary(userKyePairFolder + File.separator + "id_rsa"));
userKyes.put("public_key", Converter.encodeFileToBase64Binary(userKyePairFolder + File.separator + "id_rsa.pub"));
userKeyPairCredential.setKeys(userKyes);
// userKeyPairCredential = Converter.encryptCredential(userKeyPairCredential, credentialSecret);
CloudsStormVMs cloudsStormVMs = objectMapper.readValue(new File(tempInputDirPath + TOPOLOGY_RELATIVE_PATH + File.separator + subTopology.getTopology() + ".yml"),
CloudsStormVMs.class);
List<CloudsStormVM> vms = cloudsStormVMs.getVms();
......
......@@ -284,6 +284,7 @@ public class CloudStormServiceTest {
assertTrue(provisionedFiles.containsKey("file_contents"));
String cloudStormZipFileContentsAsBase64 = provisionedFiles.get("file_contents");
cloudStormZipFileContentsAsBase64 = Converter.decryptString(cloudStormZipFileContentsAsBase64, instance.secret);
String testZipPath = tempInputDirPath + File.separator + "test.zip";
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