Skip to content

Commit

Permalink
storage: fix integration (#3297)
Browse files Browse the repository at this point in the history
Do not pollute main test bucket with default kms key
  • Loading branch information
frankyn authored and pongad committed May 22, 2018
1 parent 754b1fc commit d3fe98c
Showing 1 changed file with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1860,25 +1860,30 @@ public void testListBucketRequesterPaysFails() throws InterruptedException {
}

@Test
public void testListBucketDefaultKmsKeyName() throws InterruptedException {
Bucket remoteBucket = storage.get(BUCKET, Storage.BucketGetOption.fields(BucketField.ENCRYPTION));
assertNull(remoteBucket.getDefaultKmsKeyName());
remoteBucket = remoteBucket.toBuilder().setDefaultKmsKeyName(KMS_KEY_NAME_1).build().update();
public void testListBucketDefaultKmsKeyName() throws ExecutionException, InterruptedException {
String bucketName = RemoteStorageHelper.generateBucketName();
Bucket remoteBucket = storage.create(BucketInfo.newBuilder(bucketName)
.setDefaultKmsKeyName(KMS_KEY_NAME_1).setLocation("US").build());
assertNotNull(remoteBucket);
assertTrue(remoteBucket.getDefaultKmsKeyName().startsWith(KMS_KEY_NAME_1));
Iterator<Bucket> bucketIterator = storage.list(Storage.BucketListOption.prefix(BUCKET),
Storage.BucketListOption.fields(BucketField.ENCRYPTION)).iterateAll().iterator();
while (!bucketIterator.hasNext()) {
Thread.sleep(500);
bucketIterator = storage.list(Storage.BucketListOption.prefix(BUCKET),
try {
Iterator<Bucket> bucketIterator = storage.list(Storage.BucketListOption.prefix(bucketName),
Storage.BucketListOption.fields(BucketField.ENCRYPTION)).iterateAll().iterator();
}
while (bucketIterator.hasNext()) {
Bucket bucket = bucketIterator.next();
assertTrue(bucket.getName().startsWith(BUCKET));
assertNotNull(bucket.getDefaultKmsKeyName());
assertTrue(bucket.getDefaultKmsKeyName().startsWith(KMS_KEY_NAME_1));
assertNull(bucket.getCreateTime());
assertNull(bucket.getSelfLink());
while (!bucketIterator.hasNext()) {
Thread.sleep(500);
bucketIterator = storage.list(Storage.BucketListOption.prefix(bucketName),
Storage.BucketListOption.fields(BucketField.ENCRYPTION)).iterateAll().iterator();
}
while (bucketIterator.hasNext()) {
Bucket bucket = bucketIterator.next();
assertTrue(bucket.getName().startsWith(bucketName));
assertNotNull(bucket.getDefaultKmsKeyName());
assertTrue(bucket.getDefaultKmsKeyName().startsWith(KMS_KEY_NAME_1));
assertNull(bucket.getCreateTime());
assertNull(bucket.getSelfLink());
}
} finally {
RemoteStorageHelper.forceDelete(storage, bucketName, 5, TimeUnit.SECONDS);
}
}

Expand Down

0 comments on commit d3fe98c

Please sign in to comment.