Issue 783:HTTP Accept header field contains invalid type (*)

This commit is contained in:
Adrian Cole 2011-12-19 22:57:52 -08:00
parent 094cfd563e
commit 8148151b85
2 changed files with 17 additions and 9 deletions

View File

@ -108,6 +108,7 @@ public interface NovaAsyncClient {
@POST @POST
@QueryParams(keys = "format", values = "json") @QueryParams(keys = "format", values = "json")
@Path("/servers/{id}/action") @Path("/servers/{id}/action")
@Consumes
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Payload("%7B\"reboot\":%7B\"type\":\"{type}\"%7D%7D") @Payload("%7B\"reboot\":%7B\"type\":\"{type}\"%7D%7D")
ListenableFuture<Void> rebootServer(@PathParam("id") int id, @PayloadParam("type") RebootType rebootType); ListenableFuture<Void> rebootServer(@PathParam("id") int id, @PayloadParam("type") RebootType rebootType);
@ -118,6 +119,7 @@ public interface NovaAsyncClient {
@POST @POST
@QueryParams(keys = "format", values = "json") @QueryParams(keys = "format", values = "json")
@Path("/servers/{id}/action") @Path("/servers/{id}/action")
@Consumes
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Payload("%7B\"resize\":%7B\"flavorId\":{flavorId}%7D%7D") @Payload("%7B\"resize\":%7B\"flavorId\":{flavorId}%7D%7D")
ListenableFuture<Void> resizeServer(@PathParam("id") int id, @PayloadParam("flavorId") int flavorId); ListenableFuture<Void> resizeServer(@PathParam("id") int id, @PayloadParam("flavorId") int flavorId);
@ -128,6 +130,7 @@ public interface NovaAsyncClient {
@POST @POST
@QueryParams(keys = "format", values = "json") @QueryParams(keys = "format", values = "json")
@Path("/servers/{id}/action") @Path("/servers/{id}/action")
@Consumes
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Payload("{\"confirmResize\":null}") @Payload("{\"confirmResize\":null}")
ListenableFuture<Void> confirmResizeServer(@PathParam("id") int id); ListenableFuture<Void> confirmResizeServer(@PathParam("id") int id);
@ -138,6 +141,7 @@ public interface NovaAsyncClient {
@POST @POST
@QueryParams(keys = "format", values = "json") @QueryParams(keys = "format", values = "json")
@Path("/servers/{id}/action") @Path("/servers/{id}/action")
@Consumes
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Payload("{\"revertResize\":null}") @Payload("{\"revertResize\":null}")
ListenableFuture<Void> revertResizeServer(@PathParam("id") int id); ListenableFuture<Void> revertResizeServer(@PathParam("id") int id);
@ -160,6 +164,7 @@ public interface NovaAsyncClient {
@POST @POST
@QueryParams(keys = "format", values = "json") @QueryParams(keys = "format", values = "json")
@Path("/servers/{id}/action") @Path("/servers/{id}/action")
@Consumes
@MapBinder(RebuildServerOptions.class) @MapBinder(RebuildServerOptions.class)
ListenableFuture<Void> rebuildServer(@PathParam("id") int id, RebuildServerOptions... options); ListenableFuture<Void> rebuildServer(@PathParam("id") int id, RebuildServerOptions... options);
@ -169,6 +174,7 @@ public interface NovaAsyncClient {
*/ */
@POST @POST
@Path("/servers/{id}/action") @Path("/servers/{id}/action")
@Consumes
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Payload("%7B\"changePassword\":%7B\"adminPass\":\"{adminPass}\"%7D%7D") @Payload("%7B\"changePassword\":%7B\"adminPass\":\"{adminPass}\"%7D%7D")
ListenableFuture<Void> changeAdminPass(@PathParam("id") int id, @PayloadParam("adminPass") String adminPass); ListenableFuture<Void> changeAdminPass(@PathParam("id") int id, @PayloadParam("adminPass") String adminPass);
@ -178,6 +184,7 @@ public interface NovaAsyncClient {
*/ */
@PUT @PUT
@Path("/servers/{id}") @Path("/servers/{id}")
@Consumes
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Payload("%7B\"server\":%7B\"name\":\"{name}\"%7D%7D") @Payload("%7B\"server\":%7B\"name\":\"{name}\"%7D%7D")
ListenableFuture<Void> renameServer(@PathParam("id") int id, @PayloadParam("name") String newName); ListenableFuture<Void> renameServer(@PathParam("id") int id, @PayloadParam("name") String newName);
@ -253,6 +260,7 @@ public interface NovaAsyncClient {
*/ */
@DELETE @DELETE
@ExceptionParser(ReturnFalseOnNotFoundOr404.class) @ExceptionParser(ReturnFalseOnNotFoundOr404.class)
@Consumes
@Path("/images/{id}") @Path("/images/{id}")
ListenableFuture<Boolean> deleteImage(@PathParam("id") int id); ListenableFuture<Boolean> deleteImage(@PathParam("id") int id);

View File

@ -139,7 +139,7 @@ public class NovaAsyncClientTest extends RestClientTest<NovaAsyncClient> {
HttpRequest request = processor.createRequest(method, 2); HttpRequest request = processor.createRequest(method, 2);
assertRequestLineEquals(request, "DELETE http://endpoint/vapiversion/images/2 HTTP/1.1"); assertRequestLineEquals(request, "DELETE http://endpoint/vapiversion/images/2 HTTP/1.1");
assertNonPayloadHeadersEqual(request, ""); assertNonPayloadHeadersEqual(request, "Accept: */*\n");
assertPayloadEquals(request, null, null, false); assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class); assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class);
@ -446,7 +446,7 @@ public class NovaAsyncClientTest extends RestClientTest<NovaAsyncClient> {
HttpRequest request = processor.createRequest(method, 2, "foo"); HttpRequest request = processor.createRequest(method, 2, "foo");
assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/2/action HTTP/1.1"); assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/2/action HTTP/1.1");
assertNonPayloadHeadersEqual(request, ""); assertNonPayloadHeadersEqual(request, "Accept: */*\n");
assertPayloadEquals(request, "{\"changePassword\":{\"adminPass\":\"foo\"}}", MediaType.APPLICATION_JSON, false); assertPayloadEquals(request, "{\"changePassword\":{\"adminPass\":\"foo\"}}", MediaType.APPLICATION_JSON, false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -462,7 +462,7 @@ public class NovaAsyncClientTest extends RestClientTest<NovaAsyncClient> {
HttpRequest request = processor.createRequest(method, 2, "foo"); HttpRequest request = processor.createRequest(method, 2, "foo");
assertRequestLineEquals(request, "PUT http://endpoint/vapiversion/servers/2 HTTP/1.1"); assertRequestLineEquals(request, "PUT http://endpoint/vapiversion/servers/2 HTTP/1.1");
assertNonPayloadHeadersEqual(request, ""); assertNonPayloadHeadersEqual(request, "Accept: */*\n");
assertPayloadEquals(request, "{\"server\":{\"name\":\"foo\"}}", MediaType.APPLICATION_JSON, false); assertPayloadEquals(request, "{\"server\":{\"name\":\"foo\"}}", MediaType.APPLICATION_JSON, false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -547,7 +547,7 @@ public class NovaAsyncClientTest extends RestClientTest<NovaAsyncClient> {
HttpRequest request = processor.createRequest(method, 3); HttpRequest request = processor.createRequest(method, 3);
assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/3/action?format=json HTTP/1.1"); assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/3/action?format=json HTTP/1.1");
assertNonPayloadHeadersEqual(request, ""); assertNonPayloadHeadersEqual(request, "Accept: */*\n");
assertPayloadEquals(request, "{\"rebuild\":{}}", MediaType.APPLICATION_JSON, false); assertPayloadEquals(request, "{\"rebuild\":{}}", MediaType.APPLICATION_JSON, false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -564,7 +564,7 @@ public class NovaAsyncClientTest extends RestClientTest<NovaAsyncClient> {
HttpRequest request = processor.createRequest(method, 3, withImage("2")); HttpRequest request = processor.createRequest(method, 3, withImage("2"));
assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/3/action?format=json HTTP/1.1"); assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/3/action?format=json HTTP/1.1");
assertNonPayloadHeadersEqual(request, ""); assertNonPayloadHeadersEqual(request, "Accept: */*\n");
assertPayloadEquals(request, "{\"rebuild\":{\"imageRef\":\"2\"}}", MediaType.APPLICATION_JSON, false); assertPayloadEquals(request, "{\"rebuild\":{\"imageRef\":\"2\"}}", MediaType.APPLICATION_JSON, false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -580,7 +580,7 @@ public class NovaAsyncClientTest extends RestClientTest<NovaAsyncClient> {
HttpRequest request = processor.createRequest(method, 2, RebootType.HARD); HttpRequest request = processor.createRequest(method, 2, RebootType.HARD);
assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/2/action?format=json HTTP/1.1"); assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/2/action?format=json HTTP/1.1");
assertNonPayloadHeadersEqual(request, ""); assertNonPayloadHeadersEqual(request, "Accept: */*\n");
assertPayloadEquals(request, "{\"reboot\":{\"type\":\"HARD\"}}", MediaType.APPLICATION_JSON, false); assertPayloadEquals(request, "{\"reboot\":{\"type\":\"HARD\"}}", MediaType.APPLICATION_JSON, false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -596,7 +596,7 @@ public class NovaAsyncClientTest extends RestClientTest<NovaAsyncClient> {
HttpRequest request = processor.createRequest(method, 2, 3); HttpRequest request = processor.createRequest(method, 2, 3);
assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/2/action?format=json HTTP/1.1"); assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/2/action?format=json HTTP/1.1");
assertNonPayloadHeadersEqual(request, ""); assertNonPayloadHeadersEqual(request, "Accept: */*\n");
assertPayloadEquals(request, "{\"resize\":{\"flavorId\":3}}", MediaType.APPLICATION_JSON, false); assertPayloadEquals(request, "{\"resize\":{\"flavorId\":3}}", MediaType.APPLICATION_JSON, false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -612,7 +612,7 @@ public class NovaAsyncClientTest extends RestClientTest<NovaAsyncClient> {
HttpRequest request = processor.createRequest(method, 2); HttpRequest request = processor.createRequest(method, 2);
assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/2/action?format=json HTTP/1.1"); assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/2/action?format=json HTTP/1.1");
assertNonPayloadHeadersEqual(request, ""); assertNonPayloadHeadersEqual(request, "Accept: */*\n");
assertPayloadEquals(request, "{\"confirmResize\":null}", MediaType.APPLICATION_JSON, false); assertPayloadEquals(request, "{\"confirmResize\":null}", MediaType.APPLICATION_JSON, false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -627,7 +627,7 @@ public class NovaAsyncClientTest extends RestClientTest<NovaAsyncClient> {
HttpRequest request = processor.createRequest(method, 2); HttpRequest request = processor.createRequest(method, 2);
assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/2/action?format=json HTTP/1.1"); assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/2/action?format=json HTTP/1.1");
assertNonPayloadHeadersEqual(request, ""); assertNonPayloadHeadersEqual(request, "Accept: */*\n");
assertPayloadEquals(request, "{\"revertResize\":null}", MediaType.APPLICATION_JSON, false); assertPayloadEquals(request, "{\"revertResize\":null}", MediaType.APPLICATION_JSON, false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);