usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [46/50] [abbrv] incubator-usergrid git commit: USERGRID-771
Date Fri, 24 Jul 2015 15:22:14 GMT
USERGRID-771


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

Branch: refs/heads/USERGRID-869
Commit: 6d45d876064fcd4b2da6043027f91b06c8edc38e
Parents: e85753c
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Wed Jul 22 12:06:26 2015 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Wed Jul 22 12:06:26 2015 -0600

----------------------------------------------------------------------
 .../usergrid/rest/management/AdminUsersIT.java  |  8 ++--
 .../rest/management/RegistrationIT.java         |  8 ++--
 .../management/AccountCreationProps.java        |  4 +-
 .../cassandra/ManagementServiceImpl.java        | 44 +++++++++++++++++---
 .../apache/usergrid/management/EmailFlowIT.java |  8 ++--
 5 files changed, 54 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6d45d876/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
index 2c086b8..b2af70c 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
@@ -48,7 +48,7 @@ import com.sun.jersey.api.representation.Form;
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_ADMIN_USERS_REQUIRE_CONFIRMATION;
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_SYSADMIN_APPROVES_ADMIN_USERS;
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_SYSADMIN_APPROVES_ORGANIZATIONS;
-import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_SYSADMIN_EMAIL;
+import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_DEFAULT_SYSADMIN_EMAIL;
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_TEST_ACCOUNT_ADMIN_USER_EMAIL;
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_TEST_ACCOUNT_ADMIN_USER_PASSWORD;
 import static org.junit.Assert.assertEquals;
@@ -216,7 +216,7 @@ public class AdminUsersIT extends AbstractRestIT {
             testPropertiesMap.put( PROPERTIES_SYSADMIN_APPROVES_ORGANIZATIONS, "false" );
             //Requires admins to do email confirmation before they can log in.
             testPropertiesMap.put( PROPERTIES_ADMIN_USERS_REQUIRE_CONFIRMATION, "true" );
-            testPropertiesMap.put( PROPERTIES_SYSADMIN_EMAIL, "sysadmin-1@mockserver.com"
);
+            testPropertiesMap.put( PROPERTIES_DEFAULT_SYSADMIN_EMAIL, "sysadmin-1@mockserver.com"
);
 
             Entity testPropertiesPayload = new Entity( testPropertiesMap );
 
@@ -661,7 +661,7 @@ public class AdminUsersIT extends AbstractRestIT {
             testPropertiesMap.put( PROPERTIES_SYSADMIN_APPROVES_ORGANIZATIONS, "false" );
             //Requires admins to do email confirmation before they can log in.
             testPropertiesMap.put( PROPERTIES_ADMIN_USERS_REQUIRE_CONFIRMATION, "true" );
-            testPropertiesMap.put( PROPERTIES_SYSADMIN_EMAIL, "sysadmin-1@mockserver.com"
);
+            testPropertiesMap.put( PROPERTIES_DEFAULT_SYSADMIN_EMAIL, "sysadmin-1@mockserver.com"
);
 
             Entity testPropertiesPayload = new Entity( testPropertiesMap );
 
@@ -673,7 +673,7 @@ public class AdminUsersIT extends AbstractRestIT {
             //Retrieve properties and ensure that they are set correctly.
             ApiResponse apiResponse = clientSetup.getRestClient().testPropertiesResource().get();
 
-            assertEquals( "sysadmin-1@mockserver.com", apiResponse.getProperties().get( PROPERTIES_SYSADMIN_EMAIL
) );
+            assertEquals( "sysadmin-1@mockserver.com", apiResponse.getProperties().get( PROPERTIES_DEFAULT_SYSADMIN_EMAIL
) );
             assertEquals( "true", apiResponse.getProperties().get( PROPERTIES_ADMIN_USERS_REQUIRE_CONFIRMATION
) );
             assertEquals( "false", apiResponse.getProperties().get( PROPERTIES_SYSADMIN_APPROVES_ORGANIZATIONS
) );
             assertEquals( "false", apiResponse.getProperties().get( PROPERTIES_SYSADMIN_APPROVES_ADMIN_USERS
) );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6d45d876/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
index bcaa521..52ade58 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
@@ -122,7 +122,7 @@ public class RegistrationIT extends AbstractRestIT {
             setTestProperty(PROPERTIES_SYSADMIN_APPROVES_ADMIN_USERS, "false");
             setTestProperty(PROPERTIES_SYSADMIN_APPROVES_ORGANIZATIONS, "false");
             setTestProperty(PROPERTIES_ADMIN_USERS_REQUIRE_CONFIRMATION, "false");
-            setTestProperty(PROPERTIES_SYSADMIN_EMAIL, "sysadmin-1@mockserver.com");
+            setTestProperty(PROPERTIES_DEFAULT_SYSADMIN_EMAIL, "sysadmin-1@mockserver.com");
 
             String t = this.getAdminToken().getAccessToken();
             Form form = new Form();
@@ -149,7 +149,7 @@ public class RegistrationIT extends AbstractRestIT {
             setTestProperty(PROPERTIES_SYSADMIN_APPROVES_ADMIN_USERS, "false");
             setTestProperty(PROPERTIES_SYSADMIN_APPROVES_ORGANIZATIONS, "false");
             setTestProperty(PROPERTIES_ADMIN_USERS_REQUIRE_CONFIRMATION, "false");
-            setTestProperty(PROPERTIES_SYSADMIN_EMAIL, "sysadmin-1@mockserver.com");
+            setTestProperty(PROPERTIES_DEFAULT_SYSADMIN_EMAIL, "sysadmin-1@mockserver.com");
 
             postAddAdminToOrg(this.clientSetup.getOrganizationName(), UUIDGenerator.newTimeUUID()+"@email.com",
"password");
         } finally {
@@ -172,7 +172,7 @@ public class RegistrationIT extends AbstractRestIT {
             setTestProperty(PROPERTIES_SYSADMIN_APPROVES_ADMIN_USERS, "false");
             setTestProperty(PROPERTIES_SYSADMIN_APPROVES_ORGANIZATIONS, "false");
             setTestProperty(PROPERTIES_ADMIN_USERS_REQUIRE_CONFIRMATION, "false");
-            setTestProperty(PROPERTIES_SYSADMIN_EMAIL, "sysadmin-1@mockserver.com");
+            setTestProperty(PROPERTIES_DEFAULT_SYSADMIN_EMAIL, "sysadmin-1@mockserver.com");
 
             // this should send resetpwd  link in email to newly added org admin user(that
did not exist
             ///in usergrid) and "User Invited To Organization" email
@@ -234,7 +234,7 @@ public class RegistrationIT extends AbstractRestIT {
             setTestProperty(PROPERTIES_SYSADMIN_APPROVES_ADMIN_USERS, "false");
             setTestProperty(PROPERTIES_SYSADMIN_APPROVES_ORGANIZATIONS, "false");
             setTestProperty(PROPERTIES_ADMIN_USERS_REQUIRE_CONFIRMATION, "false");
-            setTestProperty(PROPERTIES_SYSADMIN_EMAIL, "sysadmin-1@mockserver.com");
+            setTestProperty(PROPERTIES_DEFAULT_SYSADMIN_EMAIL, "sysadmin-1@mockserver.com");
 
             // svcSetup an admin user
             String adminUserName = "AdminUserFromOtherOrg";

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6d45d876/stack/services/src/main/java/org/apache/usergrid/management/AccountCreationProps.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/AccountCreationProps.java
b/stack/services/src/main/java/org/apache/usergrid/management/AccountCreationProps.java
index 6c000e2..e67271e 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/AccountCreationProps.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/AccountCreationProps.java
@@ -85,7 +85,9 @@ public interface AccountCreationProps {
     public static final String PROPERTIES_SYSADMIN_LOGIN_NAME = "usergrid.sysadmin.login.name";
     public static final String PROPERTIES_SYSADMIN_LOGIN_ALLOWED = "usergrid.sysadmin.login.allowed";
 
-    public static final String PROPERTIES_SYSADMIN_EMAIL = "usergrid.sysadmin.email";
+    public static final String PROPERTIES_ADMIN_SYSADMIN_EMAIL = "usergrid.admin.sysadmin.email";
+    public static final String PROPERTIES_ORG_SYSADMIN_EMAIL = "usergrid.org.sysadmin.email";
+    public static final String PROPERTIES_DEFAULT_SYSADMIN_EMAIL = "usergrid.sysadmin.email";
 
     public static final String PROPERTIES_TEST_ACCOUNT_ADMIN_USER_PASSWORD =
             "usergrid.test-account.admin-user.password";

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6d45d876/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 23ae892..95ace4d 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
@@ -114,7 +114,9 @@ import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_EMA
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_MAILER_EMAIL;
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_ORGANIZATION_ACTIVATION_URL;
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_SETUP_TEST_ACCOUNT;
-import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_SYSADMIN_EMAIL;
+import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_ORG_SYSADMIN_EMAIL;
+import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_ADMIN_SYSADMIN_EMAIL;
+import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_DEFAULT_SYSADMIN_EMAIL;
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_SYSADMIN_LOGIN_ALLOWED;
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_SYSADMIN_LOGIN_EMAIL;
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_SYSADMIN_LOGIN_NAME;
@@ -215,11 +217,11 @@ public class ManagementServiceImpl implements ManagementService {
     protected EncryptionService encryptionService;
 
 
+
     /** Must be constructed with a CassandraClientPool. */
     public ManagementServiceImpl() {
     }
 
-
     @Autowired
     public void setEntityManagerFactory( EntityManagerFactory emf ) {
         logger.info( "ManagementServiceImpl.setEntityManagerFactory" );
@@ -230,6 +232,33 @@ public class ManagementServiceImpl implements ManagementService {
     @Autowired
     public void setProperties( Properties properties ) {
         this.properties = new AccountCreationPropsImpl( properties );
+
+
+    }
+
+    String orgSysAdminEmail,defaultSysAdminEmail,adminSysAdminEmail;
+    private String getDefaultSysAdminEmail(){
+        defaultSysAdminEmail = defaultSysAdminEmail != null
+            ? defaultSysAdminEmail
+            : properties.getProperty(PROPERTIES_DEFAULT_SYSADMIN_EMAIL);
+        return defaultSysAdminEmail;
+    }
+    private String getOrgSystemEmail(){
+        if( orgSysAdminEmail != null ){
+            return orgSysAdminEmail;
+        }
+        orgSysAdminEmail =  properties.getProperty( PROPERTIES_ORG_SYSADMIN_EMAIL );
+        orgSysAdminEmail = orgSysAdminEmail!=null ? orgSysAdminEmail : getDefaultSysAdminEmail();
+        return orgSysAdminEmail;
+    }
+
+    private String getAdminSystemEmail(){
+        if( adminSysAdminEmail != null ){
+            return adminSysAdminEmail;
+        }
+        adminSysAdminEmail = properties.getProperty( PROPERTIES_ADMIN_SYSADMIN_EMAIL );
+        adminSysAdminEmail = adminSysAdminEmail!=null ? adminSysAdminEmail : getDefaultSysAdminEmail();
+        return adminSysAdminEmail;
     }
 
 
@@ -2258,7 +2287,8 @@ public class ManagementServiceImpl implements ManagementService {
             }
             if ( newOrganizationsNeedSysAdminApproval() ) {
                 logger.info( "sending SysAdminApproval confirmation email: {}", organization.getName()
);
-                sendHtmlMail( properties, properties.getProperty( PROPERTIES_SYSADMIN_EMAIL
),
+                //TODO: add org email approval
+                sendHtmlMail( properties, getOrgSystemEmail(),
                         properties.getProperty( PROPERTIES_MAILER_EMAIL ),
                         "Request For Organization Account Activation " + organization.getName(),
appendEmailFooter(
                         emailMsg( hashMap( "organization_name", organization.getName() )
@@ -2321,7 +2351,8 @@ public class ManagementServiceImpl implements ManagementService {
                 organization_owners = ( organization_owners == null ) ? user.getHTMLDisplayEmailAddress()
:
                                       organization_owners + ", " + user.getHTMLDisplayEmailAddress();
             }
-            sendHtmlMail( properties, properties.getProperty( PROPERTIES_SYSADMIN_EMAIL ),
+            //TODO: org email
+            sendHtmlMail( properties, getOrgSystemEmail(),
                     properties.getProperty( PROPERTIES_MAILER_EMAIL ),
                     "Organization Account Activated " + organization.getName(), appendEmailFooter(
emailMsg(
                     hashMap( "organization_name", organization.getName() )
@@ -2414,10 +2445,11 @@ public class ManagementServiceImpl implements ManagementService {
 
     public void sendSysAdminRequestAdminActivationEmail( UserInfo user ) throws Exception
{
         String token = getActivationTokenForAdminUser( user.getUuid(), 0 );
+        //TODO: admin specific email
         String activation_url =
                 String.format( properties.getProperty( PROPERTIES_ADMIN_ACTIVATION_URL ),
user.getUuid().toString() )
                         + "?token=" + token;
-        sendHtmlMail( properties, properties.getProperty( PROPERTIES_SYSADMIN_EMAIL ),
+        sendHtmlMail( properties, getAdminSystemEmail(),
                 properties.getProperty( PROPERTIES_MAILER_EMAIL ),
                 "Request For Admin User Account Activation " + user.getEmail(), appendEmailFooter(
                 emailMsg( hashMap( "user_email", user.getEmail() ).map( "activation_url",
activation_url ),
@@ -2427,7 +2459,7 @@ public class ManagementServiceImpl implements ManagementService {
 
     public void sendSysAdminNewAdminActivatedNotificationEmail( UserInfo user ) throws Exception
{
         if ( properties.notifySysAdminOfNewAdminUsers() ) {
-            sendHtmlMail( properties, properties.getProperty( PROPERTIES_SYSADMIN_EMAIL ),
+            sendHtmlMail( properties, getAdminSystemEmail(),
                     properties.getProperty( PROPERTIES_MAILER_EMAIL ),
                     "Admin User Account Activated " + user.getEmail(), appendEmailFooter(
                     emailMsg( hashMap( "user_email", user.getEmail() ), PROPERTIES_EMAIL_SYSADMIN_ADMIN_ACTIVATED
) ) );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6d45d876/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
b/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
index c19521f..2e94d57 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
@@ -73,7 +73,9 @@ import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_NOT
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_ORGANIZATIONS_REQUIRE_CONFIRMATION;
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_SYSADMIN_APPROVES_ADMIN_USERS;
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_SYSADMIN_APPROVES_ORGANIZATIONS;
-import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_SYSADMIN_EMAIL;
+import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_DEFAULT_SYSADMIN_EMAIL;
+import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_ADMIN_SYSADMIN_EMAIL;
+import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_ORG_SYSADMIN_EMAIL;
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_USER_ACTIVATION_URL;
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_USER_CONFIRMATION_URL;
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_USER_RESETPW_URL;
@@ -112,7 +114,7 @@ public class EmailFlowIT {
         setup.set( PROPERTIES_SYSADMIN_APPROVES_ADMIN_USERS, "false" );
         setup.set( PROPERTIES_SYSADMIN_APPROVES_ORGANIZATIONS, "false" );
         setup.set( PROPERTIES_ADMIN_USERS_REQUIRE_CONFIRMATION, "true" );
-        setup.set( PROPERTIES_SYSADMIN_EMAIL, "sysadmin-1@mockserver.com" );
+        setup.set( PROPERTIES_DEFAULT_SYSADMIN_EMAIL, "sysadmin-1@mockserver.com" );
         setup.set( PROPERTIES_NOTIFY_ADMIN_OF_ACTIVATION, "true" );
 
         final String orgName = uniqueOrg();
@@ -155,7 +157,7 @@ public class EmailFlowIT {
         setup.set( PROPERTIES_NOTIFY_ADMIN_OF_ACTIVATION, "true" );
         setup.set( PROPERTIES_SYSADMIN_APPROVES_ORGANIZATIONS, "false" );
         setup.set( PROPERTIES_ADMIN_USERS_REQUIRE_CONFIRMATION, "true" );
-        setup.set( PROPERTIES_SYSADMIN_EMAIL, "sysadmin-2@mockserver.com" );
+        setup.set( PROPERTIES_DEFAULT_SYSADMIN_EMAIL, "sysadmin-2@mockserver.com" );
 
         final String orgName = uniqueOrg();
         final String userName = uniqueUsername();


Mime
View raw message