Fixed test to used Vault in place of Encrypted
This commit is contained in:
parent
6c74d0f0fd
commit
e7b6f7c889
5
pom.xml
5
pom.xml
|
@ -74,6 +74,11 @@
|
|||
<artifactId>gcube-model</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-encryption</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.information-system</groupId>
|
||||
<artifactId>resource-registry-client</artifactId>
|
||||
|
|
|
@ -12,18 +12,19 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.common.encryption.encrypter.StringEncrypter;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.model.impl.properties.EncryptedImpl;
|
||||
import org.gcube.informationsystem.model.impl.properties.PropagationConstraintImpl;
|
||||
import org.gcube.informationsystem.model.impl.properties.VaultImpl;
|
||||
import org.gcube.informationsystem.model.impl.relations.ConsistsOfImpl;
|
||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||
import org.gcube.informationsystem.model.reference.properties.Encrypted;
|
||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
|
||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.AddConstraint;
|
||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.RemoveConstraint;
|
||||
import org.gcube.informationsystem.model.reference.properties.Vault;
|
||||
import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entities.resource.ResourceNotFoundException;
|
||||
import org.gcube.informationsystem.serialization.ElementMapper;
|
||||
|
@ -513,12 +514,12 @@ public class ERManagementTest extends ContextTest {
|
|||
String additionlaPropertyValue = "MyTest";
|
||||
accessPointFacet.setAdditionalProperty(additionlaPropertyKey, additionlaPropertyValue);
|
||||
|
||||
Encrypted encrypted = new EncryptedImpl();
|
||||
String plainValue = "Encrypted";
|
||||
String encryptedValue = EncryptedImpl.encrypt(plainValue);
|
||||
encrypted.setEncryptedValue(encryptedValue);
|
||||
Vault vault = new VaultImpl();
|
||||
String plainValue = "my plain value";
|
||||
String encryptedValue = StringEncrypter.getEncrypter().encrypt(plainValue);
|
||||
vault.setValue(encryptedValue);
|
||||
String encryptedKey = "Enc";
|
||||
accessPointFacet.setAdditionalProperty(encryptedKey, encrypted);
|
||||
accessPointFacet.setAdditionalProperty(encryptedKey, vault);
|
||||
|
||||
configuration.addFacet(accessPointFacet);
|
||||
|
||||
|
@ -530,11 +531,11 @@ public class ERManagementTest extends ContextTest {
|
|||
AccessPointFacet apf = configuration.getFacets(AccessPointFacet.class).get(0);
|
||||
|
||||
Assert.assertTrue(apf.getAuthorization() instanceof ValueSchema);
|
||||
Assert.assertTrue(apf.getAdditionalProperty(encryptedKey) instanceof Encrypted);
|
||||
Encrypted enc = (Encrypted) apf.getAdditionalProperty(encryptedKey);
|
||||
String encValue = enc.getEncryptedValue();
|
||||
Assert.assertTrue(apf.getAdditionalProperty(encryptedKey) instanceof Vault);
|
||||
Vault enc = (Vault) apf.getAdditionalProperty(encryptedKey);
|
||||
String encValue = enc.getValue();
|
||||
Assert.assertTrue(encValue.compareTo(encryptedValue) == 0);
|
||||
String decryptedValue = EncryptedImpl.decrypt(encValue);
|
||||
String decryptedValue = StringEncrypter.getEncrypter().decrypt(encValue);
|
||||
Assert.assertTrue(decryptedValue.compareTo(plainValue) == 0);
|
||||
Assert.assertTrue(((String) apf.getAdditionalProperty(additionlaPropertyKey)).compareTo(additionlaPropertyValue) == 0);
|
||||
|
||||
|
|
|
@ -12,16 +12,17 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.common.encryption.encrypter.StringEncrypter;
|
||||
import org.gcube.informationsystem.base.reference.Direction;
|
||||
import org.gcube.informationsystem.model.impl.properties.EncryptedImpl;
|
||||
import org.gcube.informationsystem.model.impl.properties.PropagationConstraintImpl;
|
||||
import org.gcube.informationsystem.model.impl.properties.VaultImpl;
|
||||
import org.gcube.informationsystem.model.impl.relations.ConsistsOfImpl;
|
||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||
import org.gcube.informationsystem.model.reference.properties.Encrypted;
|
||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
|
||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.AddConstraint;
|
||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.RemoveConstraint;
|
||||
import org.gcube.informationsystem.model.reference.properties.Vault;
|
||||
import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
|
||||
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
|
||||
import org.gcube.informationsystem.model.reference.relations.Relation;
|
||||
|
@ -90,8 +91,8 @@ public class ERManagementTest extends ContextTest {
|
|||
AccessPointFacet accessPointFacet = new AccessPointFacetImpl();
|
||||
URL endpoint = new URL("https://d4science.org:443");
|
||||
accessPointFacet.setEndpoint(endpoint.toURI());
|
||||
Encrypted encrypted = new EncryptedImpl();
|
||||
encrypted.setEncryptedValue(EncryptedImpl.encrypt("1"));
|
||||
Vault encrypted = new VaultImpl();
|
||||
encrypted.setValue(StringEncrypter.getEncrypter().encrypt("1"));
|
||||
accessPointFacet.setAdditionalProperty(PASSWORD, encrypted);
|
||||
eService.addFacet(accessPointFacet);
|
||||
|
||||
|
@ -119,8 +120,8 @@ public class ERManagementTest extends ContextTest {
|
|||
UUID receivedFacetUUID = receivedFacet.getHeader().getUUID();
|
||||
Assert.assertTrue(facetUUID.compareTo(receivedFacetUUID)==0);
|
||||
|
||||
Encrypted receivedEncrypted = (Encrypted) receivedFacet.getAdditionalProperty(PASSWORD);
|
||||
Assert.assertTrue(encrypted.getEncryptedValue().compareTo(receivedEncrypted.getEncryptedValue())==0);
|
||||
Vault receivedEncrypted = (Vault) receivedFacet.getAdditionalProperty(PASSWORD);
|
||||
Assert.assertTrue(encrypted.getValue().compareTo(receivedEncrypted.getValue())==0);
|
||||
} catch(ResourceRegistryException e) {
|
||||
logger.error("", e);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue