use of org.cloudfoundry.credhub.entity.JsonCredentialVersionData in project credhub by cloudfoundry-incubator.
the class JsonCredentialVersionTest method beforeEach.
@Before
public void beforeEach() throws JsonProcessingException {
Map<String, Object> nested = new HashMap<>();
nested.put("key", "value");
value = new HashMap<>();
value.put("simple", "just-a-string");
value.put("complex", nested);
String serializedValue = new ObjectMapper().writeValueAsString(value);
Encryptor encryptor = mock(Encryptor.class);
byte[] encryptedValue = "fake-encrypted-value".getBytes();
byte[] nonce = "fake-nonce".getBytes();
UUID canaryUuid = UUID.randomUUID();
final EncryptedValue encryption = new EncryptedValue(canaryUuid, encryptedValue, nonce);
when(encryptor.encrypt(serializedValue)).thenReturn(encryption);
when(encryptor.decrypt(encryption)).thenReturn(serializedValue);
jsonCredentialData = new JsonCredentialVersionData("Foo");
subject = new JsonCredentialVersion(jsonCredentialData).setEncryptor(encryptor);
}
Aggregations