usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [5/8] incubator-usergrid git commit: Fixes to no Admin User signup when ext. tokens enabled test.
Date Mon, 20 Apr 2015 16:18:12 GMT
Fixes to no Admin User signup when ext. tokens enabled test.


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

Branch: refs/heads/master
Commit: 8aff671853b7df41d2338b5617defdd99ffa08f1
Parents: c3e8782
Author: Dave Johnson <dmjohnson@apigee.com>
Authored: Mon Apr 20 09:45:11 2015 -0400
Committer: Dave Johnson <dmjohnson@apigee.com>
Committed: Mon Apr 20 09:45:11 2015 -0400

----------------------------------------------------------------------
 .../rest/management/users/MUUserResourceIT.java | 41 ++++++++++----------
 1 file changed, 20 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8aff6718/stack/rest/src/test/java/org/apache/usergrid/rest/management/users/MUUserResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/users/MUUserResourceIT.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/management/users/MUUserResourceIT.java
index 65d6d50..a1e31c4 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/users/MUUserResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/users/MUUserResourceIT.java
@@ -29,7 +29,9 @@ import javax.ws.rs.DefaultValue;
 import javax.ws.rs.FormParam;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
 
+import com.sun.jersey.core.util.MultivaluedMapImpl;
 import org.apache.commons.lang.RandomStringUtils;
 import org.codehaus.jackson.JsonNode;
 import org.jclouds.json.Json;
@@ -631,26 +633,25 @@ public class MUUserResourceIT extends AbstractRestIT {
             // create an admin user
 
             final String rand = RandomStringUtils.randomAlphanumeric( 10 );
-            Map<String, String> payload = new HashMap<String, String>() {{
-                put( "username", "user_" + rand );
-                put( "name", "Joe Userperson" );
-                put( "email", "joe_" + rand + "@example.com" );
-                put( "password", "wigglestone" );
+            MultivaluedMap<String, String> payload = new MultivaluedMapImpl() {{
+                putSingle( "username", "user_" + rand );
+                putSingle( "name", "Joe Userperson" );
+                putSingle( "email", "joe_" + rand + "@example.com" );
+                putSingle( "password", "wigglestone" );
             }};
             JsonNode node = resource().path( "/management/users")
                     .accept( MediaType.APPLICATION_JSON )
-                    .type( MediaType.APPLICATION_JSON )
+                    .type( MediaType.APPLICATION_FORM_URLENCODED )
                     .post( JsonNode.class, payload );
 
             fail( "Create admin user should fail" );
 
-        } catch ( UniformInterfaceException actual ) {
-            assertEquals( 400, actual.getResponse().getStatus() );
-            String errorMsg = actual.getResponse().getEntity( JsonNode.class ).get( "error_description"
).toString();
-            assertTrue( errorMsg.startsWith( "Admin Users must signup via http://localhost:"
) );
-
-        } catch ( Exception e ) {
-            fail("We expected a UniformInterfaceException");
+        } catch ( Exception actual ) {
+            assertTrue( actual instanceof UniformInterfaceException );
+            UniformInterfaceException uie = (UniformInterfaceException)actual;
+            assertEquals( 400, uie.getResponse().getStatus() );
+            String errorMsg = uie.getResponse().getEntity( JsonNode.class ).get( "error_description"
).toString();
+            assertTrue( errorMsg.contains( "Admin Users must signup via" ) );
         }
 
 
@@ -673,16 +674,14 @@ public class MUUserResourceIT extends AbstractRestIT {
 
             fail( "Create org and admin user should fail" );
 
-        } catch ( UniformInterfaceException actual ) {
-            assertEquals( 400, actual.getResponse().getStatus() );
-            assertTrue( actual.getResponse().getEntity( JsonNode.class ).get( "error_description"
)
-                    .toString().startsWith( "Organization / Admin Users must be created via
http://localhost:" ));
-
-        } catch ( Exception e ) {
-            fail("We expected a UniformInterfaceException");
+        } catch ( Exception actual ) {
+            assertTrue( actual instanceof UniformInterfaceException );
+            UniformInterfaceException uie = (UniformInterfaceException)actual;
+            assertEquals( 400, uie.getResponse().getStatus() );
+            String errorMsg = uie.getResponse().getEntity( JsonNode.class ).get( "error_description"
).toString();
+            assertTrue( errorMsg.contains( "Organization / Admin Users must be created via"
) );
         }
 
-
         // turn off validate external tokens by un-setting the usergrid.central.url
 
         props.put( USERGRID_CENTRAL_URL, "" );


Mime
View raw message