use of com.google.api.services.compute.model.CustomerEncryptionKey in project cloudbreak by hortonworks.
the class GcpAttachedDiskResourceBuilderTest method testBuildWithDiskEncryption.
@Test
void testBuildWithDiskEncryption() throws Exception {
CustomerEncryptionKey encryptionKey = new CustomerEncryptionKey();
encryptionKey.setRawKey("rawKey==");
ArgumentCaptor<Disk> diskCaptor = ArgumentCaptor.forClass(Disk.class);
doAnswer(invocation -> {
Disk disk = invocation.getArgument(1);
disk.setDiskEncryptionKey(encryptionKey);
return invocation;
}).when(customGcpDiskEncryptionService).addEncryptionKeyToDisk(any(InstanceTemplate.class), diskCaptor.capture());
List<CloudResource> build = underTest.build(context, cloudInstance, privateId, auth, group, buildableResource, cloudStack);
assertNotNull(build);
assertEquals(1, build.size());
CloudResource resource = build.iterator().next();
assertEquals(ResourceType.GCP_DISK, resource.getType());
assertEquals(CommonStatus.CREATED, resource.getStatus());
assertEquals("disk", resource.getName());
assertNotNull(diskCaptor.getValue());
assertEquals(encryptionKey, diskCaptor.getValue().getDiskEncryptionKey());
}
use of com.google.api.services.compute.model.CustomerEncryptionKey in project cloudbreak by hortonworks.
the class GcpInstanceResourceBuilderTest method testStartWithEmptyMethodRsaEncryptedKey.
@Test
public void testStartWithEmptyMethodRsaEncryptedKey() throws Exception {
CustomerEncryptionKey customerEncryptionKey = new CustomerEncryptionKey();
customerEncryptionKey.setRawKey("HelloWorld==");
Map<String, Object> params = Map.of(InstanceTemplate.VOLUME_ENCRYPTION_KEY_TYPE, EncryptionType.CUSTOM.name(), InstanceTemplate.VOLUME_ENCRYPTION_KEY_ID, "Hello World");
doTestCustomEncryption(params, customerEncryptionKey);
}
use of com.google.api.services.compute.model.CustomerEncryptionKey in project cloudbreak by hortonworks.
the class CustomGcpDiskEncryptionCreatorService method rawKey.
private CustomerEncryptionKey rawKey(String encryptionKey) {
CustomerEncryptionKey customerEncryptionKey = new CustomerEncryptionKey();
customerEncryptionKey.setRawKey(encode(getEncryptionKeyBytes(encryptionKey)));
return customerEncryptionKey;
}
use of com.google.api.services.compute.model.CustomerEncryptionKey in project cloudbreak by hortonworks.
the class CustomGcpDiskEncryptionCreatorService method rsaEncryptedKey.
private CustomerEncryptionKey rsaEncryptedKey(String encryptionKey) {
String pemPublicKey = getGooglePublicKey();
PublicKey publicKey = readPublicKeyFromCertificate(pemPublicKey.getBytes(StandardCharsets.UTF_8));
byte[] rsaWrapped = encrypt(publicKey, getEncryptionKeyBytes(encryptionKey));
CustomerEncryptionKey customerEncryptionKey = new CustomerEncryptionKey();
customerEncryptionKey.setSha256(encode(rsaWrapped));
return customerEncryptionKey;
}
use of com.google.api.services.compute.model.CustomerEncryptionKey in project cloudbreak by hortonworks.
the class CustomGcpDiskEncryptionCreatorService method kmsKey.
private CustomerEncryptionKey kmsKey(String kmsKeyPath) {
CustomerEncryptionKey customerEncryptionKey = new CustomerEncryptionKey();
customerEncryptionKey.setKmsKeyName(kmsKeyPath);
return customerEncryptionKey;
}
Aggregations