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 2015/06/03 16:59:36 UTC

incubator-usergrid git commit: change token logic

Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o-dev b8c5643ab -> 429e1454a


change token logic


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

Branch: refs/heads/two-dot-o-dev
Commit: 429e1454a7b9b1ba8d99f9aa668e1de5bfad2616
Parents: b8c5643
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Jun 3 08:59:04 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Jun 3 08:59:04 2015 -0600

----------------------------------------------------------------------
 .../apache/usergrid/rest/NotificationsIT.java    | 19 ++++++++++---------
 .../rest/management/OrganizationsIT.java         |  3 +++
 .../rest/test/resource2point0/ClientSetup.java   |  5 ++---
 3 files changed, 15 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/429e1454/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
index 81daf88..474bb37 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
@@ -48,8 +48,6 @@ public class NotificationsIT extends org.apache.usergrid.rest.test.resource2poin
 
     final String org = "test-organization";
     final String app = "test-app";
-    final String orgapp = org + "/" + app;
-    String token;
 
     private static final long writeDelayMs = 15;
     private static final long readDelayMs = 15;
@@ -76,13 +74,8 @@ public class NotificationsIT extends org.apache.usergrid.rest.test.resource2poin
 
     @Test
     public void testPaging() throws Exception {
-
-        int numDevices = 2;
-        int numNotifications = 5; // to send to each device
-
-        User user = new User("ed","ed", "ed@anuff.com", "sesame" );
-        Entity entity = this.app().collection("users").post(user);
-        Token token = this.app().token().post(new Token("ed", "sesame"));
+        Token adminToken = clientSetup.getRestClient().management().token().post(Token.class, new Token( clientSetup.getUsername(), clientSetup.getPassword() ) );
+        clientSetup.getRestClient().management().token().setToken( adminToken );
 
         // create notifier
         Entity notifier = new Entity().chainPut("name", "mynotifier").chainPut("provider", "noop");
@@ -92,6 +85,14 @@ public class NotificationsIT extends org.apache.usergrid.rest.test.resource2poin
         //logger.debug("Notifier is: " + notifierNode.toString());
         assertEquals("noop", notifierNode.getResponse().getEntities().get(0).get("provider").toString());
 
+        int numDevices = 2;
+        int numNotifications = 5; // to send to each device
+
+        User user = new User("ed","ed", "ed@anuff.com", "sesame" );
+        Entity entity = this.app().collection("users").post(user);
+        Token token = this.app().token().post(new Token("ed", "sesame"));
+        this.clientSetup.getRestClient().token().setToken(token);
+
         this.refreshIndex();
 
         // create devices

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/429e1454/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
index 0fbf5ef..f9f8d39 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
@@ -60,6 +60,8 @@ public class OrganizationsIT extends AbstractRestIT {
     @Test
     public void createOrgAndOwner() throws Exception {
 
+        management().token().setToken(clientSetup.getSuperuserToken());
+
         //User property to see if owner properties exist when created.
         Map<String, Object> userProperties = new HashMap<String, Object>();
         userProperties.put( "company", "Apigee" );
@@ -277,6 +279,7 @@ public class OrganizationsIT extends AbstractRestIT {
         Token tokenReturned = clientSetup.getRestClient().management().token().post(Token.class, tokenPayload);
 
         assertNotNull( tokenReturned );
+        management().token().setToken(clientSetup.getSuperuserToken());
 
         //Assert that the get returns the correct org and owner.
         Organization returnedOrg = clientSetup.getRestClient().management().orgs().organization( organization.getOrganization() ).get();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/429e1454/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java
index 14a79e1..605e2e7 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java
@@ -101,8 +101,7 @@ public class ClientSetup implements TestRule {
 
         try {
             restClient.superuserSetup();
-            superuserToken = restClient.management().token().post(Token.class, new Token( superuserName, superuserPassword ) );
-            restClient.management().token().setToken( superuserToken );
+            superuserToken = restClient.management().token().get( superuserName, superuserPassword  );
         } catch ( Exception e ) {
             if ( logger.isDebugEnabled() ) {
                 logger.debug( "Error creating superuser, may already exist", e );
@@ -123,7 +122,7 @@ public class ClientSetup implements TestRule {
         clientCredentials = restClient.management().orgs().organization( orgName ).credentials().get();
         //refreshIndex();
 
-        //restClient.management().token().post(Token.class,new Token(username,password));
+        restClient.management().token().get(username,password);
 
         ApiResponse appResponse = restClient.management().orgs().organization(organization.getName()).app().post(new Application(appName));
         appUuid = ( String ) appResponse.getEntities().get( 0 ).get( "uuid" );