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:37 UTC
[38/50] [abbrv] incubator-usergrid git commit: Fixes
ManagementServiceIT
Fixes ManagementServiceIT
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/7ffe1ac7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/7ffe1ac7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/7ffe1ac7
Branch: refs/heads/no-source-in-es
Commit: 7ffe1ac7a5a91bd6c603124953a33519e729c683
Parents: cfff0cc
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Dec 10 13:13:45 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Dec 10 13:13:45 2014 -0700
----------------------------------------------------------------------
.../cassandra/ManagementServiceIT.java | 79 +++++++++++++-------
1 file changed, 52 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7ffe1ac7/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 4288d99..14a34b4 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
@@ -22,6 +22,7 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
+import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Ignore;
@@ -30,6 +31,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;
@@ -52,6 +54,7 @@ import org.apache.usergrid.utils.JsonUtils;
import org.apache.usergrid.utils.UUIDUtils;
import static org.apache.commons.codec.binary.Base64.encodeBase64URLSafeString;
+import static org.apache.usergrid.UUIDTestHelper.newUUIDString;
import static org.apache.usergrid.persistence.Schema.DICTIONARY_CREDENTIALS;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -66,33 +69,43 @@ import static org.junit.Assert.assertTrue;
public class ManagementServiceIT {
private static final Logger LOG = LoggerFactory.getLogger( ManagementServiceIT.class );
+
@ClassRule
public static CassandraResource cassandraResource = CassandraResource.newWithAvailablePorts();
+
@ClassRule
public static ElasticSearchResource elasticSearchResource = new ElasticSearchResource();
- // app-level data generated only once
- private static UserInfo adminUser;
- private static OrganizationInfo organization;
- private static UUID applicationId;
+ @ClassRule
+ public static final ServiceITSetup setup = new ServiceITSetupImpl( cassandraResource, elasticSearchResource );
+
@Rule
public ClearShiroSubject clearShiroSubject = new ClearShiroSubject();
- @ClassRule
- public static final ServiceITSetup setup = new ServiceITSetupImpl( cassandraResource, elasticSearchResource );
+ @Rule
+ public NewOrgAppAdminRule orgAppAdminRule = new NewOrgAppAdminRule( setup );
+
+
+ // app-level data generated only once
+ private UserInfo adminUser;
+ private UUID applicationId;
- @BeforeClass
- public static void setup() throws Exception {
+ @Before
+ public void setup() throws Exception {
LOG.info( "in setup" );
- adminUser = setup.getMgmtSvc().createAdminUser( "edanuff", "Ed Anuff", "ed@anuff.com", "test", false, false );
- organization = setup.getMgmtSvc().createOrganization( "ed-organization", adminUser, true );
- applicationId = setup.getMgmtSvc().createApplication( organization.getUuid(), "ed-application" ).getId();
+
+
+ adminUser = orgAppAdminRule.getAdminInfo();
+ applicationId = orgAppAdminRule.getApplicationInfo().getId();
+
+ setup.getEmf().refreshIndex();
}
+
@Test
public void testGetTokenForPrincipalAdmin() throws Exception {
String token = ( ( ManagementServiceImpl ) setup.getMgmtSvc() )
@@ -140,15 +153,27 @@ public class ManagementServiceIT {
batcher.setBlockingSubmit( true );
batcher.setBatchSize( 1 );
- setup.getMgmtSvc().countAdminUserAction( adminUser, "login" );
-
EntityManager em = setup.getEmf().getEntityManager( setup.getEmf().getManagementAppId() );
Map<String, Long> counts = em.getApplicationCounters();
LOG.info( JsonUtils.mapToJsonString( counts ) );
LOG.info( JsonUtils.mapToJsonString( em.getCounterNames() ) );
assertNotNull( counts.get( "admin_logins" ) );
- assertEquals( 1, counts.get( "admin_logins" ).intValue() );
+
+ final long startCount = counts.get( "admin_logins" );
+
+
+ setup.getMgmtSvc().countAdminUserAction( adminUser, "login" );
+
+
+ counts = em.getApplicationCounters();
+ LOG.info( JsonUtils.mapToJsonString( counts ) );
+ LOG.info( JsonUtils.mapToJsonString( em.getCounterNames() ) );
+ assertNotNull( counts.get( "admin_logins" ) );
+
+ final long newCount = counts.get( "admin_logins" );
+
+ assertEquals( 1l, newCount - startCount );
}
@@ -461,11 +486,11 @@ public class ManagementServiceIT {
@Test
public void authenticateAdmin() throws Exception {
- String username = "tnine";
+ String username = "tnine"+newUUIDString();
String password = "test";
UserInfo adminUser = setup.getMgmtSvc()
- .createAdminUser( username, "Todd Nine", UUID.randomUUID() + "@apigee.com", password,
+ .createAdminUser( username, "Todd Nine", newUUIDString() + "@apigee.com", password,
false, false );
EntityManager em = setup.getEmf().getEntityManager( setup.getSmf().getManagementAppId() );
@@ -490,7 +515,7 @@ public class ManagementServiceIT {
*/
@Test
public void testAdminPasswordChangeShaType() throws Exception {
- String username = "testAdminPasswordChangeShaType";
+ String username = "testAdminPasswordChangeShaType"+newUUIDString();
String password = "test";
@@ -547,7 +572,7 @@ public class ManagementServiceIT {
*/
@Test
public void testAdminPasswordChangeMd5ShaType() throws Exception {
- String username = "testAdminPasswordChangeMd5ShaType";
+ String username = "testAdminPasswordChangeMd5ShaType"+newUUIDString();
String password = "test";
@@ -610,10 +635,10 @@ public class ManagementServiceIT {
@Test
public void authenticateUser() throws Exception {
- String username = "tnine";
+ String username = "tnine"+newUUIDString();
String password = "test";
- String orgName = "autneticateUser";
- String appName = "authenticateUser";
+ String orgName = "autneticateUser"+newUUIDString();
+ String appName = "authenticateUser"+newUUIDString();
UUID appId = setup.getEmf().createApplication( orgName, appName );
@@ -654,10 +679,10 @@ public class ManagementServiceIT {
*/
@Test
public void testAppUserPasswordChangeShaType() throws Exception {
- String username = "tnine";
+ String username = "tnine"+newUUIDString();
String password = "test";
- String orgName = "testAppUserPasswordChangeShaType";
- String appName = "testAppUserPasswordChangeShaType";
+ String orgName = "testAppUserPasswordChangeShaType"+newUUIDString();
+ String appName = "testAppUserPasswordChangeShaType"+newUUIDString();
UUID appId = setup.getEmf().createApplication( orgName, appName );
@@ -713,10 +738,10 @@ public class ManagementServiceIT {
*/
@Test
public void testAppUserPasswordChangeMd5ShaType() throws Exception {
- String username = "tnine";
+ String username = "tnine"+newUUIDString();
String password = "test";
- String orgName = "testAppUserPasswordChangeMd5ShaType";
- String appName = "testAppUserPasswordChangeMd5ShaType";
+ String orgName = "testAppUserPasswordChangeMd5ShaType"+newUUIDString();
+ String appName = "testAppUserPasswordChangeMd5ShaType"+newUUIDString();
UUID appId = setup.getEmf().createApplication( orgName, appName );