You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2015/11/23 21:11:41 UTC
[1/7] usergrid git commit: Fix for USERGRID-1119 which tests the
private group activities use case.
Repository: usergrid
Updated Branches:
refs/heads/master 6fffe936b -> 5dfdf81e8
Fix for USERGRID-1119 which tests the private group activities use case.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/28a627a5
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/28a627a5
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/28a627a5
Branch: refs/heads/master
Commit: 28a627a56d40bc192b92071b91a65564113b778c
Parents: 6f3541b
Author: Dave Johnson <sn...@apache.org>
Authored: Thu Nov 19 12:35:47 2015 -0500
Committer: Dave Johnson <sn...@apache.org>
Committed: Thu Nov 19 12:35:47 2015 -0500
----------------------------------------------------------------------
.../collection/groups/GroupResourceIT.java | 115 ++++++++++++-------
1 file changed, 75 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/28a627a5/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
index bd75adf..769852d 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
@@ -25,6 +25,7 @@ import org.junit.Ignore;
import org.junit.Test;
import javax.ws.rs.ClientErrorException;
+import javax.ws.rs.NotAuthorizedException;
import java.io.IOException;
import static org.junit.Assert.*;
@@ -388,21 +389,19 @@ public class GroupResourceIT extends AbstractRestIT {
}
- /***
- *
- * Post a group activity and make sure it can be read back only by group members
- *
+ /**
+ * Post a group activities and test that the appear in the groups activities feed, and that
+ * they appear only in the personal activity feeds of the group's members.
*/
- @Ignore("Pending https://issues.apache.org/jira/browse/USERGRID-1119. Fails. See todo in the test itself.")
@Test
- public void postGroupActivity() throws IOException {
-
+ public void postPrivateGroupActivity() throws IOException {
//1. create a group
String groupName = "testgroup";
String groupPath = "testgroup";
Entity group = this.createGroup(groupName, groupPath);
+
//2. create user 1
String user1Username = "fred";
String user1Email = "fred@usergrid.com";
@@ -421,21 +420,51 @@ public class GroupResourceIT extends AbstractRestIT {
password = "password";
Entity user3 = this.createUser(user3Username, user3Email, password);
+
//5. add user1 to the group
- Entity addUser1Response = this.app().collection("users").entity(user1).connection().collection("groups").entity(group).post();
+ Entity addUser1Response = this.app().collection("users")
+ .entity(user1).connection().collection("groups").entity(group).post();
assertEquals(addUser1Response.get("name"), groupName);
//6. add user2 to the group
- Entity addUser2Response = this.app().collection("users").entity(user2).connection().collection("groups").entity(group).post();
+ Entity addUser2Response = this.app().collection("users")
+ .entity(user2).connection().collection("groups").entity(group).post();
assertEquals(addUser2Response.get("name"), groupName);
+
// user 3 does not get added to the group
+
//7. get all the users in the groups
this.refreshIndex();
Collection usersInGroup = this.app().collection("groups").uniqueID(groupName).connection("users").get();
assertEquals(usersInGroup.getResponse().getEntityCount(), 2);
+ //7a. delete default role and make group private, only accessible to those with "group1role"
+ this.app().collection("role").uniqueID("Default").delete();
+ Entity data = new Entity().chainPut("name", "group1role");
+ this.app().collection("roles").post(data);
+ this.refreshIndex();
+
+ Entity perms = new Entity();
+ String permission = "get,post,put,delete:/groups/" + group.getUuid() + "/**";
+ perms.put("permission",permission);
+ this.app().collection("roles").uniqueID("group1role").connection("permissions").post(perms);
+ this.app().collection("roles").uniqueID("group1role").connection("users").uniqueID( user1Username ).post();
+ this.app().collection("roles").uniqueID("group1role").connection("users").uniqueID( user2Username ).post();
+ this.refreshIndex();
+
+ //7b. everybody gets access to /activities
+ perms = new Entity();
+ permission = "get:/activities/**";
+ perms.put("permission",permission);
+ this.app().collection("roles").uniqueID("Guest").connection("permissions").post(perms);
+ this.refreshIndex();
+ this.app().collection("roles").uniqueID("Guest").connection("users").uniqueID( user1Username ).post();
+ this.app().collection("roles").uniqueID("Guest").connection("users").uniqueID( user2Username ).post();
+ this.app().collection("roles").uniqueID("Guest").connection("users").uniqueID( user3Username ).post();
+ this.refreshIndex();
+
//8. post an activity to the group
//JSON should look like this:
@@ -448,30 +477,19 @@ public class GroupResourceIT extends AbstractRestIT {
Entity activity = new Entity();
activity.put("actor", payload);
activity.put("verb", "post");
- String content = "content";
+ final String content = "Wilma cannot see this!";
activity.put("content", content);
- Entity activityResponse = this.app().collection("groups").uniqueID(groupName).connection("activities").post(activity);
+ Entity activityResponse = this.app().collection("groups")
+ .uniqueID(groupName).connection("activities").post(activity);
assertEquals(activityResponse.get("content"), content);
this.refreshIndex();
- //9. delete the default role
- this.app().collection("role").uniqueID("Default").delete();
-/*
- //10. add permissions to group: {"permission":"get,post,put,delete:/groups/${group}/**"}'
- payload = new Entity();
- String permission = "get,post,put,delete:/groups/${group}/**";
- payload.put("permission",permission);
- Entity permissionResponse = this.app().collection("groups").entity(group).connection("permissions").post(payload);
- assertEquals(permissionResponse.get("data"), permission);
-*/
//11. log user1 in, should then be using the app user's token not the admin token
this.getAppUserToken(user1Username, password);
-
- //TODO: next failing currently because permissions seem to be borked in the stack
-
- //12. make sure the activity appears in the feed of user 1
- Collection user1ActivityResponse = this.app().collection("groups").entity(group).connection("activities").get();
+ //10. make sure the activity appears in the feed of user 1
+ Collection user1ActivityResponse = this.app().collection("groups")
+ .entity(group).connection("activities").get();
boolean found = false;
while (user1ActivityResponse.hasNext()) {
Entity tempActivity = user1ActivityResponse.next();
@@ -481,11 +499,12 @@ public class GroupResourceIT extends AbstractRestIT {
}
assertTrue(found);
- //13. log user2 in, should then be using the app user's token not the admin token
+ //11. log user2 in, should then be using the app user's token not the admin token
this.getAppUserToken(user2Username, password);
- //14. make sure the activity appears in the feed of user 2
- Collection user2ActivityResponse = this.app().collection("groups").entity(group).connection("activities").get();
+ //12. make sure the activity appears in the feed of user 2
+ Collection user2ActivityResponse = this.app().collection("groups")
+ .entity(group).connection("activities").get();
found = false;
while (user2ActivityResponse.hasNext()) {
Entity tempActivity = user2ActivityResponse.next();
@@ -495,11 +514,35 @@ public class GroupResourceIT extends AbstractRestIT {
}
assertTrue(found);
- //15. log user3 in, should then be using the app user's token not the admin token
+ //13. log user3 in, should then be using the app user's token not the admin token
this.getAppUserToken(user3Username, password);
- //16. make sure the activity does not appear in the feed of user 3, since they are not part of the group
- Collection user3ActivityResponse = this.app().collection("groups").entity(group).connection("activities").get();
+ //14. user3 should be denied access to the group's activities
+ try {
+
+ Collection user3ActivityResponse = this.app().collection( "groups" )
+ .entity( group ).connection( "activities" ).get();
+ fail("user3 should have been denied access to the group's activities");
+
+ } catch (NotAuthorizedException expected) {}
+
+
+ //15. check that activity appears in user 1's personal feed
+ this.getAppUserToken(user1Username, password);
+ user1ActivityResponse = this.app().collection("activities").get();
+ found = false;
+ while (user1ActivityResponse.hasNext()) {
+ Entity tempActivity = user1ActivityResponse.next();
+ if (tempActivity.get("type").equals("activity") && tempActivity.get("content").equals(content)) {
+ found = true;
+ }
+ }
+ assertTrue(found);
+
+
+ //16. check that activity does not appear user 3's personal feed
+ this.getAppUserToken(user3Username, password);
+ Collection user3ActivityResponse = this.app().collection("activities").get();
found = false;
while (user3ActivityResponse.hasNext()) {
Entity tempActivity = user3ActivityResponse.next();
@@ -508,13 +551,10 @@ public class GroupResourceIT extends AbstractRestIT {
}
}
assertFalse(found);
-
-
}
public void updateGroupWithSameNameAsApp() throws IOException {
-
// create groupMap with same name as app
String groupPath = this.clientSetup.getAppName();
String groupName = this.clientSetup.getAppName();
@@ -534,10 +574,5 @@ public class GroupResourceIT extends AbstractRestIT {
groupResponse = this.app().collection("groups").uniqueID(uuid).put(group);
assertEquals(groupResponse.get("title"), evenNewerTitle);
this.refreshIndex();
-
-
-
}
-
-
}
[4/7] usergrid git commit: Re-enable 6 tests that were ignored or
commented out, add JIRA issue for the one that is still ignored.
Posted by sn...@apache.org.
Re-enable 6 tests that were ignored or commented out, add JIRA issue for the one that is still ignored.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/46f9802e
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/46f9802e
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/46f9802e
Branch: refs/heads/master
Commit: 46f9802e2fe9d8d36ecbfc4b0b86ae4756e8e03d
Parents: cd1675c
Author: Dave Johnson <sn...@apache.org>
Authored: Mon Nov 23 12:27:04 2015 -0500
Committer: Dave Johnson <sn...@apache.org>
Committed: Mon Nov 23 12:27:04 2015 -0500
----------------------------------------------------------------------
.../usergrid/rest/management/AdminUsersIT.java | 162 ++++++++++---------
1 file changed, 82 insertions(+), 80 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/46f9802e/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 a022f80..b346c28 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
@@ -32,6 +32,7 @@ import org.jvnet.mock_javamail.Mailbox;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMultipart;
+import javax.ws.rs.BadRequestException;
import javax.ws.rs.ClientErrorException;
import javax.ws.rs.InternalServerErrorException;
import javax.ws.rs.core.Form;
@@ -439,31 +440,52 @@ public class AdminUsersIT extends AbstractRestIT {
}
-// @Test
-// public void passwordResetIncorrectUserName() throws Exception {
-//
-// String email = "test2@usergrid.com";
-// setup.getMgmtSvc().createAdminUser( "test2", "test2", "test2@usergrid.com", "sesa2me", false, false );
-// UserInfo userInfo = setup.getMgmtSvc().getAdminUserByEmail( email );
-// String resetToken = setup.getMgmtSvc().getPasswordResetTokenForAdminUser( userInfo.getUuid(), 15000 );
-//
-// assertTrue( setup.getMgmtSvc().checkPasswordResetTokenForAdminUser( userInfo.getUuid(), resetToken ) );
-//
-// Form formData = new Form();
-// formData.add( "token", resetToken );
-// formData.add( "password1", "sesa2me" );
-// formData.add( "password2", "sesa2me" );
-//
-// String html = resource().path( "/management/users/" + "noodle" + userInfo.getUsername() + "/resetpw" )
-// .type( MediaType.APPLICATION_FORM_URLENCODED_TYPE ).post( String.class, formData );
-//
-// assertTrue( html.contains( "Incorrect username entered" ) );
-//
-// html = resource().path( "/management/users/" + userInfo.getUsername() + "/resetpw" )
-// .type( MediaType.APPLICATION_FORM_URLENCODED_TYPE ).post( String.class, formData );
-//
-// assertTrue( html.contains( "password set" ) );
-// }
+ @Test
+ public void passwordResetIncorrectUserName() throws Exception {
+
+ // initiate password reset
+ management().users().user( clientSetup.getUsername() ).resetpw().post(new Form());
+ refreshIndex();
+
+ // create mocked inbox, get password reset email and extract token
+ List<Message> inbox = Mailbox.get( clientSetup.getEmail() );
+ assertFalse( inbox.isEmpty() );
+
+ MockImapClient client = new MockImapClient( "mockserver.com", "test-user-47", "somepassword" );
+ client.processMail();
+
+ // Get email with confirmation token and extract token
+ String token = null;
+ Iterator<Message> msgIterator = inbox.iterator();
+ while ( token == null && msgIterator.hasNext() ) {
+ Message msg = msgIterator.next();
+ if ( msg.getSubject().equals("Password Reset") ) {
+ token = getTokenFromMessage( msg );
+ }
+ }
+ assertNotNull( token );
+
+ Form formData = new Form();
+ formData.param( "token", token );
+ formData.param( "password1", "sesame" );
+ formData.param( "password2", "sesame" );
+
+ try {
+
+ String html = management().users().user( "mr_fatfinger" ).resetpw().getTarget().request()
+ .post( javax.ws.rs.client.Entity.form( formData ), String.class );
+
+ fail("Password reset request should have failed");
+
+ } catch ( BadRequestException expected ) {
+ assertTrue( expected.getResponse().getEntity().toString().contains( "Could not find" ) );
+ }
+
+ String html = management().users().user( clientSetup.getUsername() ).resetpw().getTarget().request()
+ .post( javax.ws.rs.client.Entity.form(formData), String.class );
+
+ assertTrue( html.contains( "password set" ) );
+ }
/**
@@ -519,7 +541,6 @@ public class AdminUsersIT extends AbstractRestIT {
}
}
- //TODO: won't work until resetpw viewables are fixed in the embedded environment.
@Test
public void checkPasswordChangeTime() throws Exception {
@@ -553,72 +574,53 @@ public class AdminUsersIT extends AbstractRestIT {
String html = management().users().user( clientSetup.getUsername() ).resetpw().getTarget().request()
.post( javax.ws.rs.client.Entity.form(formData), String.class );
assertTrue( html.contains( "password set" ) );
-
-
-
+ refreshIndex();
// login with new password and get token
+ Map<String, Object> payload = new HashMap<String, Object>() {{
+ put("grant_type", "password");
+ put("username", clientSetup.getUsername() );
+ put("password", "sesame");
+ }};
+ ApiResponse response = management().token().post( false, payload, null );
+
// check password changed time
+ Long changeTime = Long.parseLong( response.getProperties().get( "passwordChanged" ).toString() );
+ assertTrue( System.currentTimeMillis() - changeTime < 2000 );
+
// change password again by posting JSON
+ payload = new HashMap<String, Object>() {{
+ put("oldpassword", "sesame");
+ put("newpassword", "test");
+ }};
+ management().users().user( clientSetup.getUsername() ).password().post( false, payload, null );
+ refreshIndex();
+
// get password and check password change time again
+ payload = new HashMap<String, Object>() {{
+ put("grant_type", "password");
+ put("username", clientSetup.getUsername() );
+ put("password", "test");
+ }};
+ response = management().token().post( false, payload, null );
+
+ Long changeTime2 = Long.parseLong( response.getProperties().get( "passwordChanged" ).toString() );
+ assertTrue( changeTime < changeTime2 );
+ assertTrue( System.currentTimeMillis() - changeTime2 < 2000 );
+
// login via /me end-point and check password change time again
+ response = management().me().get( ApiResponse.class, new QueryParameters()
+ .addParam( "grant_type", "password" )
+ .addParam( "username", clientSetup.getUsername() )
+ .addParam( "password", "test" ) );
-// final TestUser user = context.getActiveUser();
-// String email = user.getEmail();
-// UserInfo userInfo = setup.getMgmtSvc().getAdminUserByEmail( email );
-// String resetToken = setup.getMgmtSvc().getPasswordResetTokenForAdminUser( userInfo.getUuid(), 15000 );
-//
-// refreshIndex(context.getOrgName(), context.getAppName());
-//
-// Form formData = new Form();
-// formData.add( "token", resetToken );
-// formData.add( "password1", "sesame" );
-// formData.add( "password2", "sesame" );
-//
-// String html = resource().path( "/management/users/" + userInfo.getUsername() + "/resetpw" )
-// .type( MediaType.APPLICATION_FORM_URLENCODED_TYPE ).post( String.class, formData );
-// assertTrue( html.contains( "password set" ) );
-//
-// refreshIndex(context.getOrgName(), context.getAppName());
-//
-// JsonNode node = mapper.readTree( resource().path( "/management/token" )
-// .queryParam( "grant_type", "password" )
-// .queryParam( "username", email ).queryParam( "password", "sesame" )
-// .accept( MediaType.APPLICATION_JSON )
-// .get( String.class ));
-//
-// Long changeTime = node.get( "passwordChanged" ).longValue();
-// assertTrue( System.currentTimeMillis() - changeTime < 2000 );
-//
-// Map<String, String> payload = hashMap( "oldpassword", "sesame" ).map( "newpassword", "test" );
-// node = mapper.readTree( resource().path( "/management/users/" + userInfo.getUsername() + "/password" )
-// .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-// .post( String.class, payload ));
-//
-// refreshIndex(context.getOrgName(), context.getAppName());
-//
-// node = mapper.readTree( resource().path( "/management/token" )
-// .queryParam( "grant_type", "password" )
-// .queryParam( "username", email )
-// .queryParam( "password", "test" )
-// .accept( MediaType.APPLICATION_JSON )
-// .get( String.class ));
-//
-// Long changeTime2 = node.get( "passwordChanged" ).longValue();
-// assertTrue( changeTime < changeTime2 );
-// assertTrue( System.currentTimeMillis() - changeTime2 < 2000 );
-//
-// node = mapper.readTree( resource().path( "/management/me" ).queryParam( "grant_type", "password" )
-// .queryParam( "username", email ).queryParam( "password", "test" ).accept( MediaType.APPLICATION_JSON )
-// .get( String.class ));
-//
-// Long changeTime3 = node.get( "passwordChanged" ).longValue();
-// assertEquals( changeTime2, changeTime3 );
+ Long changeTime3 = Long.parseLong( response.getProperties().get( "passwordChanged" ).toString() );
+ assertEquals( changeTime2, changeTime3 );
}
[6/7] usergrid git commit: PR changes test code only. This closes #443
Posted by sn...@apache.org.
PR changes test code only. This closes #443
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/41521881
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/41521881
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/41521881
Branch: refs/heads/master
Commit: 41521881e665835c53167d5943e99ddd9289957c
Parents: 59b1f0d c1f5e16
Author: Dave Johnson <sn...@apache.org>
Authored: Mon Nov 23 15:10:46 2015 -0500
Committer: Dave Johnson <sn...@apache.org>
Committed: Mon Nov 23 15:10:46 2015 -0500
----------------------------------------------------------------------
.../applications/ApplicationResourceIT.java | 33 ++++++++++++--------
1 file changed, 20 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
[3/7] usergrid git commit: Re-enable 6 tests that were ignored or
commented out, add JIRA issue for the one that is still ignored.
Posted by sn...@apache.org.
Re-enable 6 tests that were ignored or commented out, add JIRA issue for the one that is still ignored.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/cd1675c8
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/cd1675c8
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/cd1675c8
Branch: refs/heads/master
Commit: cd1675c833a8fc29b3169916b9e4808a7144cc02
Parents: 6fffe93
Author: Dave Johnson <sn...@apache.org>
Authored: Mon Nov 23 12:26:50 2015 -0500
Committer: Dave Johnson <sn...@apache.org>
Committed: Mon Nov 23 12:26:50 2015 -0500
----------------------------------------------------------------------
.../usergrid/rest/management/AdminUsersIT.java | 97 ++++++++++++++------
1 file changed, 71 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/cd1675c8/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 09a76aa..a022f80 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
@@ -17,6 +17,7 @@
package org.apache.usergrid.rest.management;
+import net.jcip.annotations.NotThreadSafe;
import org.apache.usergrid.management.MockImapClient;
import org.apache.usergrid.persistence.core.util.StringUtils;
import org.apache.usergrid.persistence.index.utils.UUIDUtils;
@@ -36,10 +37,7 @@ import javax.ws.rs.InternalServerErrorException;
import javax.ws.rs.core.Form;
import javax.ws.rs.core.Response;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import static org.apache.usergrid.management.AccountCreationProps.*;
import static org.junit.Assert.*;
@@ -48,6 +46,7 @@ import static org.junit.Assert.*;
/**
* Contains all tests relating to Admin Users
*/
+@NotThreadSafe
public class AdminUsersIT extends AbstractRestIT {
ManagementResource management;
@@ -187,7 +186,6 @@ public class AdminUsersIT extends AbstractRestIT {
* TODO:test for parallel test that changing the properties here won't affect other tests
* @throws Exception
*/
- @Ignore("Pending https://issues.apache.org/jira/browse/USERGRID-1115. breaks other tests")
@Test
public void testUnconfirmedAdminLogin() throws Exception{
@@ -273,7 +271,6 @@ public class AdminUsersIT extends AbstractRestIT {
* Test that the system admin doesn't need a confirmation email
* @throws Exception
*/
- @Ignore("Pending https://issues.apache.org/jira/browse/USERGRID-1115. breaks other tests")
@Test
public void testSystemAdminNeedsNoConfirmation() throws Exception{
//Save original properties to return them to normal at the end of the test
@@ -311,8 +308,6 @@ public class AdminUsersIT extends AbstractRestIT {
* Test that the test account doesn't need confirmation and is created automatically.
* @throws Exception
*/
- @Ignore("Pending https://issues.apache.org/jira/browse/USERGRID-1115. Test account problem")
- // Test doesn't pass because the test account isn't getting correct instantiated
@Test
public void testTestUserNeedsNoConfirmation() throws Exception{
//Save original properties to return them to normal at the end of the test
@@ -348,9 +343,7 @@ public class AdminUsersIT extends AbstractRestIT {
* Update the current management user and make sure the change persists
* @throws Exception
*/
- @Ignore("Pending https://issues.apache.org/jira/browse/USERGRID-1115.")
- // Fails because we cannot GET a management user with a super user token - only with an Admin level token.
- // But, we can PUT with a superuser token. This test will work once that issue has been resolved.
+ @Ignore("Pending new feature https://issues.apache.org/jira/browse/USERGRID-1127")
@Test
public void updateManagementUser() throws Exception {
@@ -400,25 +393,32 @@ public class AdminUsersIT extends AbstractRestIT {
assertFalse( inbox.isEmpty() );
}
- @Ignore("Pending https://issues.apache.org/jira/browse/USERGRID-1115. Viewables issue.")
- // Test is broken due to viewables not being properly returned in the embedded tomcat
+
@Test
public void checkFormPasswordReset() throws Exception {
-
+ // initiate password reset
management().users().user( clientSetup.getUsername() ).resetpw().post(new Form());
+ refreshIndex();
- //Create mocked inbox
+ // create mocked inbox, get password reset email and extract token
List<Message> inbox = Mailbox.get( clientSetup.getEmail() );
assertFalse( inbox.isEmpty() );
MockImapClient client = new MockImapClient( "mockserver.com", "test-user-46", "somepassword" );
client.processMail();
- //Get email with confirmation token and extract token
- Message confirmation = inbox.get( 0 );
- assertEquals( "User Account Confirmation: " + clientSetup.getEmail(), confirmation.getSubject() );
- String token = getTokenFromMessage( confirmation );
+ // Get email with confirmation token and extract token
+
+ String token = null;
+ Iterator<Message> msgIterator = inbox.iterator();
+ while ( token == null && msgIterator.hasNext() ) {
+ Message msg = msgIterator.next();
+ if ( msg.getSubject().equals("Password Reset") ) {
+ token = getTokenFromMessage( msg );
+ }
+ }
+ assertNotNull( token );
Form formData = new Form();
formData.param( "token", token );
@@ -438,6 +438,7 @@ public class AdminUsersIT extends AbstractRestIT {
assertTrue( html.contains( "invalid token" ) );
}
+
// @Test
// public void passwordResetIncorrectUserName() throws Exception {
//
@@ -519,9 +520,54 @@ public class AdminUsersIT extends AbstractRestIT {
}
//TODO: won't work until resetpw viewables are fixed in the embedded environment.
-// @Test
-// public void checkPasswordChangeTime() throws Exception {
-//
+ @Test
+ public void checkPasswordChangeTime() throws Exception {
+
+ // request password reset
+
+ management().users().user( clientSetup.getUsername() ).resetpw().post(new Form());
+ refreshIndex();
+
+ // get resetpw token from email
+
+ List<Message> inbox = Mailbox.get( clientSetup.getEmail() );
+ assertFalse( inbox.isEmpty() );
+ MockImapClient client = new MockImapClient( "mockserver.com", "test-user-46", "somepassword" );
+ client.processMail();
+ String token = null;
+ Iterator<Message> msgIterator = inbox.iterator();
+ while ( token == null && msgIterator.hasNext() ) {
+ Message msg = msgIterator.next();
+ if ( msg.getSubject().equals("Password Reset") ) {
+ token = getTokenFromMessage( msg );
+ }
+ }
+ assertNotNull( token );
+
+ // reset the password to sesame
+
+ Form formData = new Form();
+ formData.param( "token", token );
+ formData.param( "password1", "sesame" );
+ formData.param( "password2", "sesame" );
+ String html = management().users().user( clientSetup.getUsername() ).resetpw().getTarget().request()
+ .post( javax.ws.rs.client.Entity.form(formData), String.class );
+ assertTrue( html.contains( "password set" ) );
+
+
+
+
+ // login with new password and get token
+
+ // check password changed time
+
+ // change password again by posting JSON
+
+ // get password and check password change time again
+
+ // login via /me end-point and check password change time again
+
+
// final TestUser user = context.getActiveUser();
// String email = user.getEmail();
// UserInfo userInfo = setup.getMgmtSvc().getAdminUserByEmail( email );
@@ -573,9 +619,9 @@ public class AdminUsersIT extends AbstractRestIT {
//
// Long changeTime3 = node.get( "passwordChanged" ).longValue();
// assertEquals( changeTime2, changeTime3 );
-// }
-//
-//
+ }
+
+
/**
@@ -638,7 +684,6 @@ public class AdminUsersIT extends AbstractRestIT {
}
}
- @Ignore("Pending https://issues.apache.org/jira/browse/USERGRID-1115. breaks other tests")
@Test
public void testProperties(){
ApiResponse originalTestPropertiesResponse = clientSetup.getRestClient().testPropertiesResource().get();
[2/7] usergrid git commit: Fix for USERGRID-1106: fixed by rewriting
test to do exactly what it used to do before the new framework conversion.
Posted by sn...@apache.org.
Fix for USERGRID-1106: fixed by rewriting test to do exactly what it used to do before the new framework conversion.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/c1f5e16a
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/c1f5e16a
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/c1f5e16a
Branch: refs/heads/master
Commit: c1f5e16a72bda590be1e890be005a636fd247550
Parents: 6fffe93
Author: Dave Johnson <sn...@apache.org>
Authored: Fri Nov 20 09:56:30 2015 -0500
Committer: Dave Johnson <sn...@apache.org>
Committed: Fri Nov 20 09:56:30 2015 -0500
----------------------------------------------------------------------
.../applications/ApplicationResourceIT.java | 33 ++++++++++++--------
1 file changed, 20 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/c1f5e16a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
index 8d29290..e822f66 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
@@ -645,34 +645,41 @@ public class ApplicationResourceIT extends AbstractRestIT {
}
/**
- * Retrieve an access token using HTTP Basic authentication
+ * Retrieve an app user access token using HTTP Basic authentication
*/
@Test
- @Ignore("Pending https://issues.apache.org/jira/browse/USERGRID-1106")
- //Are we trying to generate token with token? Couldn't find endpoint that accepts token for generating token
public void clientCredentialsFlowWithHeaderAuthorization() throws Exception {
- //retrieve the credentials
- Credentials orgCredentials = getAppCredentials();
- String clientId = orgCredentials.getClientId();
- String clientSecret = orgCredentials.getClientSecret();
+ // get app credentials from /<org>/<app>/credentials end-point (using admin credentials)
+ Credentials appCredentials = getAppCredentials();
+ String clientId = appCredentials.getClientId();
+ String clientSecret = appCredentials.getClientSecret();
+
+ // use app credentials to admin user access token
Token token = clientSetup.getRestClient().management().token()
.post(Token.class,new Token("client_credentials", clientId, clientSecret));
- //GET the token endpoint, adding authorization header
- Token apiResponse = this.app().token().getTarget( false )
+ String clientCredentials = clientId + ":" + clientSecret;
+ String encodedToken = Base64.encodeToString( clientCredentials.getBytes() );
+
+ Map<String, String> payload = hashMap( "grant_type", "client_credentials" );
+
+ // use admin user access token to get app user access token
+ Token apiResponse = this.app().token().getTarget( false ).request()
//add the auth header
- .request()
- .header( "Authorization", "Bearer " + token.getAccessToken() )
+ .header( "Authorization", "Basic " + encodedToken )
.accept( MediaType.APPLICATION_JSON )
- .post(javax.ws.rs.client.Entity.entity(
- hashMap( "grant_type", "client_credentials" ), MediaType.APPLICATION_JSON_TYPE ), Token.class );
+ .post(javax.ws.rs.client.Entity.entity(payload, MediaType.APPLICATION_JSON_TYPE ), Token.class );
//Assert that a valid token with a valid TTL is returned
assertNotNull("A valid response was returned.", apiResponse);
assertNull("There is no error.", apiResponse.getError());
assertNotNull("It has access_token.", apiResponse.getAccessToken());
assertNotNull("It has expires_in.", apiResponse.getExpirationDate());
+
+
+
+
}
/**
[7/7] usergrid git commit: PR changes test code only. This closes #444
Posted by sn...@apache.org.
PR changes test code only. This closes #444
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/5dfdf81e
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/5dfdf81e
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/5dfdf81e
Branch: refs/heads/master
Commit: 5dfdf81e8d0c58e04b305b3bd1adeac176fbaae5
Parents: 4152188 46f9802
Author: Dave Johnson <sn...@apache.org>
Authored: Mon Nov 23 15:11:05 2015 -0500
Committer: Dave Johnson <sn...@apache.org>
Committed: Mon Nov 23 15:11:05 2015 -0500
----------------------------------------------------------------------
.../usergrid/rest/management/AdminUsersIT.java | 253 +++++++++++--------
1 file changed, 150 insertions(+), 103 deletions(-)
----------------------------------------------------------------------
[5/7] usergrid git commit: PR changes test code only. This closes #441
Posted by sn...@apache.org.
PR changes test code only. This closes #441
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/59b1f0d4
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/59b1f0d4
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/59b1f0d4
Branch: refs/heads/master
Commit: 59b1f0d44dd2f630120547b3d851faf3c213c5f0
Parents: 6fffe93 28a627a
Author: Dave Johnson <sn...@apache.org>
Authored: Mon Nov 23 15:09:52 2015 -0500
Committer: Dave Johnson <sn...@apache.org>
Committed: Mon Nov 23 15:09:52 2015 -0500
----------------------------------------------------------------------
.../collection/groups/GroupResourceIT.java | 115 ++++++++++++-------
1 file changed, 75 insertions(+), 40 deletions(-)
----------------------------------------------------------------------