You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2014/12/28 21:36:36 UTC
[1/8] incubator-usergrid git commit: updated groups tests to work
with new framework
Repository: incubator-usergrid
Updated Branches:
refs/heads/USERGRID-291-User-Tests 2a8391ea3 -> f59aad0da
updated groups tests to work with new framework
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/9005e30f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/9005e30f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/9005e30f
Branch: refs/heads/USERGRID-291-User-Tests
Commit: 9005e30fd6130636dc0f81d4bfa02b7b523b1993
Parents: 615ac49
Author: Rod Simpson <ro...@apigee.com>
Authored: Sat Dec 20 14:04:54 2014 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Sat Dec 20 14:04:54 2014 -0700
----------------------------------------------------------------------
.../collection/groups/GroupResourceIT.java | 359 +++++++++++--------
1 file changed, 215 insertions(+), 144 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9005e30f/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 79ce8c5..f536269 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
@@ -26,6 +26,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.sun.jersey.api.client.UniformInterfaceException;
import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
+import org.apache.usergrid.rest.test.resource2point0.model.Collection;
import org.apache.usergrid.rest.test.resource2point0.model.Entity;
import org.junit.Test;
import org.slf4j.Logger;
@@ -41,6 +42,39 @@ public class GroupResourceIT extends AbstractRestIT {
public GroupResourceIT() throws Exception { }
+ private Entity createGroup(String groupName, String groupPath) throws IOException{
+ Entity payload = new Entity();
+ payload.put("name", groupName);
+ payload.put("path", groupPath);
+ Entity entity = this.app().collection("groups").post(payload);
+ assertEquals(entity.get("name"), groupName);
+ assertEquals(entity.get("path"), groupPath);
+ this.refreshIndex();
+ return entity;
+ }
+
+ private Entity createRole(String roleName, String roleTitle) throws IOException{
+ Entity payload = new Entity();
+ payload.put("name", roleName);
+ payload.put("title", roleTitle);
+ Entity entity = this.app().collection("roles").post(payload);
+ assertEquals(entity.get("name"), roleName);
+ assertEquals(entity.get("title"), roleTitle);
+ this.refreshIndex();
+ return entity;
+ }
+
+ private Entity createUser(String username, String email) throws IOException{
+ Entity payload = new Entity();
+ payload.put("username", username);
+ payload.put("email", email);
+ Entity entity = this.app().collection("users").post(payload);
+ assertEquals(entity.get("username"), username);
+ assertEquals(entity.get("email"), email);
+ this.refreshIndex();
+ return entity;
+ }
+
/***
*
* Verify that we can create a group with a standard string in the name and path
@@ -50,15 +84,7 @@ public class GroupResourceIT extends AbstractRestIT {
String groupName = "testgroup";
String groupPath = "testgroup";
-
- Entity payload = new Entity();
- payload.put("name", groupName);
- payload.put("path", groupPath);
-
- Entity group = this.app().collection("groups").post(payload);
-
- assertEquals(group.get("path"), groupPath);
- assertEquals(group.get("name"), groupName);
+ this.createGroup(groupName, groupPath);
}
@@ -70,18 +96,9 @@ public class GroupResourceIT extends AbstractRestIT {
@Test()
public void createGroupSlashInNameAndPathValidation() throws IOException {
- //create the group with a slash in the name
String groupNameSlash = "test/group";
String groupPathSlash = "test/group";
-
- Entity payload = new Entity();
- payload.put("name", groupNameSlash);
- payload.put("path", groupPathSlash);
-
- Entity group = this.app().collection("groups").post(payload);
-
- assertEquals(group.get("name"), groupNameSlash);
- assertEquals(group.get("path"), groupPathSlash);
+ this.createGroup(groupNameSlash, groupPathSlash);
}
@@ -93,18 +110,9 @@ public class GroupResourceIT extends AbstractRestIT {
@Test()
public void createGroupSpaceInNameValidation() throws IOException {
- //create the group with a space in the name
String groupSpaceName = "test group";
String groupPath = "testgroup";
-
- Entity payload = new Entity();
- payload.put("name", groupSpaceName);
- payload.put("path", groupPath);
-
- Entity group = this.app().collection("groups").post(payload);
-
- assertEquals(group.get("name"), groupSpaceName);
- assertEquals(group.get("path"), groupPath);
+ this.createGroup(groupSpaceName, groupPath);
}
@@ -118,14 +126,8 @@ public class GroupResourceIT extends AbstractRestIT {
String groupName = "testgroup";
String groupSpacePath = "test group";
-
- Entity payload = new Entity();
- payload.put("name", groupName);
- payload.put("path", groupSpacePath);
-
-
try {
- this.app().collection("groups").post(payload);
+ Entity group = this.createGroup(groupName, groupSpacePath);
fail("Should not be able to create a group with a space in the path");
} catch (UniformInterfaceException e) {
//verify the correct error was returned
@@ -137,50 +139,204 @@ public class GroupResourceIT extends AbstractRestIT {
/***
*
- * Verify that we can create a group and then change the name
+ * Verify that we can create a group, change the name, then delete it
*/
@Test()
public void changeGroupNameValidation() throws IOException {
+ //1. create a group
String groupName = "testgroup";
String groupPath = "testgroup";
+ Entity group = this.createGroup(groupName, groupPath);
+
+ //2. change the name
String newGroupPath = "newtestgroup";
+ group.put("path", newGroupPath);
+ Entity groupResponse = this.app().collection("groups").entity(group).put(group);
+ assertEquals(groupResponse.get("path"), newGroupPath);
+ this.refreshIndex();
- Entity payload = new Entity();
- payload.put("name", groupName);
- payload.put("path", groupPath);
+ //3. do a GET to verify the property really was set
+ Entity groupResponseGET = this.app().collection("groups").entity(group).get();
+ assertEquals(groupResponseGET.get("path"), newGroupPath);
- Entity group = this.app().collection("groups").post(payload);
- assertEquals(group.get("path"), groupPath);
+ //4. now delete the group
+ ApiResponse response = this.app().collection("groups").entity(group).delete();
+ //todo: what to do with delete responses?
- //now change the name
- group.put("path", newGroupPath);
- this.app().collection("groups").entity(group).put(group);
- assertEquals(group.get("path"), newGroupPath);
+ //5. do a GET to make sure the entity was deleted
+ try {
+ this.app().collection("groups").uniqueID(groupName).get();
+ fail("Entity still exists");
+ } catch (UniformInterfaceException e) {
+ //verify the correct error was returned
+ JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
+ assertEquals( "service_resource_not_found", node.get( "error" ).textValue() );
+ }
- //now delete the group
- ApiResponse response = this.app().collection("groups").entity(group).delete();
+ }
+ /***
+ *
+ * Verify that we can create a group, user, add user to group, delete connection
+ */
+ @Test()
+ public void addRemoveUserGroup() throws IOException {
+ //1. create a group
+ String groupName = "testgroup";
+ String groupPath = "testgroup";
+ Entity group = this.createGroup(groupName, groupPath);
+
+ // 2. create a user
+ String username = "fred";
+ String email = "fred@usergrid.com";
+ Entity user = this.createUser(username, email);
+
+ // 3. add the user to the group
+ Entity response = this.app().collection("users").entity(user).connection().collection("groups").entity(group).post();
+ assertEquals(response.get("name"), groupName);
+ this.refreshIndex();
+
+ // 4. make sure the user is in the group
+ Collection collection = this.app().collection("groups").entity(group).connection().collection("users").get();
+ Entity entity = collection.next();
+ assertEquals(entity.get("username"), username);
+
+ //5. try it the other way around
+ collection = this.app().collection("users").entity(user).connection().collection("groups").get();
+ entity = collection.next();
+ assertEquals(entity.get("name"), groupName);
+
+ //6. remove the user from the group
+ ApiResponse responseDel = this.app().collection("group").entity(group).connection().collection("users").entity(user).delete();
+ this.refreshIndex();
+ //todo: how to check response from delete
+
+ //6. make sure the connection no longer exists
+ collection = this.app().collection("group").entity(group).connection().collection("users").get();
+ assertEquals(collection.hasNext(), false);
+
+ //8. do a GET to make sure the user still exists and did not get deleted with the collection delete
+ Entity userEntity = this.app().collection("user").entity(user).get();
+ assertEquals(userEntity.get("username"), username);
+
+ }
+
+ /***
+ *
+ * Verify that we can create a group, role, add role to group, delete connection
+ */
+ @Test
+ public void addRemoveRoleGroup() throws IOException {
+
+ //1. create a group
+ String groupName = "testgroup";
+ String groupPath = "testgroup";
+ Entity group = this.createGroup(groupName, groupPath);
+
+ //2. create a role
+ String roleName = "tester";
+ String roleTitle = "tester";
+ Entity role = this.createRole(roleName, roleTitle);
+
+ //3. add role to the group
+ Entity response = this.app().collection("role").entity(role).connection().collection("groups").entity(group).post();
+ assertEquals(response.get("name"), roleName);
+ this.refreshIndex();
+
+ //4. make sure the role is in the group
+ Collection collection = this.app().collection("groups").entity(group).connection().collection("roles").get();
+ Entity entity = collection.next();
+ assertEquals(entity.get("name"), roleName);
+
+ //5. remove Role from the group (should only delete the connection)
+ ApiResponse responseDel = this.app().collection("role").entity(role).connection().collection("groups").entity(group).delete();
+ this.refreshIndex();
+ //todo: how to check response from delete
+
+ //6. make sure the connection no longer exists
+ collection = this.app().collection("groups").entity(group).connection().collection("roles").get();
try {
- Entity newGroup = this.app().collection("groups").uniqueID(groupName).get();
+ collection.next();
fail("Entity still exists");
} catch (UniformInterfaceException e) {
//verify the correct error was returned
JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
- assertEquals( "illegal_argument", node.get( "error" ).textValue() );
+ assertEquals( "service_resource_not_found", node.get( "error" ).textValue() );
+ }
+
+ //7. check root roles to make sure role still exists
+ role = this.app().collection("roles").uniqueID(roleName).get();
+ assertEquals(role.get("name"), roleName);
+
+ //8. delete the role
+ ApiResponse responseDel2 = this.app().collection("role").entity(role).delete();
+ this.refreshIndex();
+ //todo: what to do with response from delete call?
+
+ //9. do a GET to make sure the role was deleted
+ try {
+ this.app().collection("role").entity(role).get();
+ fail("Entity still exists");
+ } catch (UniformInterfaceException e) {
+ //verify the correct error was returned
+ JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
+ assertEquals( "service_resource_not_found", node.get( "error" ).textValue() );
}
}
+
/***
*
- * Verify that we can create a group and then add a user to it
+ * Verify that group / role permissions work
+ *
+ * create group
+ * create user
+ * create role
+ * add permissions to role (e.g. POST, GET on /cats)
+ * add role to group
+ * add user to group
+ * delete default role (to ensure no app-level user operations are allowed)
+ * delete guest role (to ensure no app-level user operations are allowed)
+ * create a /cats/fluffy
+ * read /cats/fluffy
+ * update /cats/fluffy (should fail)
+ * delete /cats/fluffy (should fail)
*/
@Test()
- public void createGroupAndAddAUserValidation() throws IOException {
+ public void addRolePermissionToGroupVerifyPermission() throws IOException {
+
+ //1. create a group
+ String groupName = "testgroup";
+ String groupPath = "testgroup";
+ Entity group = this.createGroup(groupName, groupPath);
+
+ //2. create a user
+ String username = "fred";
+ String email = "fred@usergrid.com";
+ Entity user = this.createUser(username, email);
+ //3. create a role
+ String roleName = "tester";
+ String roleTitle = "tester";
+ Entity role = this.createRole(roleName, roleTitle);
+
+ //4. add permissions to role
+
+
+ //5. add role to the group
+ Entity addRoleresponse = this.app().collection("role").entity(role).connection().collection("groups").entity(group).post();
+ assertEquals(addRoleresponse.get("name"), roleName);
+ this.refreshIndex();
+
+ //6. add user to group
+ Entity addUserResponse = this.app().collection("users").entity(user).connection().collection("groups").entity(group).post();
+ assertEquals(addUserResponse.get("name"), groupName);
+ this.refreshIndex();
}
+
/***
*
* Verify that we can create a group and then add a role to it
@@ -188,6 +344,13 @@ public class GroupResourceIT extends AbstractRestIT {
@Test()
public void createGroupAndAddARoleValidation() throws IOException {
+ /*
+ JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/roles" ).queryParam( "access_token", access_token )
+ .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
+ assertNull( node.get( "errors" ) );
+ assertTrue( node.get( "entities" ).findValuesAsText( "name" ).contains( roleName ) );
+
+ */
}
/*
@@ -252,98 +415,6 @@ public class GroupResourceIT extends AbstractRestIT {
assertTrue( node.get( "data" ).size() == 0 );
}
-/*
- @Test
- public void addRemoveRole() throws IOException {
-
- UUID id = UUIDUtils.newTimeUUID();
-
- String groupName = "groupname" + id;
- String roleName = "rolename" + id;
-
- ApiResponse response = client.createGroup( groupName );
- assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-
- UUID createdId = response.getEntities().get( 0 ).getUuid();
-
- refreshIndex("test-organization", "test-app");
-
- // create Role
-
- String json = "{\"title\":\"" + roleName + "\",\"name\":\"" + roleName + "\"}";
- JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/roles" ).queryParam( "access_token", access_token )
- .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
- .post( String.class, json ));
-
- // check it
- assertNull( node.get( "errors" ) );
-
-
- refreshIndex("test-organization", "test-app");
-
- // add Role
-
- node = mapper.readTree( resource().path( "/test-organization/test-app/groups/" + createdId + "/roles/" + roleName )
- .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
-
- refreshIndex("test-organization", "test-app");
-
- // check it
- assertNull( node.get( "errors" ) );
- assertEquals( node.get( "entities" ).get( 0 ).get( "name" ).asText(), roleName );
-
- node = mapper.readTree( resource().path( "/test-organization/test-app/groups/" + createdId + "/roles" )
- .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
- assertNull( node.get( "errors" ) );
- assertEquals( node.get( "entities" ).get( 0 ).get( "name" ).asText(), roleName );
-
- // check root roles
- node = mapper.readTree( resource().path( "/test-organization/test-app/roles" ).queryParam( "access_token", access_token )
- .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
- assertNull( node.get( "errors" ) );
- assertTrue( node.get( "entities" ).findValuesAsText( "name" ).contains( roleName ) );
-
- refreshIndex("test-organization", "test-app");
-
- // remove Role
-
- node = mapper.readTree( resource().path( "/test-organization/test-app/groups/" + createdId + "/roles/" + roleName )
- .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE ).delete( String.class ));
- assertNull( node.get( "errors" ) );
-
- refreshIndex("test-organization", "test-app");
-
- node = mapper.readTree( resource().path( "/test-organization/test-app/groups/" + createdId + "/roles" )
- .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
- assertNull( node.get( "errors" ) );
- assertTrue( node.get( "entities" ).size() == 0 );
-
- // check root roles - role should remain
- node = mapper.readTree( resource().path( "/test-organization/test-app/roles" ).queryParam( "access_token", access_token )
- .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
- assertNull( node.get( "errors" ) );
- assertTrue( node.get( "entities" ).findValuesAsText( "name" ).contains( roleName ) );
-
- // now kill the root role
- node = mapper.readTree( resource().path( "/test-organization/test-app/roles/" + roleName )
- .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE ).delete( String.class ));
- assertNull( node.get( "errors" ) );
-
- refreshIndex("test-organization", "test-app");
-
- // now it should be gone
- node = mapper.readTree( resource().path( "/test-organization/test-app/roles" ).queryParam( "access_token", access_token )
- .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
- assertNull( node.get( "errors" ) );
- assertFalse( node.get( "entities" ).findValuesAsText( "name" ).contains( roleName ) );
- }
- */
-
/***
*
[2/8] incubator-usergrid git commit: added data to response,
flushed out groupsrolespermissionsusers test
Posted by sf...@apache.org.
added data to response, flushed out groupsrolespermissionsusers 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/118aa73e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/118aa73e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/118aa73e
Branch: refs/heads/USERGRID-291-User-Tests
Commit: 118aa73e2c42d35e458a3d4cd529077442229349
Parents: 9005e30
Author: Rod Simpson <ro...@apigee.com>
Authored: Sat Dec 20 15:39:35 2014 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Sat Dec 20 15:39:35 2014 -0700
----------------------------------------------------------------------
.../collection/groups/GroupResourceIT.java | 128 ++++++++-----------
.../rest/test/resource2point0/model/Entity.java | 8 +-
2 files changed, 60 insertions(+), 76 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/118aa73e/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 f536269..ac1e1d6 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
@@ -64,10 +64,11 @@ public class GroupResourceIT extends AbstractRestIT {
return entity;
}
- private Entity createUser(String username, String email) throws IOException{
+ private Entity createUser(String username, String email, String password) throws IOException{
Entity payload = new Entity();
payload.put("username", username);
payload.put("email", email);
+ payload.put("password", password);
Entity entity = this.app().collection("users").post(payload);
assertEquals(entity.get("username"), username);
assertEquals(entity.get("email"), email);
@@ -191,7 +192,8 @@ public class GroupResourceIT extends AbstractRestIT {
// 2. create a user
String username = "fred";
String email = "fred@usergrid.com";
- Entity user = this.createUser(username, email);
+ String password = "password";
+ Entity user = this.createUser(username, email, password);
// 3. add the user to the group
Entity response = this.app().collection("users").entity(user).connection().collection("groups").entity(group).post();
@@ -300,6 +302,7 @@ public class GroupResourceIT extends AbstractRestIT {
* add user to group
* delete default role (to ensure no app-level user operations are allowed)
* delete guest role (to ensure no app-level user operations are allowed)
+ * log the user in with
* create a /cats/fluffy
* read /cats/fluffy
* update /cats/fluffy (should fail)
@@ -316,7 +319,8 @@ public class GroupResourceIT extends AbstractRestIT {
//2. create a user
String username = "fred";
String email = "fred@usergrid.com";
- Entity user = this.createUser(username, email);
+ String password = "password";
+ Entity user = this.createUser(username, email, password);
//3. create a role
String roleName = "tester";
@@ -324,95 +328,69 @@ public class GroupResourceIT extends AbstractRestIT {
Entity role = this.createRole(roleName, roleTitle);
//4. add permissions to role
-
+ Entity payload = new Entity();
+ payload.put("permission","get,post:/cats");
+ Entity permission = this.app().collection("roles").uniqueID(roleName).connection("permissions").post(payload);
+ assertEquals(permission.get("data"), "get,post:/cats");
+ this.refreshIndex();
//5. add role to the group
- Entity addRoleresponse = this.app().collection("role").entity(role).connection().collection("groups").entity(group).post();
- assertEquals(addRoleresponse.get("name"), roleName);
+ Entity addRoleResponse = this.app().collection("groups").entity(group).connection().collection("roles").entity(role).post();
+ assertEquals(addRoleResponse.get("name"), roleName);
this.refreshIndex();
//6. add user to group
Entity addUserResponse = this.app().collection("users").entity(user).connection().collection("groups").entity(group).post();
assertEquals(addUserResponse.get("name"), groupName);
this.refreshIndex();
- }
-
- /***
- *
- * Verify that we can create a group and then add a role to it
- */
- @Test()
- public void createGroupAndAddARoleValidation() throws IOException {
-
- /*
- JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/roles" ).queryParam( "access_token", access_token )
- .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
- assertNull( node.get( "errors" ) );
- assertTrue( node.get( "entities" ).findValuesAsText( "name" ).contains( roleName ) );
-
- */
- }
-
- /*
-
- @Test
- public void addRemovePermission() throws IOException {
-
- GroupsCollection groups = context.groups();
-
-
-
- UUID id = UUIDUtils.newTimeUUID();
- String groupName = "groupname" + id;
-
- ApiResponse response = client.createGroup( groupName );
- assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-
- refreshIndex("test-organization", "test-app");
-
- UUID createdId = response.getEntities().get( 0 ).getUuid();
-
- // add Permission
- String orgName = context.getOrgName();
- String appName = context.getAppName();
- String path = "/"+orgName+"/"+appName+"/groups/";
-
- String json = "{\"permission\":\"delete:/test\"}";
- JsonNode node = mapper.readTree( resource().path( path + createdId + "/permissions" )
- .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, json ));
-
- // check it
- assertNull( node.get( "errors" ) );
- assertEquals( node.get( "data" ).get( 0 ).asText(), "delete:/test" );
+ //7. delete the default role
+ ApiResponse responseDelDefault = this.app().collection("role").uniqueID("Default").delete();
+ this.refreshIndex();
+ //todo: what to do with response from delete call?
- refreshIndex("test-organization", "test-app");
+ //8. delete the guest role
+ ApiResponse responseDelGuest = this.app().collection("role").uniqueID("Guest").delete();
+ this.refreshIndex();
+ //todo: what to do with response from delete call?
- node = mapper.readTree( resource().path( "/test-organization/test-app/groups/" + createdId + "/permissions" )
- .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
- assertNull( node.get( "errors" ) );
- assertEquals( node.get( "data" ).get( 0 ).asText(), "delete:/test" );
+ //log user in, should then be using the app user's token not the admin token
+ //todo: need to log user in here - how?
- // remove Permission
+ //create a cat - permissions should allow this
+ String catName = "fluffy";
+ payload = new Entity();
+ payload.put("name", catName);
+ Entity fluffy = this.app().collection("cats").post(payload);
+ assertEquals(fluffy.get("name"), catName);
+ this.refreshIndex();
- node = mapper.readTree( resource().path( "/test-organization/test-app/groups/" + createdId + "/permissions" )
- .queryParam( "access_token", access_token ).queryParam( "permission", "delete%3A%2Ftest" )
- .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).delete( String.class ));
+ //get the cat - permissions should allow this
+ fluffy = this.app().collection("cats").uniqueID(catName).get();
+ assertEquals(fluffy.get("name"), catName);
- // check it
- assertNull( node.get( "errors" ) );
- assertTrue( node.get( "data" ).size() == 0 );
+ //edit the cat - permissions should not allow this
+ fluffy.put("color", "brown");
+ try {
+ this.app().collection("cats").uniqueID(catName).put(fluffy);
+ fail("permissions should not allow this");
+ } catch (UniformInterfaceException e) {
+ //verify the correct error was returned
+ JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
+ assertEquals( "improper credentials or something", node.get( "error" ).textValue() );
+ }
- refreshIndex("test-organization", "test-app");
+ //delete the cat - permissions should not allow this
+ try {
+ this.app().collection("cats").uniqueID(catName).delete();
+ fail("permissions should not allow this");
+ } catch (UniformInterfaceException e) {
+ //verify the correct error was returned
+ JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
+ assertEquals( "improper credentials or something", node.get( "error" ).textValue() );
+ }
- node = mapper.readTree( resource().path( "/test-organization/test-app/groups/" + createdId + "/permissions" )
- .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
- assertNull( node.get( "errors" ) );
- assertTrue( node.get( "data" ).size() == 0 );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/118aa73e/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
index c4ac5ca..73cdda5 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
@@ -55,11 +55,17 @@ public class Entity implements Serializable, Map<String,Object> {
public Entity(ApiResponse response){
this.response = response;
- if(response.getEntities() !=null && response.getEntities().size()>=1){
+ if(response.getEntities() != null && response.getEntities().size()>=1){
List<Entity> entities = response.getEntities();
Map<String,Object> entity = entities.get(0);
this.putAll(entity);
}
+ else if (response.getData() != null){
+ ArrayList<String> data = (ArrayList <String>) response.getData();
+ Entity entity = new Entity();
+ entity.put("data", data.get(0));
+ this.putAll(entity);
+ }
}
//For the owner , should have different cases that looks at the different types it could be
[8/8] incubator-usergrid git commit: method already defined
Posted by sf...@apache.org.
method already defined
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/f59aad0d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/f59aad0d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/f59aad0d
Branch: refs/heads/USERGRID-291-User-Tests
Commit: f59aad0dac0a694c774a2f69ae7d142902ca66ca
Parents: 42da450
Author: Shawn Feldman <sf...@apache.org>
Authored: Sun Dec 28 13:36:13 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Sun Dec 28 13:36:13 2014 -0700
----------------------------------------------------------------------
.../test/resource2point0/endpoints/ApplicationsResource.java | 6 ------
1 file changed, 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f59aad0d/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationsResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationsResource.java
index a52e55a..07ac809 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationsResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationsResource.java
@@ -44,11 +44,5 @@ public class ApplicationsResource extends CollectionEndpoint {
return new CollectionEndpoint(name,context,this);
}
- public TokenResource token(){
- return new TokenResource(context,this);
- }
- public TokenResource token() {
- return new TokenResource(context,this);
- }
}
[4/8] incubator-usergrid git commit: Updated Group Tests,
added token login methods
Posted by sf...@apache.org.
Updated Group Tests, added token login methods
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/233f733f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/233f733f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/233f733f
Branch: refs/heads/USERGRID-291-User-Tests
Commit: 233f733fc307dd397c0a6dd5d5c7555e7f5947f1
Parents: f699a8d
Author: Rod Simpson <ro...@apigee.com>
Authored: Tue Dec 23 10:40:55 2014 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Tue Dec 23 10:40:55 2014 -0700
----------------------------------------------------------------------
.../collection/groups/GroupResourceIT.java | 128 +++++++++++--------
.../test/resource2point0/AbstractRestIT.java | 22 ++++
.../endpoints/ApplicationsResource.java | 3 +
.../endpoints/OrganizationResource.java | 4 +
.../endpoints/TokenResource.java | 2 +-
5 files changed, 107 insertions(+), 52 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/233f733f/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 ac1e1d6..4afc51d 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
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
+import java.util.NoSuchElementException;
import com.fasterxml.jackson.databind.JsonNode;
import com.sun.jersey.api.client.UniformInterfaceException;
@@ -143,29 +144,32 @@ public class GroupResourceIT extends AbstractRestIT {
* Verify that we can create a group, change the name, then delete it
*/
@Test()
- public void changeGroupNameValidation() throws IOException {
+ public void groupCRUDOperations() throws IOException {
//1. create a group
String groupName = "testgroup";
String groupPath = "testgroup";
Entity group = this.createGroup(groupName, groupPath);
- //2. change the name
+ //2. do a GET to verify the property really was set
+ Entity groupResponseGET = this.app().collection("groups").entity(group).get();
+ assertEquals(groupResponseGET.get("path"), groupPath);
+
+ //3. change the name
String newGroupPath = "newtestgroup";
group.put("path", newGroupPath);
Entity groupResponse = this.app().collection("groups").entity(group).put(group);
assertEquals(groupResponse.get("path"), newGroupPath);
this.refreshIndex();
- //3. do a GET to verify the property really was set
- Entity groupResponseGET = this.app().collection("groups").entity(group).get();
+ //4. do a GET to verify the property really was set
+ groupResponseGET = this.app().collection("groups").entity(group).get();
assertEquals(groupResponseGET.get("path"), newGroupPath);
- //4. now delete the group
- ApiResponse response = this.app().collection("groups").entity(group).delete();
- //todo: what to do with delete responses?
+ //5. now delete the group
+ this.app().collection("groups").entity(group).delete();
- //5. do a GET to make sure the entity was deleted
+ //6. do a GET to make sure the entity was deleted
try {
this.app().collection("groups").uniqueID(groupName).get();
fail("Entity still exists");
@@ -211,9 +215,8 @@ public class GroupResourceIT extends AbstractRestIT {
assertEquals(entity.get("name"), groupName);
//6. remove the user from the group
- ApiResponse responseDel = this.app().collection("group").entity(group).connection().collection("users").entity(user).delete();
+ this.app().collection("group").entity(group).connection().collection("users").entity(user).delete();
this.refreshIndex();
- //todo: how to check response from delete
//6. make sure the connection no longer exists
collection = this.app().collection("group").entity(group).connection().collection("users").get();
@@ -241,10 +244,11 @@ public class GroupResourceIT extends AbstractRestIT {
String roleName = "tester";
String roleTitle = "tester";
Entity role = this.createRole(roleName, roleTitle);
+ this.refreshIndex();
//3. add role to the group
Entity response = this.app().collection("role").entity(role).connection().collection("groups").entity(group).post();
- assertEquals(response.get("name"), roleName);
+ assertEquals(response.get("name"), groupName);
this.refreshIndex();
//4. make sure the role is in the group
@@ -253,19 +257,16 @@ public class GroupResourceIT extends AbstractRestIT {
assertEquals(entity.get("name"), roleName);
//5. remove Role from the group (should only delete the connection)
- ApiResponse responseDel = this.app().collection("role").entity(role).connection().collection("groups").entity(group).delete();
+ this.app().collection("groups").entity(group).connection().collection("roles").entity(role).delete();
this.refreshIndex();
- //todo: how to check response from delete
//6. make sure the connection no longer exists
collection = this.app().collection("groups").entity(group).connection().collection("roles").get();
try {
collection.next();
fail("Entity still exists");
- } catch (UniformInterfaceException e) {
- //verify the correct error was returned
- JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
- assertEquals( "service_resource_not_found", node.get( "error" ).textValue() );
+ } catch (NoSuchElementException e) {
+ //all good - there shouldn't be an element!
}
//7. check root roles to make sure role still exists
@@ -273,9 +274,7 @@ public class GroupResourceIT extends AbstractRestIT {
assertEquals(role.get("name"), roleName);
//8. delete the role
- ApiResponse responseDel2 = this.app().collection("role").entity(role).delete();
- this.refreshIndex();
- //todo: what to do with response from delete call?
+ this.app().collection("role").entity(role).delete();
//9. do a GET to make sure the role was deleted
try {
@@ -329,36 +328,29 @@ public class GroupResourceIT extends AbstractRestIT {
//4. add permissions to role
Entity payload = new Entity();
- payload.put("permission","get,post:/cats");
+ payload.put("permission","get,post:/cats/*");
Entity permission = this.app().collection("roles").uniqueID(roleName).connection("permissions").post(payload);
- assertEquals(permission.get("data"), "get,post:/cats");
- this.refreshIndex();
+ assertEquals(permission.get("data"), "get,post:/cats/*");
//5. add role to the group
Entity addRoleResponse = this.app().collection("groups").entity(group).connection().collection("roles").entity(role).post();
assertEquals(addRoleResponse.get("name"), roleName);
- this.refreshIndex();
//6. add user to group
Entity addUserResponse = this.app().collection("users").entity(user).connection().collection("groups").entity(group).post();
assertEquals(addUserResponse.get("name"), groupName);
- this.refreshIndex();
//7. delete the default role
- ApiResponse responseDelDefault = this.app().collection("role").uniqueID("Default").delete();
- this.refreshIndex();
- //todo: what to do with response from delete call?
+ this.app().collection("role").uniqueID("Default").delete();
//8. delete the guest role
- ApiResponse responseDelGuest = this.app().collection("role").uniqueID("Guest").delete();
- this.refreshIndex();
- //todo: what to do with response from delete call?
+ this.app().collection("role").uniqueID("Guest").delete();
- //log user in, should then be using the app user's token not the admin token
- //todo: need to log user in here - how?
+ //9. log user in, should then be using the app user's token not the admin token
+ this.getAppUserToken(username, password);
- //create a cat - permissions should allow this
+ //10. create a cat - permissions should allow this
String catName = "fluffy";
payload = new Entity();
payload.put("name", catName);
@@ -366,11 +358,11 @@ public class GroupResourceIT extends AbstractRestIT {
assertEquals(fluffy.get("name"), catName);
this.refreshIndex();
- //get the cat - permissions should allow this
+ //11. get the cat - permissions should allow this
fluffy = this.app().collection("cats").uniqueID(catName).get();
assertEquals(fluffy.get("name"), catName);
- //edit the cat - permissions should not allow this
+ //12. edit the cat - permissions should not allow this
fluffy.put("color", "brown");
try {
this.app().collection("cats").uniqueID(catName).put(fluffy);
@@ -378,17 +370,17 @@ public class GroupResourceIT extends AbstractRestIT {
} catch (UniformInterfaceException e) {
//verify the correct error was returned
JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
- assertEquals( "improper credentials or something", node.get( "error" ).textValue() );
+ assertEquals( "unauthorized", node.get( "error" ).textValue() );
}
- //delete the cat - permissions should not allow this
+ //13. delete the cat - permissions should not allow this
try {
this.app().collection("cats").uniqueID(catName).delete();
fail("permissions should not allow this");
} catch (UniformInterfaceException e) {
//verify the correct error was returned
JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
- assertEquals( "improper credentials or something", node.get( "error" ).textValue() );
+ assertEquals( "unauthorized", node.get( "error" ).textValue() );
}
}
@@ -402,23 +394,57 @@ public class GroupResourceIT extends AbstractRestIT {
@Test
public void postGroupActivity() throws IOException {
- /*
//1. create a group
- GroupsCollection groups = context.groups();
+ String groupName = "testgroup";
+ String groupPath = "testgroup";
+ Entity group = this.createGroup(groupName, groupPath);
+
+ //2. create user 1
+ String username = "fred";
+ String email = "fred@usergrid.com";
+ String password = "password";
+ Entity user1 = this.createUser(username, email, password);
+
+ //3. create user 2
+ username = "barney";
+ email = "fred@usergrid.com";
+ password = "password";
+ Entity user2 = this.createUser(username, email, password);
+
+ //4. add user1 to the group
+ Entity addUser1Response = this.app().collection("users").entity(user1).connection().collection("groups").entity(group).post();
+ assertEquals(addUser1Response.get("name"), groupName);
+
+ //5. add user2 to the group
+ Entity addUser2Response = this.app().collection("users").entity(user2).connection().collection("groups").entity(group).post();
+ assertEquals(addUser2Response.get("name"), groupName);
+
+ //6. post an activity to the group
+ //JSON should look like this:
+ //{'{"actor":{"displayName":"fdsafdsa","uuid":"2b70e83a-8a3f-11e4-9716-235107bcadb1","username":"fdsafdsa"},
+ // "verb":"post","content":"fdsafdsa"}'
+ Entity payload = new Entity();
+ payload.put("displayName", "fred");
+ payload.put("uuid", user1.get("uuid"));
+ payload.put("username", "fred");
+ Entity activity = new Entity();
+ activity.put("actor", payload);
+ activity.put("verb", "post");
+ activity.put("content", "content");
+ Entity activityResponse = this.app().collection("users").post(activity);
+ assertEquals(activityResponse.get("content"), "content");
+ assertEquals(activityResponse, activity);
+ this.refreshIndex();
+
+ //7. make sure the activity appears in the feed of user 1
+
+
+ //8. make sure the activity appears in the feed of user 2
+
- //create a group with a normal name
- String groupName = "groupTitle";
- String groupPath = "groupPath";
- JsonNode testGroup = groups.create(groupName, groupPath);
- //verify the group was created
- assertNull(testGroup.get("errors"));
- assertEquals(testGroup.get("path").asText(), groupPath);
- //2. post group activity
- //TODO: actually post a group activity
- */
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/233f733f/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
index 242bb43..2e47ba8 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
@@ -26,6 +26,8 @@ import javax.ws.rs.core.MediaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.usergrid.rest.test.resource2point0.endpoints.ApplicationsResource;
import org.apache.usergrid.rest.test.resource2point0.endpoints.OrganizationResource;
+import org.apache.usergrid.rest.test.resource2point0.model.Entity;
+import org.apache.usergrid.rest.test.resource2point0.model.Token;
import org.junit.ClassRule;
import org.junit.Rule;
@@ -133,4 +135,24 @@ public class AbstractRestIT extends JerseyTest {
assertEquals( expectedErrorMessage, errorJson.get( "error" ).asText() );
}
+
+ protected Token getAppUserToken(String username, String password){
+ Token payload = new Token();
+ payload.put("username", username);
+ payload.put("password", password);
+ payload.put("grant_type", "password");
+ return this.clientSetup.getRestClient().org(clientSetup.getOrganization().getName()).app(clientSetup.getAppName()).token().post(payload);
+ }
+
+ protected Token getAdminToken(String username, String password){
+ return this.clientSetup.getRestClient().management().token().post(
+ new Token(username, password)
+ );
+ }
+
+ protected Token getAdminToken(){
+ return this.clientSetup.getRestClient().management().token().post(
+ new Token(this.clientSetup.getUsername(),this.clientSetup.getUsername())
+ );
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/233f733f/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationsResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationsResource.java
index a08dff5..ef26508 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationsResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationsResource.java
@@ -43,4 +43,7 @@ public class ApplicationsResource extends CollectionEndpoint {
}
+ public TokenResource token() {
+ return new TokenResource(context,this);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/233f733f/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/OrganizationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/OrganizationResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/OrganizationResource.java
index 9834b6b..158b6ad 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/OrganizationResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/OrganizationResource.java
@@ -41,6 +41,10 @@ public class OrganizationResource extends NamedResource {
return new ApplicationsResource( app, context ,this );
}
+ public ApplicationsResource token(){
+ return new ApplicationsResource( "token", context ,this );
+ }
+
public void post(Map<String,String> organization) {
getResource().type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/233f733f/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/TokenResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/TokenResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/TokenResource.java
index 41c9f2a..3ae08c5 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/TokenResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/TokenResource.java
@@ -37,7 +37,7 @@ public class TokenResource extends NamedResource {
/**
- * Obtains an access token of type "application user"
+ * Obtains an access token
*
* @param token
* @return
[7/8] incubator-usergrid git commit: merge from two-o
Posted by sf...@apache.org.
merge from two-o
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/42da450b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/42da450b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/42da450b
Branch: refs/heads/USERGRID-291-User-Tests
Commit: 42da450b251f3b629a9a27c9fc667a140f8f2cea
Parents: 2a8391e e980398
Author: Shawn Feldman <sf...@apache.org>
Authored: Sun Dec 28 13:34:28 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Sun Dec 28 13:34:28 2014 -0700
----------------------------------------------------------------------
.../collection/groups/GroupResourceIT.java | 567 ++++++++++++-------
.../test/resource2point0/AbstractRestIT.java | 22 +-
.../endpoints/ApplicationsResource.java | 3 +
.../endpoints/OrganizationResource.java | 1 +
.../endpoints/TokenResource.java | 2 +-
.../rest/test/resource2point0/model/Entity.java | 8 +-
6 files changed, 378 insertions(+), 225 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/42da450b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
index a6c3152,2e47ba8..370823d
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
@@@ -24,8 -24,10 +24,9 @@@ import java.util.Arrays
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.usergrid.rest.test.resource2point0.endpoints.ApplicationsResource;
import org.apache.usergrid.rest.test.resource2point0.endpoints.OrganizationResource;
- import org.apache.usergrid.rest.test.resource2point0.model.Token;
+import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
+ import org.apache.usergrid.rest.test.resource2point0.model.Entity;
+ import org.apache.usergrid.rest.test.resource2point0.model.Token;
import org.junit.ClassRule;
import org.junit.Rule;
@@@ -114,24 -118,14 +115,18 @@@ public class AbstractRestIT extends Jer
}
- public void refreshIndex() {
- //TODO: add error checking and logging
- clientSetup.restClient.getResource().path( "/refreshindex" )
- .queryParam( "org_name", clientSetup.getOrganization().getName() )
- .queryParam( "app_name", clientSetup.getAppName() )
- .accept( MediaType.APPLICATION_JSON ).post();
+ protected ClientContext context(){
+ return this.clientSetup.getRestClient().getContext();
+ }
+ protected Token getAppUserToken(String username, String password){
+ return this.clientSetup.getRestClient().token().post(new Token(username,password));
+ }
+
- protected Token getAdminToken(){
- return this.clientSetup.getRestClient().management().token().post(
- new Token(this.clientSetup.getUsername(),this.clientSetup.getUsername())
- );
- }
-
+ public void refreshIndex() {
+ //TODO: add error checking and logging
+ clientSetup.refreshIndex();
}
@@@ -141,4 -135,24 +136,17 @@@
assertEquals( expectedErrorMessage, errorJson.get( "error" ).asText() );
}
+
- protected Token getAppUserToken(String username, String password){
- Token payload = new Token();
- payload.put("username", username);
- payload.put("password", password);
- payload.put("grant_type", "password");
- return this.clientSetup.getRestClient().org(clientSetup.getOrganization().getName()).app(clientSetup.getAppName()).token().post(payload);
- }
+
+ protected Token getAdminToken(String username, String password){
+ return this.clientSetup.getRestClient().management().token().post(
+ new Token(username, password)
+ );
+ }
+
+ protected Token getAdminToken(){
+ return this.clientSetup.getRestClient().management().token().post(
+ new Token(this.clientSetup.getUsername(),this.clientSetup.getUsername())
+ );
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/42da450b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationsResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationsResource.java
index 33225ce,ef26508..a52e55a
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationsResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationsResource.java
@@@ -44,8 -42,8 +44,11 @@@ public class ApplicationsResource exten
return new CollectionEndpoint(name,context,this);
}
+ public TokenResource token(){
+ return new TokenResource(context,this);
+ }
+ public TokenResource token() {
+ return new TokenResource(context,this);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/42da450b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/OrganizationResource.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/42da450b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/TokenResource.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/42da450b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
----------------------------------------------------------------------
[3/8] incubator-usergrid git commit: Merge branch 'two-dot-o' of
https://git-wip-us.apache.org/repos/asf/incubator-usergrid into
rodsimpson_usergrid/USERGRID-302
Posted by sf...@apache.org.
Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into rodsimpson_usergrid/USERGRID-302
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/f699a8d9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/f699a8d9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/f699a8d9
Branch: refs/heads/USERGRID-291-User-Tests
Commit: f699a8d9c8208f1721bde90fcaae450cc5832151
Parents: 118aa73 fa27c04
Author: Rod Simpson <ro...@apigee.com>
Authored: Mon Dec 22 14:13:02 2014 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Mon Dec 22 14:13:02 2014 -0700
----------------------------------------------------------------------
stack/core/.test-tdoe-5thread.log.swp | Bin 0 -> 28672 bytes
.../corepersistence/CpEntityDeleteListener.java | 101 -----
.../CpEntityIndexDeleteListener.java | 98 ----
.../corepersistence/CpEntityManager.java | 124 ++---
.../corepersistence/CpRelationManager.java | 35 +-
.../usergrid/corepersistence/CpSetup.java | 16 +-
.../usergrid/corepersistence/GuiceModule.java | 43 +-
.../HybridEntityManagerFactory.java | 4 +
.../events/EntityDeletedHandler.java | 68 +++
.../events/EntityVersionCreatedHandler.java | 69 +++
.../events/EntityVersionDeletedHandler.java | 102 +++++
.../results/FilteringLoader.java | 7 +-
.../CpEntityDeleteListenerTest.java | 91 ----
.../CpEntityIndexDeleteListenerTest.java | 111 -----
.../corepersistence/StaleIndexCleanupTest.java | 219 ++++++++-
.../corepersistence/TestGuiceModule.java | 9 +-
.../migration/GraphShardVersionMigrationIT.java | 5 +-
.../usergrid/persistence/CollectionIT.java | 15 +-
.../query/AbstractIteratingQueryIT.java | 2 +-
.../resources/usergrid-custom-test.properties | 3 +
.../collection/EntityCollectionManager.java | 13 +-
.../collection/EntityDeletedFactory.java | 34 ++
.../persistence/collection/EntitySet.java | 4 +-
.../collection/EntityVersionCleanupFactory.java | 35 ++
.../collection/EntityVersionCreatedFactory.java | 31 ++
.../persistence/collection/VersionSet.java | 22 +-
.../collection/event/EntityDeleted.java | 5 +-
.../collection/event/EntityVersionCreated.java | 14 +-
.../collection/event/EntityVersionDeleted.java | 11 +-
.../collection/guice/CollectionModule.java | 24 +-
.../collection/impl/CollectionScopeImpl.java | 4 +-
.../impl/EntityCollectionManagerImpl.java | 86 +++-
.../collection/impl/EntityDeletedTask.java | 148 ++++++
.../impl/EntityVersionCleanupTask.java | 224 +++++----
.../impl/EntityVersionCreatedTask.java | 122 +++++
.../mvcc/stage/delete/MarkCommit.java | 137 +++---
.../impl/EntityVersionSerializer.java | 3 -
.../collection/guice/TestCollectionModule.java | 4 -
.../impl/EntityVersionCleanupTaskTest.java | 450 ++++++++++++-------
.../impl/EntityVersionCreatedTaskTest.java | 244 ++++++++++
.../core/task/NamedTaskExecutorImpl.java | 141 +++++-
.../core/task/NamedTaskExecutorImplTest.java | 56 ++-
.../usergrid/persistence/index/EntityIndex.java | 20 +-
.../persistence/index/EntityIndexBatch.java | 7 +-
.../index/impl/EsEntityIndexBatchImpl.java | 9 +-
.../index/impl/EsEntityIndexImpl.java | 142 ++++--
.../persistence/index/impl/IndexingUtils.java | 105 +++--
.../apache/usergrid/rest/TestContextSetup.java | 6 +-
.../collection/DuplicateNameIT.java | 2 +-
.../rest/test/resource/TestContext.java | 3 +-
.../endpoints/CollectionEndpoint.java | 2 +-
51 files changed, 2162 insertions(+), 1068 deletions(-)
----------------------------------------------------------------------
[5/8] incubator-usergrid git commit: updated groups,
activity test failing due to problems in stack
Posted by sf...@apache.org.
updated groups, activity test failing due to problems in stack
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/f8aeed3f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/f8aeed3f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/f8aeed3f
Branch: refs/heads/USERGRID-291-User-Tests
Commit: f8aeed3ff920251566cb140e5b4aa072fff5f1c8
Parents: 233f733
Author: Rod Simpson <ro...@apigee.com>
Authored: Tue Dec 23 14:23:08 2014 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Tue Dec 23 14:23:08 2014 -0700
----------------------------------------------------------------------
.../collection/groups/GroupResourceIT.java | 141 ++++++++++++++-----
1 file changed, 102 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f8aeed3f/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 4afc51d..e0c271b 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
@@ -43,6 +43,11 @@ public class GroupResourceIT extends AbstractRestIT {
public GroupResourceIT() throws Exception { }
+ /***
+ *
+ * helper method to create a group
+ *
+ */
private Entity createGroup(String groupName, String groupPath) throws IOException{
Entity payload = new Entity();
payload.put("name", groupName);
@@ -54,6 +59,11 @@ public class GroupResourceIT extends AbstractRestIT {
return entity;
}
+ /***
+ *
+ * helper method to create a role
+ *
+ */
private Entity createRole(String roleName, String roleTitle) throws IOException{
Entity payload = new Entity();
payload.put("name", roleName);
@@ -65,6 +75,11 @@ public class GroupResourceIT extends AbstractRestIT {
return entity;
}
+ /***
+ *
+ * helper method to create an app level user
+ *
+ */
private Entity createUser(String username, String email, String password) throws IOException{
Entity payload = new Entity();
payload.put("username", username);
@@ -80,6 +95,7 @@ public class GroupResourceIT extends AbstractRestIT {
/***
*
* Verify that we can create a group with a standard string in the name and path
+ *
*/
@Test()
public void createGroupValidation() throws IOException {
@@ -93,8 +109,8 @@ public class GroupResourceIT extends AbstractRestIT {
/***
*
* Verify that we can create a group with a slash in the name and path
+ *
*/
-
@Test()
public void createGroupSlashInNameAndPathValidation() throws IOException {
@@ -107,8 +123,8 @@ public class GroupResourceIT extends AbstractRestIT {
/***
*
* Verify that we can create a group with a space in the name
+ *
*/
-
@Test()
public void createGroupSpaceInNameValidation() throws IOException {
@@ -121,8 +137,8 @@ public class GroupResourceIT extends AbstractRestIT {
/***
*
* Verify that we cannot create a group with a space in the path
+ *
*/
-
@Test()
public void createGroupSpaceInPathValidation() throws IOException {
@@ -142,6 +158,7 @@ public class GroupResourceIT extends AbstractRestIT {
/***
*
* Verify that we can create a group, change the name, then delete it
+ *
*/
@Test()
public void groupCRUDOperations() throws IOException {
@@ -184,6 +201,7 @@ public class GroupResourceIT extends AbstractRestIT {
/***
*
* Verify that we can create a group, user, add user to group, delete connection
+ *
*/
@Test()
public void addRemoveUserGroup() throws IOException {
@@ -231,6 +249,7 @@ public class GroupResourceIT extends AbstractRestIT {
/***
*
* Verify that we can create a group, role, add role to group, delete connection
+ *
*/
@Test
public void addRemoveRoleGroup() throws IOException {
@@ -293,19 +312,6 @@ public class GroupResourceIT extends AbstractRestIT {
*
* Verify that group / role permissions work
*
- * create group
- * create user
- * create role
- * add permissions to role (e.g. POST, GET on /cats)
- * add role to group
- * add user to group
- * delete default role (to ensure no app-level user operations are allowed)
- * delete guest role (to ensure no app-level user operations are allowed)
- * log the user in with
- * create a /cats/fluffy
- * read /cats/fluffy
- * update /cats/fluffy (should fail)
- * delete /cats/fluffy (should fail)
*/
@Test()
public void addRolePermissionToGroupVerifyPermission() throws IOException {
@@ -343,14 +349,10 @@ public class GroupResourceIT extends AbstractRestIT {
//7. delete the default role
this.app().collection("role").uniqueID("Default").delete();
- //8. delete the guest role
- this.app().collection("role").uniqueID("Guest").delete();
-
- //9. log user in, should then be using the app user's token not the admin token
+ //8. log user in, should then be using the app user's token not the admin token
this.getAppUserToken(username, password);
-
- //10. create a cat - permissions should allow this
+ //9. create a cat - permissions should allow this
String catName = "fluffy";
payload = new Entity();
payload.put("name", catName);
@@ -358,11 +360,11 @@ public class GroupResourceIT extends AbstractRestIT {
assertEquals(fluffy.get("name"), catName);
this.refreshIndex();
- //11. get the cat - permissions should allow this
+ //10. get the cat - permissions should allow this
fluffy = this.app().collection("cats").uniqueID(catName).get();
assertEquals(fluffy.get("name"), catName);
- //12. edit the cat - permissions should not allow this
+ //11. edit the cat - permissions should not allow this
fluffy.put("color", "brown");
try {
this.app().collection("cats").uniqueID(catName).put(fluffy);
@@ -373,7 +375,7 @@ public class GroupResourceIT extends AbstractRestIT {
assertEquals( "unauthorized", node.get( "error" ).textValue() );
}
- //13. delete the cat - permissions should not allow this
+ //12. delete the cat - permissions should not allow this
try {
this.app().collection("cats").uniqueID(catName).delete();
fail("permissions should not allow this");
@@ -389,8 +391,8 @@ public class GroupResourceIT extends AbstractRestIT {
/***
*
* Post a group activity
+ *
*/
-
@Test
public void postGroupActivity() throws IOException {
@@ -401,26 +403,40 @@ public class GroupResourceIT extends AbstractRestIT {
Entity group = this.createGroup(groupName, groupPath);
//2. create user 1
- String username = "fred";
- String email = "fred@usergrid.com";
+ String user1Username = "fred";
+ String user1Email = "fred@usergrid.com";
String password = "password";
- Entity user1 = this.createUser(username, email, password);
+ Entity user1 = this.createUser(user1Username, user1Email, password);
//3. create user 2
- username = "barney";
- email = "fred@usergrid.com";
+ String user2Username = "barney";
+ String user2Email = "barney@usergrid.com";
+ password = "password";
+ Entity user2 = this.createUser(user2Username, user2Email, password);
+
+ //4. create user 3
+ String user3Username = "wilma";
+ String user3Email = "wilma@usergrid.com";
password = "password";
- Entity user2 = this.createUser(username, email, password);
+ Entity user3 = this.createUser(user3Username, user3Email, password);
- //4. add user1 to the group
+ //5. add user1 to the group
Entity addUser1Response = this.app().collection("users").entity(user1).connection().collection("groups").entity(group).post();
assertEquals(addUser1Response.get("name"), groupName);
- //5. add user2 to the group
+ //6. add user2 to the group
Entity addUser2Response = this.app().collection("users").entity(user2).connection().collection("groups").entity(group).post();
assertEquals(addUser2Response.get("name"), groupName);
- //6. post an activity to the group
+ // 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.response.getEntityCount(), 2);
+
+
+ //8. post an activity to the group
//JSON should look like this:
//{'{"actor":{"displayName":"fdsafdsa","uuid":"2b70e83a-8a3f-11e4-9716-235107bcadb1","username":"fdsafdsa"},
// "verb":"post","content":"fdsafdsa"}'
@@ -432,17 +448,64 @@ public class GroupResourceIT extends AbstractRestIT {
activity.put("actor", payload);
activity.put("verb", "post");
activity.put("content", "content");
- Entity activityResponse = this.app().collection("users").post(activity);
+ Entity activityResponse = this.app().collection("groups").uniqueID(groupName).connection("activities").post(activity);
assertEquals(activityResponse.get("content"), "content");
- assertEquals(activityResponse, activity);
this.refreshIndex();
- //7. make sure the activity appears in the feed of user 1
+ //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);
- //8. make sure the activity appears in the feed of user 2
+ //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();
+ boolean found = false;
+ while (user1ActivityResponse.hasNext()) {
+ Entity tempActivity = user1ActivityResponse.next();
+ if (tempActivity.get("type").equals("activity") && tempActivity.get("content").equals("content")) {
+ found = true;
+ }
+ }
+ assertTrue(found);
+
+ //13. 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();
+ found = false;
+ while (user2ActivityResponse.hasNext()) {
+ Entity tempActivity = user2ActivityResponse.next();
+ if (tempActivity.get("type").equals("activity") && tempActivity.get("content").equals("content")) {
+ found = true;
+ }
+ }
+ assertTrue(found);
+
+ //15. 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();
+ found = false;
+ while (user3ActivityResponse.hasNext()) {
+ Entity tempActivity = user3ActivityResponse.next();
+ if (tempActivity.get("type").equals("activity") && tempActivity.get("content").equals("content")) {
+ found = true;
+ }
+ }
+ assertFalse(found);
}
[6/8] incubator-usergrid git commit: cleanup for groups test
Posted by sf...@apache.org.
cleanup for groups 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/e9803987
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e9803987
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e9803987
Branch: refs/heads/USERGRID-291-User-Tests
Commit: e98039870d141165ffd99860789184d8dcc0ce5e
Parents: f8aeed3
Author: Rod Simpson <ro...@apigee.com>
Authored: Tue Dec 23 15:12:04 2014 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Tue Dec 23 15:12:04 2014 -0700
----------------------------------------------------------------------
.../collection/groups/GroupResourceIT.java | 39 +++++++++-----------
.../endpoints/OrganizationResource.java | 3 --
2 files changed, 18 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e9803987/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 e0c271b..14f1863 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
@@ -18,15 +18,10 @@ package org.apache.usergrid.rest.applications.collection.groups;
import java.io.IOException;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
import java.util.NoSuchElementException;
-
import com.fasterxml.jackson.databind.JsonNode;
import com.sun.jersey.api.client.UniformInterfaceException;
import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
-import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
import org.apache.usergrid.rest.test.resource2point0.model.Collection;
import org.apache.usergrid.rest.test.resource2point0.model.Entity;
import org.junit.Test;
@@ -36,10 +31,14 @@ import org.apache.usergrid.cassandra.Concurrent;
import static org.junit.Assert.*;
-/** @author rockerston */
+/**
+ * @author rockerston
+ *
+ * REST tests for /groups endpoint
+ *
+ * */
@Concurrent()
public class GroupResourceIT extends AbstractRestIT {
- private static Logger log = LoggerFactory.getLogger( GroupResourceIT.class );
public GroupResourceIT() throws Exception { }
@@ -145,7 +144,7 @@ public class GroupResourceIT extends AbstractRestIT {
String groupName = "testgroup";
String groupSpacePath = "test group";
try {
- Entity group = this.createGroup(groupName, groupSpacePath);
+ this.createGroup(groupName, groupSpacePath);
fail("Should not be able to create a group with a space in the path");
} catch (UniformInterfaceException e) {
//verify the correct error was returned
@@ -281,11 +280,8 @@ public class GroupResourceIT extends AbstractRestIT {
//6. make sure the connection no longer exists
collection = this.app().collection("groups").entity(group).connection().collection("roles").get();
- try {
- collection.next();
+ if (collection.hasNext()) {
fail("Entity still exists");
- } catch (NoSuchElementException e) {
- //all good - there shouldn't be an element!
}
//7. check root roles to make sure role still exists
@@ -390,7 +386,7 @@ public class GroupResourceIT extends AbstractRestIT {
/***
*
- * Post a group activity
+ * Post a group activity and make sure it can be read back only by group members
*
*/
@Test
@@ -438,8 +434,8 @@ public class GroupResourceIT extends AbstractRestIT {
//8. post an activity to the group
//JSON should look like this:
- //{'{"actor":{"displayName":"fdsafdsa","uuid":"2b70e83a-8a3f-11e4-9716-235107bcadb1","username":"fdsafdsa"},
- // "verb":"post","content":"fdsafdsa"}'
+ //{'{"actor":{"displayName":"fred","uuid":"2b70e83a-8a3f-11e4-9716-235107bcadb1","username":"fred"},
+ // "verb":"post","content":"content"}'
Entity payload = new Entity();
payload.put("displayName", "fred");
payload.put("uuid", user1.get("uuid"));
@@ -447,21 +443,22 @@ public class GroupResourceIT extends AbstractRestIT {
Entity activity = new Entity();
activity.put("actor", payload);
activity.put("verb", "post");
- activity.put("content", "content");
+ String content = "content";
+ activity.put("content", content);
Entity activityResponse = this.app().collection("groups").uniqueID(groupName).connection("activities").post(activity);
- assertEquals(activityResponse.get("content"), "content");
+ 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);
@@ -473,7 +470,7 @@ public class GroupResourceIT extends AbstractRestIT {
boolean found = false;
while (user1ActivityResponse.hasNext()) {
Entity tempActivity = user1ActivityResponse.next();
- if (tempActivity.get("type").equals("activity") && tempActivity.get("content").equals("content")) {
+ if (tempActivity.get("type").equals("activity") && tempActivity.get("content").equals(content)) {
found = true;
}
}
@@ -487,7 +484,7 @@ public class GroupResourceIT extends AbstractRestIT {
found = false;
while (user2ActivityResponse.hasNext()) {
Entity tempActivity = user2ActivityResponse.next();
- if (tempActivity.get("type").equals("activity") && tempActivity.get("content").equals("content")) {
+ if (tempActivity.get("type").equals("activity") && tempActivity.get("content").equals(content)) {
found = true;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e9803987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/OrganizationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/OrganizationResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/OrganizationResource.java
index 158b6ad..f9f99fc 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/OrganizationResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/OrganizationResource.java
@@ -41,9 +41,6 @@ public class OrganizationResource extends NamedResource {
return new ApplicationsResource( app, context ,this );
}
- public ApplicationsResource token(){
- return new ApplicationsResource( "token", context ,this );
- }
public void post(Map<String,String> organization) {