usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [08/21] incubator-usergrid git commit: Added reactivate endpoint to users in rest test framework. Added test to prove that reactivate endpoint still works.
Date Tue, 03 Mar 2015 21:03:36 GMT
Added reactivate endpoint to users in rest test framework.
Added test to prove that reactivate endpoint still works.


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

Branch: refs/heads/USERGRID-422
Commit: 8585558f313d040c011d0e79ffb860f0254144ef
Parents: e5bd343
Author: grey <greyes@apigee.com>
Authored: Fri Feb 27 17:05:23 2015 -0800
Committer: grey <greyes@apigee.com>
Committed: Fri Feb 27 17:05:23 2015 -0800

----------------------------------------------------------------------
 .../usergrid/rest/management/AdminUsersIT.java  | 54 ++++++--------------
 .../rest/test/resource2point0/ClientSetup.java  |  2 +
 .../endpoints/mgmt/ReactivateResource.java      | 46 +++++++++++++++++
 .../endpoints/mgmt/UserResource.java            |  5 ++
 4 files changed, 69 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8585558f/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
index 74c5297..c5950f6 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
@@ -421,46 +421,24 @@ public class AdminUsersIT extends AbstractRestIT {
         return management().users().user( organization.getUsername() ).get();
 
     }
+
+
+    /**
+     * Check that we send the reactivate email after calling the reactivate endpoint.
+     * @throws Exception
+     */
+    @Test
+    public void reactivateTest() throws Exception {
+        //call reactivate endpoint on default user
+        clientSetup.getRestClient().management().users().user( clientSetup.getUsername()
).reactivate();
+        refreshIndex();
+
+        //Create mocked inbox
+        List<Message> inbox = Mailbox.get( clientSetup.getEmail());
+        assertFalse( inbox.isEmpty() );
+    }
     
 //
-//    @Test
-//    public void reactivateMultipleSend() throws Exception {
-//
-//        JsonNode node = mapper.readTree( resource().path( "/management/organizations" ).accept(
MediaType.APPLICATION_JSON )
-//                                                   .type( MediaType.APPLICATION_JSON_TYPE
).post( String.class, buildOrgUserPayload( "reactivate" ) ));
-//
-//        logNode( node );
-//        String email = node.get( "data" ).get( "owner" ).get( "email" ).asText();
-//        String uuid = node.get( "data" ).get( "owner" ).get( "uuid" ).asText();
-//        assertNotNull( email );
-//        assertEquals( "MUUserResourceIT-reactivate@apigee.com", email );
-//
-//        refreshIndex(context.getOrgName(), context.getAppName());
-//
-//        // reactivate should send activation email
-//
-//        node = mapper.readTree( resource().path( String.format( "/management/users/%s/reactivate",
uuid ) )
-//                                          .queryParam( "access_token", adminAccessToken
).accept( MediaType.APPLICATION_JSON )
-//                                          .type( MediaType.APPLICATION_JSON_TYPE ).get(
String.class ));
-//
-//        refreshIndex(context.getOrgName(), context.getAppName());
-//
-//        List<Message> inbox = org.jvnet.mock_javamail.Mailbox.get( email );
-//
-//        assertFalse( inbox.isEmpty() );
-//        logNode( node );
-//    }
-//
-//
-//    private Map<String, String> buildOrgUserPayload( String caller ) {
-//        String className = this.getClass().getSimpleName();
-//        Map<String, String> payload = hashMap( "email", String.format( "%s-%s@apigee.com",
className, caller ) )
-//                .map( "username", String.format( "%s-%s-user", className, caller ) )
-//                .map( "name", String.format( "%s %s", className, caller ) ).map( "password",
"password" )
-//                .map( "organization", String.format( "%s-%s-org", className, caller ) );
-//        return payload;
-//    }
-//
 //
 //    @Test
 //    public void checkPasswordReset() throws Exception {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8585558f/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java
index 55c10a3..63c420f 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java
@@ -108,6 +108,8 @@ public class ClientSetup implements TestRule {
 
     public String getUsername(){return username;}
 
+    public String getEmail(){return username+"@usergrid.com";}
+
     public String getPassword(){return password;}
 
     public Organization getOrganization(){return organization;}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8585558f/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ReactivateResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ReactivateResource.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ReactivateResource.java
new file mode 100644
index 0000000..25dc95e
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ReactivateResource.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt;
+
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.usergrid.rest.test.resource2point0.endpoints.NamedResource;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.UrlResource;
+import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
+import org.apache.usergrid.rest.test.resource2point0.model.Entity;
+import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
+
+import com.sun.jersey.api.client.WebResource;
+
+
+/**
+ * handles the * /reactivate endpoints
+ */
+public class ReactivateResource extends NamedResource {
+    public ReactivateResource(final ClientContext context, final UrlResource parent) {
+        super("reactivate",context, parent);
+    }
+
+    public Entity get(){
+        WebResource resource = getResource(true);
+        ApiResponse response = resource.type( MediaType.APPLICATION_JSON_TYPE )
+                                       .accept( MediaType.APPLICATION_JSON ).get( ApiResponse.class);
+        return new Entity(response);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8585558f/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/UserResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/UserResource.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/UserResource.java
index b320e6b..bb70509 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/UserResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/UserResource.java
@@ -38,6 +38,10 @@ public class UserResource extends NamedResource {
         super( name, context, parent );
     }
 
+    public ReactivateResource reactivate() {
+        return new ReactivateResource( context, this );
+    }
+
     public ConfirmResource confirm() {
         return new ConfirmResource(context,this);
     }
@@ -64,4 +68,5 @@ public class UserResource extends NamedResource {
                                        .accept( MediaType.APPLICATION_JSON ).put( ApiResponse.class,
userPayload);
         return new Entity(response);
     }
+
 }


Mime
View raw message