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/07/10 15:37:53 UTC
[47/50] [abbrv] incubator-usergrid git commit: Fixed basic auth and
added a test that makes sure we can now use application tokens
Fixed basic auth and added a test that makes sure we can now use application tokens
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/e1cdc736
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e1cdc736
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e1cdc736
Branch: refs/heads/two-dot-o-import
Commit: e1cdc73683fdcd01ffabc869b6ceb41df64869c6
Parents: ade2ece
Author: GERey <gr...@apigee.com>
Authored: Mon Jun 15 11:32:47 2015 -0700
Committer: GERey <gr...@apigee.com>
Committed: Mon Jun 15 11:32:47 2015 -0700
----------------------------------------------------------------------
.../applications/ApplicationResourceIT.java | 37 ++++++++++++++++++++
.../rest/test/resource2point0/RestClient.java | 2 ++
2 files changed, 39 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e1cdc736/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 671954b..104d436 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
@@ -23,6 +23,8 @@ import com.sun.jersey.api.client.UniformInterfaceException;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.representation.Form;
import org.apache.shiro.codec.Base64;
+
+import org.apache.usergrid.persistence.index.utils.UUIDUtils;
import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
import org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt.OrganizationResource;
import org.apache.usergrid.rest.test.resource2point0.model.*;
@@ -118,6 +120,41 @@ public class ApplicationResourceIT extends AbstractRestIT {
assertEquals(3, roles.getNumOfEntities());
}
+ /**
+ * Retrieve an collection using the application client credentials
+ */
+ @Test
+ public void applicationCollectionWithAppToken() throws Exception {
+
+ Credentials appCredentials = getAppCredentials();
+
+ QueryParameters queryParameters = new QueryParameters();
+ queryParameters.addParam("grant_type", "client_credentials");
+ queryParameters.addParam("client_id", appCredentials.getClientId());
+ queryParameters.addParam("client_secret", appCredentials.getClientSecret());
+
+ Entity testUser = new Entity( );
+ testUser.chainPut( "name","temp" ).chainPut( "password","temp1" );
+
+ Token appToken = this.app().token().post(new Token("client_credentials",appCredentials.getClientId(),appCredentials.getClientSecret() ));
+
+
+ //retrieve the credentials
+
+ //retrieve the app using only the org credentials
+ ApiResponse apiResponse = this.app().collection( "roles" ).getResource( true, appToken )
+ .accept( MediaType.APPLICATION_JSON )
+ .type(MediaType.APPLICATION_JSON_TYPE)
+ .get(ApiResponse.class);
+ //assert that a valid response is returned without error
+ assertNotNull(apiResponse);
+ assertNull(apiResponse.getError());
+
+ Collection roles = new Collection(apiResponse);
+ //assert that we have the correct number of default roles
+ assertEquals(3, roles.getNumOfEntities());
+ }
+
/**
* Verifies that we return JSON even when no accept header is specified.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e1cdc736/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
index ed7057f..0cfeb40 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
@@ -115,6 +115,8 @@ public class RestClient implements UrlResource {
this.getResource().path( "system/superuser/setup" )
.accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON ).get( JsonNode.class );
+
+ client.removeFilter( httpBasicAuthFilter );
}
//todo:fix this method for the client.