There is a security vulnerability in SSH key-generation using GitKraken < v8.0.1. If you used this tool to create SSH keys, please update GitKraken and regenerate. If you need help with this, contact forum-support@opengroup.org

Commit 272c3024 authored by Komal Makkar's avatar Komal Makkar
Browse files

Merge branch 'master' of...

Merge branch 'master' of https://community.opengroup.org/osdu/platform/system/lib/cloud/azure/os-core-lib-azure into users/komakkar/eventgridClient
parents e53e043e 5dd68db0
Pipeline #33328 failed with stage
in 2 minutes and 6 seconds
......@@ -200,6 +200,44 @@ public class BlobStore {
}
}
/**
* @param dataPartitionId Data partition id
* @param containerName Name of the storage container
* @return boolean indicating whether the creation of the given container was successful or not.
* Throws exception in case of failure.
*/
public boolean createBlobContainer(
final String dataPartitionId,
final String containerName) {
BlobServiceClient blobServiceClient = blobServiceClientFactory.getBlobServiceClient(dataPartitionId);
try {
blobServiceClient.createBlobContainer(containerName);
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).info("{}", MessageFormatter.format("Done creating container with name {}", containerName).getMessage());
return true;
} catch (BlobStorageException ex) {
throw handleBlobStoreException(500, "Failed to create blob container", ex);
}
}
/**
* @param dataPartitionId Data partition id
* @param containerName Name of the storage container
* @return boolean indicating whether the deletion of the given container was successful or not.
* Throws exception in case of failure.
*/
public boolean deleteBlobContainer(
final String dataPartitionId,
final String containerName) {
BlobServiceClient blobServiceClient = blobServiceClientFactory.getBlobServiceClient(dataPartitionId);
try {
blobServiceClient.deleteBlobContainer(containerName);
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).info("{}", MessageFormatter.format("Done deleting container with name {}", containerName).getMessage());
return true;
} catch (BlobStorageException ex) {
throw handleBlobStoreException(500, "Failed to delete blob container", ex);
}
}
/**
* @param dataPartitionId Data partition id
* @param filePath Path of file (blob) for which SAS token needs to be generated
......
......@@ -312,6 +312,58 @@ public class BlobStoreTest {
assertEquals(copyInfo, null);
}
@Test
public void createBlobContainer_Failure() {
BlobStorageException exception = mockStorageException(BlobErrorCode.INTERNAL_ERROR);
doThrow(exception).when(blobServiceClient).createBlobContainer(anyString());
String containerName = "containerName";
try {
blobStore.createBlobContainer(PARTITION_ID, containerName);
} catch (AppException ex) {
assertEquals(500, ex.getError().getCode());
} catch (Exception ex) {
fail("should not get different error code");
}
}
@Test
public void createBlobContainer_Success() {
String containerName = "containerName";
boolean status = blobStore.createBlobContainer(PARTITION_ID, containerName);
ArgumentCaptor<String> containerNameCaptor = ArgumentCaptor.forClass(String.class);
verify(blobServiceClient).createBlobContainer(containerNameCaptor.capture());
assertEquals(containerNameCaptor.getValue(), containerName);
assertEquals(status, true);
}
@Test
public void deleteBlobContainer_Failure() {
BlobStorageException exception = mockStorageException(BlobErrorCode.INTERNAL_ERROR);
doThrow(exception).when(blobServiceClient).deleteBlobContainer(anyString());
String containerName = "containerName";
try {
blobStore.deleteBlobContainer(PARTITION_ID, containerName);
} catch (AppException ex) {
assertEquals(500, ex.getError().getCode());
} catch (Exception ex) {
fail("should not get different error code");
}
}
@Test
public void deleteBlobContainer_Success() {
String containerName = "containerName";
boolean status = blobStore.deleteBlobContainer(PARTITION_ID, containerName);
ArgumentCaptor<String> containerNameCaptor = ArgumentCaptor.forClass(String.class);
verify(blobServiceClient).deleteBlobContainer(containerNameCaptor.capture());
assertEquals(containerNameCaptor.getValue(), containerName);
assertEquals(status, true);
}
@Test
public void getSasToken_NullSasTokenObtained() {
int expiryDays = 1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment