mirror of https://github.com/apache/jclouds.git
Issue 695: Converted deleteSSHKey to return boolean instead of void when 2xx return code
This commit is contained in:
parent
e71728d82c
commit
831e35ecbc
|
@ -21,8 +21,8 @@ package org.jclouds.tmrk.enterprisecloud.features;
|
|||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import org.jclouds.http.filters.BasicAuthentication;
|
||||
import org.jclouds.rest.annotations.*;
|
||||
import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||
import org.jclouds.tmrk.enterprisecloud.binders.BindCreateSSHKeyToXmlPayload;
|
||||
import org.jclouds.tmrk.enterprisecloud.binders.BindSSHKeyToXmlPayload;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.keys.SSHKey;
|
||||
|
@ -87,11 +87,10 @@ public interface SSHKeyAsyncClient {
|
|||
|
||||
/**
|
||||
* @see SSHKeyClient#createSSHKey
|
||||
* TODO Should map the 204 header to a boolean to indicate that it was sucessful
|
||||
*/
|
||||
@DELETE
|
||||
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
||||
public ListenableFuture<Void> deleteSSHKey(@EndpointParam URI uri);
|
||||
@ExceptionParser(ReturnFalseOnNotFoundOr404.class)
|
||||
public ListenableFuture<Boolean> deleteSSHKey(@EndpointParam URI uri);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -94,6 +94,6 @@ public interface SSHKeyClient {
|
|||
* @param uri the uri of the ssk key to delete
|
||||
* e.g. /cloudapi/ecloud/admin/sshkeys/77
|
||||
*/
|
||||
public void deleteSSHKey(URI uri);
|
||||
public boolean deleteSSHKey(URI uri);
|
||||
|
||||
}
|
||||
|
|
|
@ -21,9 +21,9 @@ package org.jclouds.tmrk.enterprisecloud.features;
|
|||
import com.google.inject.TypeLiteral;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.functions.ParseXMLWithJAXB;
|
||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||
import org.jclouds.http.functions.ReturnTrueIf2xx;
|
||||
import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.keys.SSHKey;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -116,8 +116,8 @@ public class SSHKeyAsyncClientTest extends BaseTerremarkEnterpriseCloudAsyncClie
|
|||
assertNonPayloadHeadersEqual(httpRequest,"x-tmrk-version: 2011-07-01\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
|
||||
assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class);
|
||||
assertResponseParserClassEquals(method, httpRequest, ReturnTrueIf2xx.class);
|
||||
assertExceptionParserClassEquals(method, ReturnFalseOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public class SSHKeyClientLiveTest extends BaseTerremarkEnterpriseCloudClientLive
|
|||
assertFalse(sshKey.isDefaultKey());
|
||||
assertFalse(sshKey.getFingerPrint().isEmpty());
|
||||
assertFalse(sshKey.getPrivateKey().isEmpty());
|
||||
client.deleteSSHKey(sshKey.getHref());
|
||||
assertTrue(client.deleteSSHKey(sshKey.getHref()));
|
||||
assertNull(client.getSSHKey(sshKey.getHref()));
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,11 @@ public class SSHKeyClientLiveTest extends BaseTerremarkEnterpriseCloudClientLive
|
|||
SSHKey result = client.getSSHKey(sshKey.getHref());
|
||||
assertEquals(result.getName(),"editedname");
|
||||
|
||||
client.deleteSSHKey(sshKey.getHref());
|
||||
assertTrue(client.deleteSSHKey(sshKey.getHref()));
|
||||
assertNull(client.getSSHKey(sshKey.getHref()));
|
||||
}
|
||||
|
||||
public void testDeleteWhenNoKey() {
|
||||
assertFalse(client.deleteSSHKey(URI.create("/cloudapi/ecloud/admin/sshkeys/-1")));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue