use of com.google.cloud.bigtable.admin.v2.models.EncryptionInfo in project java-bigtable by googleapis.
the class BigtableCmekIT method tableTest.
@Test
public void tableTest() throws Exception {
// Confirm that table is CMEK-protected
if (testEnvRule.env().shouldWaitForCmekKeyStatusUpdate()) {
waitForCmekStatus(TEST_TABLE_ID, clusterId1);
}
Map<String, List<EncryptionInfo>> encryptionInfos = tableAdmin.getEncryptionInfo(TEST_TABLE_ID);
assertThat(encryptionInfos).hasSize(1);
assertThat(encryptionInfos.get(clusterId1)).hasSize(1);
EncryptionInfo encryptionInfo = encryptionInfos.get(clusterId1).get(0);
assertThat(encryptionInfo.getType()).isEqualTo(EncryptionInfo.Type.CUSTOMER_MANAGED_ENCRYPTION);
assertThat(encryptionInfo.getStatus().getCode()).isAnyOf(Status.Code.OK, Status.Code.UNKNOWN);
if (testEnvRule.env().shouldWaitForCmekKeyStatusUpdate()) {
assertThat(encryptionInfo.getStatus().getCode()).isEqualTo(Status.Code.OK);
}
// in order to poll until the final state can be asserted.
if (encryptionInfo.getStatus().getCode() == Code.UNKNOWN) {
assertThat(encryptionInfo.getKmsKeyVersion()).isEmpty();
assertThat(encryptionInfo.getStatus().getMessage()).isEqualTo("Key version is not yet known.");
} else {
assertThat(encryptionInfo.getKmsKeyVersion()).startsWith(kmsKeyName);
assertThat(encryptionInfo.getStatus().getMessage()).isEqualTo("");
}
}
Aggregations