Search in sources :

Example 1 with Encryption

use of com.microsoft.azure.management.compute.Encryption in project cloudbreak by hortonworks.

the class AzureClient method setupDiskEncryptionWithDesIfNeeded.

@VisibleForTesting
void setupDiskEncryptionWithDesIfNeeded(String diskEncryptionSetId, Disk.DefinitionStages.WithCreate withCreate) {
    if (!Strings.isNullOrEmpty(diskEncryptionSetId)) {
        // This is nasty. The DES setter is not exposed in WithCreate, so have to rely on the direct tweaking of the underlying DiskInner.
        Encryption encryption = new Encryption();
        encryption.withDiskEncryptionSetId(diskEncryptionSetId);
        // WithCreate is actually a DiskImpl instance, but that type is not visible.
        DiskInner inner = (DiskInner) ((IndexableRefreshableWrapperImpl) withCreate).inner();
        inner.withEncryption(encryption);
    }
}
Also used : Encryption(com.microsoft.azure.management.compute.Encryption) DiskInner(com.microsoft.azure.management.compute.implementation.DiskInner) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 2 with Encryption

use of com.microsoft.azure.management.compute.Encryption in project cloudbreak by hortonworks.

the class AzureClientTest method setupDiskEncryptionWithDesIfNeededTestWhenDesGiven.

@Test
void setupDiskEncryptionWithDesIfNeededTestWhenDesGiven() {
    when(withCreateIndexableRefreshableWrapperImpl.inner()).thenReturn(diskInner);
    underTest.setupDiskEncryptionWithDesIfNeeded(DISK_ENCRYPTION_SET_ID, (Disk.DefinitionStages.WithCreate) withCreateIndexableRefreshableWrapperImpl);
    verify(diskInner).withEncryption(encryptionCaptor.capture());
    Encryption encryption = encryptionCaptor.getValue();
    assertThat(encryption).isNotNull();
    assertThat(encryption.diskEncryptionSetId()).isEqualTo(DISK_ENCRYPTION_SET_ID);
}
Also used : Encryption(com.microsoft.azure.management.compute.Encryption) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Encryption (com.microsoft.azure.management.compute.Encryption)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 DiskInner (com.microsoft.azure.management.compute.implementation.DiskInner)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1