usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject [05/19] incubator-usergrid git commit: ManagermentResource
Date Tue, 02 Jun 2015 21:17:21 GMT
ManagermentResource


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

Branch: refs/heads/USERGRID-685
Commit: 8e73aee5e5080d08d14f5e30232366d790fdb594
Parents: 42f45ef
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Mon Jun 1 16:47:37 2015 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Mon Jun 1 16:47:37 2015 -0600

----------------------------------------------------------------------
 .../rest/management/ManagementResourceIT.java   | 54 +++++++++-----------
 .../endpoints/mgmt/MeResource.java              |  4 ++
 2 files changed, 27 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8e73aee5/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
index 006b99c..d04ce36 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
@@ -65,16 +65,12 @@ public class ManagementResourceIT extends AbstractRestIT {
      */
     @Test
     public void setSelfAdminPasswordAsAdmin() {
-
-        management.token().setToken(this.getAdminToken());
-
-
-        management.users().post(User.class,new User("test","test","test@email.com","test"));
-
+        UUID uuid =  UUIDUtils.newTimeUUID();
+        management.token().setToken(clientSetup.getSuperuserToken());
+        management.users().post(User.class, new User("test"+uuid, "test"+uuid, "test"+uuid+"@email.com",
"test"));
         Map<String, Object> data = new HashMap<>();
         data.put( "newpassword", "foo" );
         data.put( "oldpassword", "test" );
-
         management.users().user("test").password().post(Entity.class, data);
         data.clear();
         data.put( "oldpassword", "foo" );
@@ -202,9 +198,9 @@ public class ManagementResourceIT extends AbstractRestIT {
         userFeed = getUserFeed( lastUser );
         assertNotNull( userFeed );
         assertTrue( userFeed.size() > 1 );
-        String serialized = userFeed.toString();
-        assertTrue( serialized.indexOf( postFollowContent ) > 0 );
-        assertTrue( serialized.indexOf( preFollowContent ) > 0 );
+        String serialized = ((Entity)userFeed.get(0)).get("content").toString()+ ((Entity)userFeed.get(1)).get("content").toString();
+        assertTrue( serialized.indexOf( postFollowContent ) >= 0 );
+        assertTrue( serialized.indexOf( preFollowContent ) >= 0 );
     }
 
 
@@ -342,30 +338,28 @@ public class ManagementResourceIT extends AbstractRestIT {
     @Test
     public void meToken() throws Exception {
         QueryParameters queryParameters = new QueryParameters().addParam("grant_type", "password")
-                                  .addParam("username", "test@usergrid.com").addParam("password",
"test");
-        JsonNode node = management.me().post(JsonNode.class,queryParameters);
+                                  .addParam("username", clientSetup.getUsername()).addParam("password",clientSetup.getPassword());
+        Token myToken = management.me().get(Token.class,queryParameters);
 
 
-        logNode( node );
-        String token = node.get( "access_token" ).textValue();
+        String token = myToken.getAccessToken();
         assertNotNull( token );
 
-        node = management.me().get( JsonNode.class );
-        logNode( node );
+        Entity entity = management.me().get( Entity.class );
 
-        assertNotNull( node.get( "passwordChanged" ) );
-        assertNotNull( node.get( "access_token" ) );
-        assertNotNull( node.get( "expires_in" ) );
-        JsonNode userNode = node.get( "user" );
+        assertNotNull( entity.get( "passwordChanged" ) );
+        assertNotNull( entity.get( "access_token" ) );
+        assertNotNull( entity.get( "expires_in" ) );
+        Map<String,Object> userNode =(Map<String,Object>) entity.get( "user"
);
         assertNotNull( userNode );
         assertNotNull( userNode.get( "uuid" ) );
         assertNotNull( userNode.get( "username" ) );
         assertNotNull( userNode.get( "email" ) );
         assertNotNull( userNode.get( "name" ) );
         assertNotNull( userNode.get( "properties" ) );
-        JsonNode orgsNode = userNode.get( "organizations" );
+        Map<String,Object> orgsNode = (Map<String,Object>) userNode.get( "organizations"
);
         assertNotNull( orgsNode );
-        JsonNode orgNode = orgsNode.get( "test-organization" );
+        Map<String,Object> orgNode =(Map<String,Object>) orgsNode.entrySet().iterator().next().getValue();
         assertNotNull( orgNode );
         assertNotNull( orgNode.get( "name" ) );
         assertNotNull( orgNode.get( "properties" ) );
@@ -375,7 +369,7 @@ public class ManagementResourceIT extends AbstractRestIT {
     @Test
     public void meTokenPost() throws Exception {
         Map<String, String> payload =
-                hashMap( "grant_type", "password" ).map( "username", "test@usergrid.com"
).map( "password", "test" );
+                hashMap( "grant_type", "password" ).map( "username", clientSetup.getUsername()
).map( "password",clientSetup.getPassword() );
 
         JsonNode node = management.me().post(JsonNode.class, payload);
 
@@ -393,12 +387,10 @@ public class ManagementResourceIT extends AbstractRestIT {
 
         Form form = new Form();
         form.add( "grant_type", "password" );
-        form.add( "username", "test@usergrid.com" );
-        form.add( "password", "test" );
+        form.add( "username", clientSetup.getUsername() );
+        form.add( "password", clientSetup.getPassword() );
 
-        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 );
+        JsonNode node = management.me().post( JsonNode.class, form );
 
         logNode( node );
         String token = node.get( "access_token" ).textValue();
@@ -415,8 +407,8 @@ public class ManagementResourceIT extends AbstractRestIT {
     public void ttlNan() throws Exception {
 
         Map<String, String> payload =
-                hashMap( "grant_type", "password" ).map( "username", "test@usergrid.com"
).map( "password", "test" )
-                                                   .map( "ttl", "derp" );
+                hashMap( "grant_type", "password" ).map("username", clientSetup.getUsername()).map(
"password",clientSetup.getPassword() )
+                                                   .map("ttl", "derp");
 
         Status responseStatus = null;
         try {
@@ -434,7 +426,7 @@ public class ManagementResourceIT extends AbstractRestIT {
     public void ttlOverMax() throws Exception {
 
         Map<String, String> payload =
-                hashMap( "grant_type", "password" ).map( "username", "test@usergrid.com"
).map( "password", "test" )
+                hashMap( "grant_type", "password" ).map( "username", clientSetup.getUsername()).map(
"password", clientSetup.getPassword() )
                                                    .map( "ttl", Long.MAX_VALUE + "" );
 
         Status responseStatus = null;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8e73aee5/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/MeResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/MeResource.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/MeResource.java
index 1c7bf1b..4b3c042 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/MeResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/MeResource.java
@@ -29,4 +29,8 @@ public class MeResource extends NamedResource {
     public MeResource( final ClientContext context, final UrlResource parent ) {
         super( "me", context, parent );
     }
+
+    public TokenResource token(){
+        return new TokenResource(context,this);
+    }
 }


Mime
View raw message