This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push: new aec78be camel-box, revalidated ignored tests for BoxUsersManagerIntegrationTest aec78be is described below commit aec78be72ebcc758dda4ce086fa88148ca4933f4 Author: JiriOndrusek <jondr...@redhat.com> AuthorDate: Thu May 2 17:43:16 2019 +0200 camel-box, revalidated ignored tests for BoxUsersManagerIntegrationTest --- .../component/box/AbstractBoxTestSupport.java | 8 +- .../box/BoxUsersManagerIntegrationTest.java | 85 +++++++++++++++++----- .../src/test/resources/test-options.properties | 8 ++ 3 files changed, 83 insertions(+), 18 deletions(-) diff --git a/components/camel-box/camel-box-component/src/test/java/org/apache/camel/component/box/AbstractBoxTestSupport.java b/components/camel-box/camel-box-component/src/test/java/org/apache/camel/component/box/AbstractBoxTestSupport.java index ccec2d8..44a2c4a 100644 --- a/components/camel-box/camel-box-component/src/test/java/org/apache/camel/component/box/AbstractBoxTestSupport.java +++ b/components/camel-box/camel-box-component/src/test/java/org/apache/camel/component/box/AbstractBoxTestSupport.java @@ -37,6 +37,8 @@ public class AbstractBoxTestSupport extends CamelTestSupport { protected BoxFolder testFolder; protected BoxFile testFile; + protected boolean jwtAuthentoication; + protected Map<String, Object> options; @Override protected CamelContext createCamelContext() throws Exception { @@ -52,7 +54,7 @@ public class AbstractBoxTestSupport extends CamelTestSupport { e); } - Map<String, Object> options = new HashMap<>(); + options = new HashMap<>(); for (Map.Entry<Object, Object> entry : properties.entrySet()) { options.put(entry.getKey().toString(), entry.getValue()); } @@ -65,6 +67,10 @@ public class AbstractBoxTestSupport extends CamelTestSupport { component.setConfiguration(configuration); context.addComponent("box", component); + //initialize flag, whether is box configuration JWT + String authenticationType = properties.getProperty("authenticationType"); + jwtAuthentoication = !BoxConfiguration.STANDARD_AUTHENTICATION.equals(authenticationType); + return context; } diff --git a/components/camel-box/camel-box-component/src/test/java/org/apache/camel/component/box/BoxUsersManagerIntegrationTest.java b/components/camel-box/camel-box-component/src/test/java/org/apache/camel/component/box/BoxUsersManagerIntegrationTest.java index 0e13b0c..157b702 100644 --- a/components/camel-box/camel-box-component/src/test/java/org/apache/camel/component/box/BoxUsersManagerIntegrationTest.java +++ b/components/camel-box/camel-box-component/src/test/java/org/apache/camel/component/box/BoxUsersManagerIntegrationTest.java @@ -31,6 +31,7 @@ import org.apache.camel.component.box.api.BoxUsersManager; import org.apache.camel.component.box.internal.BoxApiCollection; import org.apache.camel.component.box.internal.BoxUsersManagerApiMethod; import org.junit.After; +import org.junit.Assume; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -50,9 +51,9 @@ public class BoxUsersManagerIntegrationTest extends AbstractBoxTestSupport { private static final String CAMEL_TEST_USER_JOB_TITLE = "Camel Tester"; private static final String CAMEL_TEST_CREATE_APP_USER_NAME = "Wilma"; private static final String CAMEL_TEST_CREATE_ENTERPRISE_USER_NAME = "fred"; - private static final String CAMEL_TEST_CREATE_ENTERPRISE_USER_LOGIN = "f...@example.com"; private static final String CAMEL_TEST_CREATE_ENTERPRISE_USER2_NAME = "gregory"; - private static final String CAMEL_TEST_CREATE_ENTERPRISE_USER2_LOGIN = "greg...@example.com"; + private static final String CAMEL_TEST_ENTERPRISE_USER_LOGIN_KEY = "enterpriseUser1Login"; + private static final String CAMEL_TEST_ENTERPRISE_USER2_LOGIN_KEY = "enterpriseUser2Login"; private BoxUser testUser; @@ -79,9 +80,11 @@ public class BoxUsersManagerIntegrationTest extends AbstractBoxTestSupport { } } - @Ignore //creation of app users could be used only with JWT authentication, which is not possible in this time @Test public void testCreateAppUser() throws Exception { + //This test makes sense only with JWT authentication. With standard (OAuth) it will always fail. + Assume.assumeTrue("Test has to be executed with standard authentication.", jwtAuthentoication); + com.box.sdk.BoxUser result = null; try { @@ -108,9 +111,18 @@ public class BoxUsersManagerIntegrationTest extends AbstractBoxTestSupport { } } - @Ignore //newly created user has to have unique and existing email address to be created. In manual execution, test could be un-ignored, but value for the "CamelBox.login" has to be changed. @Test public void testCreateEnterpriseUser() throws Exception { + //This test makes sense only with standard (OAuth) authentication, with JWT it will always fail with return code 403 + Assume.assumeFalse("Test has to be executed with standard authentication.", jwtAuthentoication); + + String enterpriseUser1Login = (String)options.get(CAMEL_TEST_ENTERPRISE_USER_LOGIN_KEY); + if (enterpriseUser1Login != null && "".equals(enterpriseUser1Login.trim())) { + enterpriseUser1Login = null; + } + + assertNotNull("Email for enterprise user has to be defined in test-options.properties for this test to succeed.", enterpriseUser1Login); + com.box.sdk.BoxUser result = null; try { @@ -119,7 +131,7 @@ public class BoxUsersManagerIntegrationTest extends AbstractBoxTestSupport { final Map<String, Object> headers = new HashMap<>(); // parameter type is String - headers.put("CamelBox.login", CAMEL_TEST_CREATE_ENTERPRISE_USER_LOGIN); + headers.put("CamelBox.login", enterpriseUser1Login); // parameter type is String headers.put("CamelBox.name", CAMEL_TEST_CREATE_ENTERPRISE_USER_NAME); // parameter type is com.box.sdk.CreateUserParams @@ -139,9 +151,11 @@ public class BoxUsersManagerIntegrationTest extends AbstractBoxTestSupport { } } - @Ignore //creation of app users could be used only with JWT authentication, which is not possible in this time @Test public void testDeleteUser() throws Exception { + //This test makes sense only with JWT authentication. With standard (OAuth) it will always fail. + Assume.assumeTrue("Test has to be executed with standard authentication.", jwtAuthentoication); + BoxUser.Info info = BoxUser.createAppUser(getConnection(), CAMEL_TEST_CREATE_APP_USER_NAME); final Map<String, Object> headers = new HashMap<>(); @@ -151,6 +165,8 @@ public class BoxUsersManagerIntegrationTest extends AbstractBoxTestSupport { headers.put("CamelBox.force", Boolean.FALSE); requestBodyAndHeaders("direct://DELETEUSER", null, headers); + //give some time to delete task to be finished + Thread.sleep(2000); Iterable<BoxUser.Info> it = BoxUser.getAllEnterpriseUsers(getConnection(), CAMEL_TEST_CREATE_APP_USER_NAME); int searchResults = sizeOfIterable(it); @@ -226,6 +242,9 @@ public class BoxUsersManagerIntegrationTest extends AbstractBoxTestSupport { @Test public void testUpdateUserInfo() throws Exception { + //This test makes sense only with standard (OAuth) authentication, with JWT it will always fail with return code 403 + Assume.assumeFalse("Test has to be executed with standard authentication.", jwtAuthentoication); + BoxUser.Info info = testUser.getInfo(); info.setJobTitle(CAMEL_TEST_USER_JOB_TITLE); @@ -245,21 +264,53 @@ public class BoxUsersManagerIntegrationTest extends AbstractBoxTestSupport { } } - @Ignore //newly created user has to have unique and existing email address to be created. In manual execution, test could be un-ignored, but values for emails have to be changed. + @Test public void testmMoveFolderToUser() throws Exception { - BoxUser.Info user1 = BoxUser.createEnterpriseUser(getConnection(), - CAMEL_TEST_CREATE_ENTERPRISE_USER_LOGIN, CAMEL_TEST_CREATE_ENTERPRISE_USER_NAME); - BoxUser.Info user2 = BoxUser.createEnterpriseUser(getConnection(), - CAMEL_TEST_CREATE_ENTERPRISE_USER2_LOGIN, CAMEL_TEST_CREATE_ENTERPRISE_USER2_NAME); + //This test makes sense only with standard (OAuth) authentication, with JWT it will always fail with return code 403 + Assume.assumeFalse("Test has to be executed with standard authentication.", jwtAuthentoication); - final Map<String, Object> headers = new HashMap<>(); - // parameter type is String - headers.put("CamelBox.userId", user1.getID()); - headers.put("CamelBox.sourceUserId", user2.getID()); + String enterpriseUser1Login = (String)options.get(CAMEL_TEST_ENTERPRISE_USER_LOGIN_KEY); + String enterpriseUser2Login = (String)options.get(CAMEL_TEST_ENTERPRISE_USER2_LOGIN_KEY); + if (enterpriseUser1Login != null && "".equals(enterpriseUser1Login.trim())) { + enterpriseUser1Login = null; + } + if (enterpriseUser2Login != null && "".equals(enterpriseUser2Login.trim())) { + enterpriseUser2Login = null; + } + + assertNotNull("Email for enterprise user has to be defined in test-options.properties for this test to succeed.", enterpriseUser1Login); + assertNotNull("Email for enterprise user2 has to be defined in test-options.properties for this test to succeed.", enterpriseUser2Login); + + BoxUser.Info user1 = null; + BoxUser.Info user2 = null; + try { + user1 = BoxUser.createEnterpriseUser(getConnection(), + enterpriseUser1Login, CAMEL_TEST_CREATE_ENTERPRISE_USER_NAME); + user2 = BoxUser.createEnterpriseUser(getConnection(), + enterpriseUser2Login, CAMEL_TEST_CREATE_ENTERPRISE_USER2_NAME); + + final Map<String, Object> headers = new HashMap<>(); + // parameter type is String + headers.put("CamelBox.userId", user1.getID()); + headers.put("CamelBox.sourceUserId", user2.getID()); - final com.box.sdk.BoxFolder.Info result = requestBodyAndHeaders("direct://MOVEFOLDERTOUSER", null, headers); - assertNotNull("moveFolderToUser result", result); + final com.box.sdk.BoxFolder.Info result = requestBodyAndHeaders("direct://MOVEFOLDERTOUSER", null, headers); + assertNotNull("moveFolderToUser result", result); + } finally { + if (user1 != null) { + try { + user1.getResource().delete(false, true); + } catch (Throwable t) { + } + } + if (user2 != null) { + try { + user2.getResource().delete(false, true); + } catch (Throwable t) { + } + } + } } @Override diff --git a/components/camel-box/camel-box-component/src/test/resources/test-options.properties b/components/camel-box/camel-box-component/src/test/resources/test-options.properties index 900a0f6..504f6bc 100644 --- a/components/camel-box/camel-box-component/src/test/resources/test-options.properties +++ b/components/camel-box/camel-box-component/src/test/resources/test-options.properties @@ -31,3 +31,11 @@ userPassword= ## Create a test Box.com application and provide its clientId and clientSecret clientId= clientSecret= + + +## Properties for BoxUsersManagerIntegrationTest (if stays blank, 2 tests from BoxUsersManagerIntegrationTest will fail, other will be fine) +## for creation of enterprise user, you has to fill existing unique email (which will receive notification email after creation of user) as a login +## for example: you can use gmail account with different suffix (after +) +## "[name]+1...@gmail.com", "[name]+2...@gmail.com" are unique and both notification emails will be delivered to "[name]@gmail.com" +enterpriseUser1Login= +enterpriseUser2Login=