use of com.github.tomakehurst.wiremock.client.BasicCredentials in project cloudstack by apache.
the class ScaleIOGatewayClientImplTest method testCreateSingleVolume.
@Test
public void testCreateSingleVolume() {
Assert.assertNotNull(client);
wireMockRule.verify(getRequestedFor(urlEqualTo("/api/login")).withBasicAuth(new BasicCredentials(username, password)));
final String volumeName = "testvolume";
final String scaleIOStoragePoolId = "4daaa55e00000000";
final int sizeInGb = 8;
Volume scaleIOVolume = client.createVolume(volumeName, scaleIOStoragePoolId, sizeInGb, Storage.ProvisioningType.THIN);
wireMockRule.verify(postRequestedFor(urlEqualTo("/api/types/Volume/instances")).withBasicAuth(new BasicCredentials(username, sessionKey)).withRequestBody(containing("\"name\":\"" + volumeName + "\"")).withHeader("Content-Type", equalTo("application/json")));
wireMockRule.verify(getRequestedFor(urlEqualTo("/api/instances/Volume::c948d0b10000000a")).withBasicAuth(new BasicCredentials(username, sessionKey)));
Assert.assertNotNull(scaleIOVolume);
Assert.assertEquals(scaleIOVolume.getId(), "c948d0b10000000a");
Assert.assertEquals(scaleIOVolume.getName(), volumeName);
Assert.assertEquals(scaleIOVolume.getStoragePoolId(), scaleIOStoragePoolId);
Assert.assertEquals(scaleIOVolume.getSizeInKb(), Long.valueOf(sizeInGb * 1024 * 1024));
Assert.assertEquals(scaleIOVolume.getVolumeType(), Volume.VolumeType.ThinProvisioned);
}
use of com.github.tomakehurst.wiremock.client.BasicCredentials in project cloudstack by apache.
the class ScaleIOGatewayClientImplTest method testCreateMultipleVolumes.
@Test
public void testCreateMultipleVolumes() {
Assert.assertNotNull(client);
wireMockRule.verify(getRequestedFor(urlEqualTo("/api/login")).withBasicAuth(new BasicCredentials(username, password)));
final String volumeNamePrefix = "testvolume_";
final String scaleIOStoragePoolId = "4daaa55e00000000";
final int sizeInGb = 8;
final int volumesCount = 1000;
for (int i = 1; i <= volumesCount; i++) {
String volumeName = volumeNamePrefix + i;
Volume scaleIOVolume = client.createVolume(volumeName, scaleIOStoragePoolId, sizeInGb, Storage.ProvisioningType.THIN);
Assert.assertNotNull(scaleIOVolume);
Assert.assertEquals(scaleIOVolume.getId(), "c948d0b10000000a");
Assert.assertEquals(scaleIOVolume.getStoragePoolId(), scaleIOStoragePoolId);
Assert.assertEquals(scaleIOVolume.getSizeInKb(), Long.valueOf(sizeInGb * 1024 * 1024));
Assert.assertEquals(scaleIOVolume.getVolumeType(), Volume.VolumeType.ThinProvisioned);
}
wireMockRule.verify(volumesCount, postRequestedFor(urlEqualTo("/api/types/Volume/instances")).withBasicAuth(new BasicCredentials(username, sessionKey)).withRequestBody(containing("\"name\":\"" + volumeNamePrefix)).withHeader("Content-Type", equalTo("application/json")));
wireMockRule.verify(volumesCount, getRequestedFor(urlEqualTo("/api/instances/Volume::c948d0b10000000a")).withBasicAuth(new BasicCredentials(username, sessionKey)));
}
Aggregations