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 2014/12/12 15:30:42 UTC

[43/50] [abbrv] incubator-usergrid git commit: Fixes OrganizationIT. Suffers from same org->admin bug

Fixes OrganizationIT.  Suffers from same org->admin bug


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

Branch: refs/heads/no-source-in-es
Commit: 942b000aca6eb0a4b65a66f49670cba426c7f608
Parents: bb05616
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Dec 10 16:43:41 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Dec 10 16:43:41 2014 -0700

----------------------------------------------------------------------
 .../cassandra/ManagementServiceImpl.java        |  2 --
 .../usergrid/management/OrganizationIT.java     | 23 ++++++++++++++------
 2 files changed, 16 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/942b000a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
index 34925b0..edea8fa 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
@@ -1179,7 +1179,6 @@ public class ManagementServiceImpl implements ManagementService {
 
         EntityManager em = emf.getEntityManager( smf.getManagementAppId() );
         User user = em.get( userId, User.class );
-        em.refreshIndex();
 
         CredentialsInfo newCredentials =
                 encryptionService.defaultEncryptedCredentials( newPassword, user.getUuid(), smf.getManagementAppId() );
@@ -1228,7 +1227,6 @@ public class ManagementServiceImpl implements ManagementService {
                 .plainTextCredentials( mongoPassword( ( String ) user.getProperty( "username" ), newPassword ),
                         user.getUuid(), smf.getManagementAppId() ) );
 
-        em.refreshIndex();
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/942b000a/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java b/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
index 92bb448..47718f0 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
@@ -26,6 +26,7 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 
+import org.apache.usergrid.NewOrgAppAdminRule;
 import org.apache.usergrid.ServiceITSetup;
 import org.apache.usergrid.ServiceITSetupImpl;
 import org.apache.usergrid.cassandra.CassandraResource;
@@ -36,6 +37,9 @@ import org.apache.usergrid.management.exceptions.RecentlyUsedPasswordException;
 import org.apache.usergrid.persistence.index.impl.ElasticSearchResource;
 import org.apache.usergrid.security.AuthPrincipalInfo;
 
+import static org.apache.usergrid.TestHelper.uniqueEmail;
+import static org.apache.usergrid.TestHelper.uniqueOrg;
+import static org.apache.usergrid.TestHelper.uniqueUsername;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
@@ -58,14 +62,17 @@ public class OrganizationIT {
     @ClassRule
     public static ServiceITSetup setup = new ServiceITSetupImpl( cassandraResource, elasticSearchResource );
 
+    @Rule
+    public NewOrgAppAdminRule newOrgAppAdminRule = new NewOrgAppAdminRule( setup );
+
 
     @Test
     public void testCreateOrganization() throws Exception {
         UserInfo user =
-                setup.getMgmtSvc().createAdminUser( "edanuff2", "Ed Anuff", "ed@anuff.com2", "test", false, false );
+                setup.getMgmtSvc().createAdminUser( uniqueUsername(), "Ed Anuff", uniqueEmail(), "test", false, false );
         assertNotNull( user );
 
-        OrganizationInfo organization = setup.getMgmtSvc().createOrganization( "OrganizationIT", user, false );
+        OrganizationInfo organization = setup.getMgmtSvc().createOrganization( uniqueOrg(), user, false );
         assertNotNull( organization );
 
         setup.getEmf().getEntityManager( setup.getSmf().getManagementAppId() ).refreshIndex();
@@ -108,7 +115,7 @@ public class OrganizationIT {
         assertEquals( user.getUuid(), principal.getUuid() );
 
         UserInfo new_user = setup.getMgmtSvc()
-                                 .createAdminUser( "test-user-133", "Test User", "test-user-133@mockserver.com",
+                                 .createAdminUser(uniqueUsername(), "Test User", uniqueEmail(),
                                          "testpassword", true, true );
         assertNotNull( new_user );
 
@@ -121,11 +128,13 @@ public class OrganizationIT {
 
         String[] passwords = new String[] { "password1", "password2", "password3", "password4", "password5" };
 
+
+
         UserInfo user = setup.getMgmtSvc()
-                             .createAdminUser( "edanuff3", "Ed Anuff", "ed2@anuff.com2", passwords[0], true, false );
+                             .createAdminUser( uniqueUsername(), "Ed Anuff", uniqueEmail(), passwords[0], true, false );
         assertNotNull( user );
 
-        OrganizationInfo organization = setup.getMgmtSvc().createOrganization( "OrganizationTest2", user, true );
+        OrganizationInfo organization = setup.getMgmtSvc().createOrganization( uniqueOrg(), user, true );
         assertNotNull( organization );
 
         setup.getEmf().getEntityManager( setup.getSmf().getManagementAppId() );
@@ -151,7 +160,7 @@ public class OrganizationIT {
         setup.getEmf().getEntityManager( setup.getSmf().getManagementAppId() );
 
         try {
-            setup.getMgmtSvc().setAdminUserPassword( user.getUuid(), passwords[2] );
+            setup.getMgmtSvc().setAdminUserPassword( user.getUuid(), passwords[3] );
             fail( "password change should fail" );
         }
         catch ( RecentlyUsedPasswordException e ) {
@@ -207,7 +216,7 @@ public class OrganizationIT {
         }
 
         // test history size w/ user belonging to 2 orgs
-        OrganizationInfo organization2 = setup.getMgmtSvc().createOrganization( "OrganizationTest3", user, false );
+        OrganizationInfo organization2 = setup.getMgmtSvc().createOrganization(uniqueOrg(), user, false );
         assertNotNull( organization2 );
 
         setup.getEmf().getEntityManager( setup.getSmf().getManagementAppId() ).refreshIndex();