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/03/04 23:39:09 UTC
[14/38] incubator-usergrid git commit: Added testSystemAdmin needs no
confirmation test
Added testSystemAdmin needs no confirmation 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/5bdbc297
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/5bdbc297
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/5bdbc297
Branch: refs/heads/USERGRID-432
Commit: 5bdbc297a0bcc9f7c0bb247dc41b99f240a8ced5
Parents: 88fe906
Author: grey <gr...@apigee.com>
Authored: Fri Feb 27 11:56:09 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Fri Feb 27 11:56:09 2015 -0800
----------------------------------------------------------------------
.../usergrid/rest/management/AdminUsersIT.java | 72 ++++++++++----------
.../rest/test/resource2point0/ClientSetup.java | 13 +++-
2 files changed, 47 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5bdbc297/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 d2c86a9..130a1da 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
@@ -298,43 +298,41 @@ public class AdminUsersIT extends AbstractRestIT {
}
}
-//
-// @Test
-// public void testSystemAdminNeedsNoConfirmation() throws Exception {
-//
-// Map<String, String> originalProperties = getRemoteTestProperties();
-//
-// try {
-// // require comfirmation of new admin users
-// setTestProperty( PROPERTIES_SYSADMIN_APPROVES_ADMIN_USERS, "false" );
-// setTestProperty( PROPERTIES_SYSADMIN_APPROVES_ORGANIZATIONS, "false" );
-// setTestProperty( PROPERTIES_ADMIN_USERS_REQUIRE_CONFIRMATION, "true" );
-//
-// assertTrue( setup.getMgmtSvc().newAdminUsersRequireConfirmation() );
-// assertFalse( setup.getMgmtSvc().newAdminUsersNeedSysAdminApproval() );
-//
-// String sysadminUsername = ( String ) setup.getMgmtSvc().getProperties()
-// .get( AccountCreationProps.PROPERTIES_SYSADMIN_LOGIN_EMAIL );
-//
-// String sysadminPassword = ( String ) setup.getMgmtSvc().getProperties()
-// .get( AccountCreationProps.PROPERTIES_SYSADMIN_LOGIN_PASSWORD );
-//
-// // sysadmin login should suceed despite confirmation setting
-// JsonNode node;
-// try {
-// node = mapper.readTree( resource().path( "/management/token" ).queryParam( "grant_type", "password" )
-// .queryParam( "username", sysadminUsername ).queryParam( "password", sysadminPassword )
-// .accept( MediaType.APPLICATION_JSON ).get( String.class ));
-// }
-// catch ( UniformInterfaceException e ) {
-// fail( "Sysadmin should need no confirmation" );
-// }
-// }
-// finally {
-// setTestProperties( originalProperties );
-// }
-// }
-//
+
+ /**
+ * Test that the system admin doesn't need a confirmation email
+ * @throws Exception
+ */
+ @Test
+ public void testSystemAdminNeedsNoConfirmation() throws Exception{
+ //Save original properties to return them to normal at the end of the test
+ ApiResponse originalTestPropertiesResponse = clientSetup.getRestClient().testPropertiesResource().get();
+ Entity originalTestProperties = new Entity( originalTestPropertiesResponse );
+ try {
+ //Set runtime enviroment to the following settings
+ Map<String, Object> testPropertiesMap = new HashMap<>();
+
+ testPropertiesMap.put( PROPERTIES_SYSADMIN_APPROVES_ADMIN_USERS, "false" );
+ 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" );
+
+ Entity testPropertiesPayload = new Entity( testPropertiesMap );
+
+ //Send rest call to the /testProperties endpoint to persist property changes
+ clientSetup.getRestClient().testPropertiesResource().post( testPropertiesPayload );
+ refreshIndex();
+
+ Token superuserToken = management().token().post(
+ new Token( clientSetup.getSuperuserName(), clientSetup.getSuperuserPassword() ) );
+
+ assertNotNull( "We should have gotten a valid token back" ,superuserToken );
+ }finally{
+ clientSetup.getRestClient().testPropertiesResource().post( originalTestProperties );
+
+ }
+ }
+
//
// @Test
// public void testTestUserNeedsNoConfirmation() throws Exception {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5bdbc297/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 819cd85..55c10a3 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
@@ -47,6 +47,8 @@ public class ClientSetup implements TestRule {
protected String orgName;
protected String appName;
protected Token superuserToken;
+ protected String superuserName = "superuser";
+ protected String superuserPassword = "superpassword";
protected Organization organization;
protected Application application;
@@ -89,7 +91,7 @@ public class ClientSetup implements TestRule {
String name = testClass + "." + methodName;
restClient.superuserSetup();
- superuserToken = restClient.management().token().post( new Token( "superuser", "superpassword" ) );
+ superuserToken = restClient.management().token().post( new Token( superuserName, superuserPassword ) );
username = "user_"+name + UUIDUtils.newTimeUUID();
password = username;
@@ -118,6 +120,15 @@ public class ClientSetup implements TestRule {
return superuserToken;
}
+ public String getSuperuserName() {
+ return superuserName;
+ }
+
+
+ public String getSuperuserPassword() {
+ return superuserPassword;
+ }
+
public void refreshIndex() {
this.restClient.refreshIndex(getOrganizationName(),getAppName());
}