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 2015/03/04 23:57:37 UTC
[13/50] [abbrv] incubator-usergrid git commit: [USERGRID-280] Added
testTestUserNeedsNoConfirmation,
this test currently does not pass but due to test account issues
[USERGRID-280] Added testTestUserNeedsNoConfirmation, this test currently does not pass but due to test account issues
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/a43954d1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/a43954d1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/a43954d1
Branch: refs/heads/USERGRID-405
Commit: a43954d11f180ca8d2790c91595593957b63e771
Parents: 5bdbc29
Author: grey <gr...@apigee.com>
Authored: Fri Feb 27 12:26:31 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Fri Feb 27 12:26:31 2015 -0800
----------------------------------------------------------------------
.../usergrid/rest/management/AdminUsersIT.java | 83 ++++++++++----------
1 file changed, 42 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a43954d1/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 130a1da..2aaf9de 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
@@ -60,6 +60,8 @@ import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_NOT
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_TEST_ACCOUNT_ADMIN_USER_EMAIL;
+import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_TEST_ACCOUNT_ADMIN_USER_PASSWORD;
import static org.apache.usergrid.utils.MapUtils.hashMap;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -326,53 +328,52 @@ public class AdminUsersIT extends AbstractRestIT {
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 {
-//
-// 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 testUserUsername = ( String ) setup.getMgmtSvc().getProperties()
-// .get( AccountCreationProps
-// .PROPERTIES_TEST_ACCOUNT_ADMIN_USER_EMAIL );
-//
-// String testUserPassword = ( String ) setup.getMgmtSvc().getProperties()
-// .get( AccountCreationProps
-// .PROPERTIES_TEST_ACCOUNT_ADMIN_USER_PASSWORD );
-//
-// // test user login should suceed despite confirmation setting
-// JsonNode node;
-// try {
-// node = mapper.readTree( resource().path( "/management/token" ).queryParam( "grant_type", "password" )
-// .queryParam( "username", testUserUsername ).queryParam( "password", testUserPassword )
-// .accept( MediaType.APPLICATION_JSON ).get( String.class ));
-// }
-// catch ( UniformInterfaceException e ) {
-// fail( "Test User should need no confirmation" );
-// }
-// }
-// finally {
-// setTestProperties( originalProperties );
-// }
-// }
-//
-//
+
+ /**
+ * Test that the test account doesn't need confirmation and is created automatically.
+ * @throws Exception
+ */
+ @Ignore("Test doesn't pass because the test account isn't getting correct instantiated")
+ @Test
+ public void testTestUserNeedsNoConfirmation() 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 testToken = management().token().post(
+ new Token( originalTestProperties.getAsString( PROPERTIES_TEST_ACCOUNT_ADMIN_USER_EMAIL ),
+ originalTestProperties.getAsString( PROPERTIES_TEST_ACCOUNT_ADMIN_USER_PASSWORD ) ));
+
+ assertNotNull( "We should have gotten a valid token back" ,testToken );
+ }finally{
+ clientSetup.getRestClient().testPropertiesResource().post( originalTestProperties );
+
+ }
+ }
+
+
private String getTokenFromMessage( Message msg ) throws IOException, MessagingException {
String body = ( ( MimeMultipart ) msg.getContent() ).getBodyPart( 0 ).getContent().toString();
return StringUtils.substringAfterLast( body, "token=" );