You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2014/12/11 03:07:31 UTC
[1/3] incubator-usergrid git commit: Fixes OrganizationIT. Suffers
from same org->admin bug
Repository: incubator-usergrid
Updated Branches:
refs/heads/USERGRID-273 bb05616aa -> 31bb3f18d
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/USERGRID-273
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();
[3/3] incubator-usergrid git commit: Fixes TokenServiceIT and bug in
ManagementService counter test
Posted by to...@apache.org.
Fixes TokenServiceIT and bug in ManagementService counter 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/31bb3f18
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/31bb3f18
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/31bb3f18
Branch: refs/heads/USERGRID-273
Commit: 31bb3f18d358faa30ab451cfaf97aa78823d65fe
Parents: 2175834
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Dec 10 17:03:34 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Dec 10 17:03:34 2014 -0700
----------------------------------------------------------------------
.../cassandra/ManagementServiceIT.java | 5 ++-
.../security/tokens/TokenServiceIT.java | 40 ++++++++------------
.../usergrid/services/ServiceFactoryIT.java | 4 +-
3 files changed, 21 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/31bb3f18/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
index ddb2bbb..6957097 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
@@ -161,9 +161,10 @@ public class ManagementServiceIT {
Map<String, Long> counts = em.getApplicationCounters();
LOG.info( JsonUtils.mapToJsonString( counts ) );
LOG.info( JsonUtils.mapToJsonString( em.getCounterNames() ) );
- assertNotNull( counts.get( "admin_logins" ) );
- final long startCount = counts.get( "admin_logins" );
+ final Long existingCounts = counts.get( "admin_logins" );
+
+ final long startCount = existingCounts == null ? 0 : existingCounts;
setup.getMgmtSvc().countAdminUserAction( adminUser, "login" );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/31bb3f18/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java
index 49d939c..67bc035 100644
--- a/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java
@@ -20,6 +20,7 @@ package org.apache.usergrid.security.tokens;
import java.util.HashMap;
import java.util.Map;
+import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Rule;
@@ -27,6 +28,7 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.apache.usergrid.NewOrgAppAdminRule;
import org.apache.usergrid.ServiceITSetup;
import org.apache.usergrid.ServiceITSetupImpl;
import org.apache.usergrid.cassandra.CassandraResource;
@@ -73,15 +75,13 @@ public class TokenServiceIT {
public static ServiceITSetup setup = new ServiceITSetupImpl( cassandraResource, elasticSearchResource );
- @BeforeClass
- public static void setup() throws Exception {
- log.info( "in setup" );
- adminUser =
- setup.getMgmtSvc().createAdminUser( "edanuff34", "Ed Anuff", "ed@anuff34.com", "test", false, false );
- OrganizationInfo organization = setup.getMgmtSvc().createOrganization( "TokenServiceTestOrg", adminUser, true );
+ @Rule
+ public NewOrgAppAdminRule newOrgAppAdminRule = new NewOrgAppAdminRule( setup );
- // TODO update to organizationName/applicationName
- setup.getMgmtSvc().createApplication( organization.getUuid(), "TokenServiceTestOrg/ed-application" ).getId();
+ @Before
+ public void setup() throws Exception {
+ log.info( "in setup" );
+ adminUser = newOrgAppAdminRule.getAdminInfo();
}
@@ -91,8 +91,8 @@ public class TokenServiceIT {
Map<String, Object> data = new HashMap<String, Object>() {
{
- put( "email", "ed@anuff34.com" );
- put( "username", "edanuff34" );
+ put( "email", adminUser.getEmail());
+ put( "username", adminUser.getUsername());
}
};
@@ -106,8 +106,8 @@ public class TokenServiceIT {
long last_access = tokenInfo.getAccessed();
assertEquals( "email_confirm", tokenInfo.getType() );
- assertEquals( "ed@anuff34.com", tokenInfo.getState().get( "email" ) );
- assertEquals( "edanuff34", tokenInfo.getState().get( "username" ) );
+ assertEquals( adminUser.getEmail(), tokenInfo.getState().get( "email" ) );
+ assertEquals( adminUser.getUsername(), tokenInfo.getState().get( "username" ) );
tokenInfo = setup.getTokenSvc().getTokenInfo( tokenStr );
@@ -311,9 +311,7 @@ public class TokenServiceIT {
@Test
public void appDefaultExpiration() throws Exception {
- OrganizationOwnerInfo orgInfo =
- setup.getMgmtSvc().createOwnerAndOrganization( "foo", "foobar", "foobar", "foo@bar.com", "foobar" );
- ApplicationInfo appInfo = setup.getMgmtSvc().createApplication( orgInfo.getOrganization().getUuid(), "bar" );
+ ApplicationInfo appInfo = newOrgAppAdminRule.getApplicationInfo();
EntityManager em = setup.getEmf().getEntityManager( appInfo.getId() );
Application app = em.getApplication();
AuthPrincipalInfo userPrincipal =
@@ -328,11 +326,7 @@ public class TokenServiceIT {
@Test
public void appExpiration() throws Exception {
-
- OrganizationOwnerInfo orgInfo =
- setup.getMgmtSvc().createOwnerAndOrganization( "foo2", "foobar2", "foobar", "foo2@bar.com", "foobar" );
-
- ApplicationInfo appInfo = setup.getMgmtSvc().createApplication( orgInfo.getOrganization().getUuid(), "bar" );
+ ApplicationInfo appInfo = newOrgAppAdminRule.getApplicationInfo();
EntityManager em = setup.getEmf().getEntityManager( appInfo.getId() );
@@ -409,11 +403,7 @@ public class TokenServiceIT {
@Test
public void appExpirationInfinite() throws Exception {
-
- OrganizationOwnerInfo orgInfo = setup.getMgmtSvc().createOwnerAndOrganization( "appExpirationInfinite",
- "appExpirationInfinite", "foobar", "appExpirationInfinite@bar.com", "foobar" );
-
- ApplicationInfo appInfo = setup.getMgmtSvc().createApplication( orgInfo.getOrganization().getUuid(), "bar" );
+ ApplicationInfo appInfo = newOrgAppAdminRule.getApplicationInfo();
EntityManager em = setup.getEmf().getEntityManager( appInfo.getId() );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/31bb3f18/stack/services/src/test/java/org/apache/usergrid/services/ServiceFactoryIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/ServiceFactoryIT.java b/stack/services/src/test/java/org/apache/usergrid/services/ServiceFactoryIT.java
index 71152c9..e4e576f 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/ServiceFactoryIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/ServiceFactoryIT.java
@@ -26,6 +26,8 @@ import org.apache.usergrid.cassandra.Concurrent;
import org.apache.usergrid.services.simple.SimpleService;
+import static org.apache.usergrid.TestHelper.uniqueApp;
+import static org.apache.usergrid.TestHelper.uniqueOrg;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -40,7 +42,7 @@ public class ServiceFactoryIT extends AbstractServiceIT {
public void testPackagePrefixes() throws Exception {
logger.info( "test package prefixes" );
- UUID applicationId = setup.getEmf().createApplication( "org", "app" );
+ UUID applicationId = setup.getEmf().createApplication(uniqueOrg(), uniqueApp() );
ServiceManager sm = setup.getSmf().getServiceManager( applicationId );
Service service = sm.getService( "simple" );
assertEquals( "/simple", service.getServiceType() );
[2/3] incubator-usergrid git commit: Fixes FB test
Posted by to...@apache.org.
Fixes FB 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/21758341
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/21758341
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/21758341
Branch: refs/heads/USERGRID-273
Commit: 217583418a590ad5e99144dc2ee5c66438731655
Parents: 942b000
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Dec 10 16:46:48 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Dec 10 16:46:48 2014 -0700
----------------------------------------------------------------------
.../usergrid/security/providers/FacebookProviderIT.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21758341/stack/services/src/test/java/org/apache/usergrid/security/providers/FacebookProviderIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/security/providers/FacebookProviderIT.java b/stack/services/src/test/java/org/apache/usergrid/security/providers/FacebookProviderIT.java
index c78e348..90309bd 100644
--- a/stack/services/src/test/java/org/apache/usergrid/security/providers/FacebookProviderIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/security/providers/FacebookProviderIT.java
@@ -38,6 +38,9 @@ import org.apache.usergrid.persistence.entities.User;
import org.apache.usergrid.persistence.index.impl.ElasticSearchResource;
import org.apache.usergrid.utils.MapUtils;
+import static org.apache.usergrid.TestHelper.newUUIDString;
+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;
@@ -66,9 +69,9 @@ public class FacebookProviderIT {
public static void setup() throws Exception {
providerFactory = cassandraResource.getBean( SignInProviderFactory.class );
UserInfo adminUser = setup.getMgmtSvc()
- .createAdminUser( "fbuser", "Facebook User", "user@facebook.com", "test", false,
+ .createAdminUser( uniqueUsername(), "Facebook User", "user"+newUUIDString()+"@facebook.com", "test", false,
false );
- OrganizationInfo organization = setup.getMgmtSvc().createOrganization( "fb-organization", adminUser, true );
+ OrganizationInfo organization = setup.getMgmtSvc().createOrganization( uniqueOrg(), adminUser, true );
applicationId = setup.getMgmtSvc().createApplication( organization.getUuid(), "fb-application" ).getId();
}