usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [1/2] git commit: Fix /management/me end-point so that it correctly accepts POST of form-encoded data.
Date Fri, 17 Jan 2014 19:20:41 GMT
Updated Branches:
  refs/heads/master 52172132b -> 1150e47da


Fix /management/me end-point so that it correctly accepts POST of form-encoded data.


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/0c19ebd9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/0c19ebd9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/0c19ebd9

Branch: refs/heads/master
Commit: 0c19ebd98b0af07ff773405f6ea2c04927199d8c
Parents: e2ee790
Author: Dave Johnson <dmjohnson@apigee.com>
Authored: Fri Jan 17 13:42:20 2014 -0500
Committer: Dave Johnson <dmjohnson@apigee.com>
Committed: Fri Jan 17 13:42:20 2014 -0500

----------------------------------------------------------------------
 .../rest/management/ManagementResource.java         | 16 ++++++++--------
 .../rest/management/ManagementResourceIT.java       | 13 ++++++++++---
 2 files changed, 18 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0c19ebd9/stack/rest/src/main/java/org/usergrid/rest/management/ManagementResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/usergrid/rest/management/ManagementResource.java
b/stack/rest/src/main/java/org/usergrid/rest/management/ManagementResource.java
index e75bd2f..34b7639 100644
--- a/stack/rest/src/main/java/org/usergrid/rest/management/ManagementResource.java
+++ b/stack/rest/src/main/java/org/usergrid/rest/management/ManagementResource.java
@@ -299,14 +299,14 @@ public class ManagementResource extends AbstractContextResource {
     @Path( "me" )
     @Consumes( APPLICATION_FORM_URLENCODED )
     public Response getAccessTokenLightPost( @Context UriInfo ui, @HeaderParam( "Authorization"
) String authorization,
-                                             @QueryParam( "grant_type" ) String grant_type,
-                                             @QueryParam( "username" ) String username,
-                                             @QueryParam( "password" ) String password,
-                                             @QueryParam( "client_id" ) String client_id,
-                                             @QueryParam( "client_secret" ) String client_secret,
-                                             @QueryParam( "ttl" ) long ttl,
-                                             @QueryParam( "access_token" ) String access_token,
-                                             @QueryParam( "callback" ) @DefaultValue( ""
) String callback )
+                                             @FormParam( "grant_type" ) String grant_type,
+                                             @FormParam( "username" ) String username,
+                                             @FormParam( "password" ) String password,
+                                             @FormParam( "client_id" ) String client_id,
+                                             @FormParam( "client_secret" ) String client_secret,
+                                             @FormParam( "ttl" ) long ttl,
+                                             @FormParam( "access_token" ) String access_token,
+                                             @FormParam( "callback" ) @DefaultValue( "" )
String callback )
             throws Exception {
         return getAccessTokenInternal( ui, authorization, grant_type, username, password,
client_id, client_secret, ttl,
                 callback, false );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0c19ebd9/stack/rest/src/test/java/org/usergrid/rest/management/ManagementResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/usergrid/rest/management/ManagementResourceIT.java
b/stack/rest/src/test/java/org/usergrid/rest/management/ManagementResourceIT.java
index 1ea108b..9a7b873 100644
--- a/stack/rest/src/test/java/org/usergrid/rest/management/ManagementResourceIT.java
+++ b/stack/rest/src/test/java/org/usergrid/rest/management/ManagementResourceIT.java
@@ -33,6 +33,7 @@ import org.apache.commons.lang.StringUtils;
 
 import com.sun.jersey.api.client.ClientResponse.Status;
 import com.sun.jersey.api.client.UniformInterfaceException;
+import com.sun.jersey.api.representation.Form;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -370,10 +371,16 @@ public class ManagementResourceIT extends AbstractRestIT {
 
 
     @Test
-    public void meTokenPostForm() throws Exception {
-        JsonNode node = resource().path( "/management/me" ).queryParam( "grant_type", "password"
)
-                .queryParam( "username", "test@usergrid.com" ).queryParam( "password", "test"
)
+    public void meTokenPostForm() {
+
+        Form form = new Form();
+        form.add( "grant_type", "password" );
+        form.add( "username", "test@usergrid.com" );
+        form.add( "password", "test");
+
+        JsonNode node = resource().path( "/management/me" )
                 .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_FORM_URLENCODED_TYPE
)
+                .entity( form, MediaType.APPLICATION_FORM_URLENCODED_TYPE )
                 .post( JsonNode.class );
 
         logNode( node );


Mime
View raw message