syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1440441 - in /syncope/trunk/core/src/test/java/org/apache/syncope/core/rest: AbstractTest.java AuthenticationTestITCase.java RoleTestITCase.java SearchTestITCase.java TaskTestITCase.java UserRequestTestITCase.java UserTestITCase.java
Date Wed, 30 Jan 2013 14:56:06 GMT
Author: cschneider
Date: Wed Jan 30 14:56:05 2013
New Revision: 1440441

URL: http://svn.apache.org/viewvc?rev=1440441&view=rev
Log:
SYNCOPE-231 Fix error in cxf authentication

Modified:
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SearchTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserRequestTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java?rev=1440441&r1=1440440&r2=1440441&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java Wed Jan
30 14:56:05 2013
@@ -256,7 +256,7 @@ public abstract class AbstractTest {
     // END CXF Initialization
 
     @SuppressWarnings("unchecked")
-    public <T> T setupCredentials(final T proxy, final String username, final String
password) {
+    public <T> T setupCredentials(final T proxy, final Class<?> serviceInterface,
final String username, final String password) {
         if (proxy instanceof SpringServiceProxy) {
             SpringServiceProxy service = (SpringServiceProxy) proxy;
             if (username == null && password == null) {
@@ -268,8 +268,8 @@ public abstract class AbstractTest {
         } else {
             restClientFactory.setUsername(username);
             restClientFactory.setPassword(password);
-            restClientFactory.setServiceClass(proxy.getClass());
-            T serviceProxy = (T) restClientFactory.create(proxy.getClass());
+            restClientFactory.setServiceClass(serviceInterface);
+            T serviceProxy = (T) restClientFactory.create(serviceInterface);
             setupContentType(WebClient.client(serviceProxy));
             return serviceProxy;
         }

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java?rev=1440441&r1=1440440&r2=1440441&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java
(original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java
Wed Jan 30 14:56:05 2013
@@ -45,6 +45,7 @@ import org.apache.syncope.common.types.S
 import org.apache.syncope.common.types.SyncopeClientExceptionType;
 import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
 import org.apache.syncope.common.validation.SyncopeClientException;
+import org.apache.syncope.core.persistence.dao.InvalidSearchConditionException;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
 import org.junit.runners.MethodSorters;
@@ -110,7 +111,7 @@ public class AuthenticationTestITCase ex
         assertNotNull(schemaTO);
 
         // 4. read the schema created above (as user) - success
-        SchemaService schemaService2 = setupCredentials(schemaService, userTO.getUsername(),
"password123");
+        SchemaService schemaService2 = setupCredentials(schemaService, SchemaService.class,
userTO.getUsername(), "password123");
 
         schemaTO = schemaService2.read(AttributableType.USER, SchemaService.SchemaType.NORMAL,
"authTestSchema");
         assertNotNull(schemaTO);
@@ -150,12 +151,12 @@ public class AuthenticationTestITCase ex
         userTO = createUser(userTO);
         assertNotNull(userTO);
 
-        UserService userService2 = setupCredentials(userService, userTO.getUsername(), "password123");
+        UserService userService2 = setupCredentials(userService, UserService.class, userTO.getUsername(),
"password123");
 
         UserTO readUserTO = userService2.read(1L);
         assertNotNull(readUserTO);
 
-        UserService userService3 = setupCredentials(userService, "user2", ADMIN_PWD);
+        UserService userService3 = setupCredentials(userService, UserService.class, "user2",
ADMIN_PWD);
 
         SyncopeClientException exception = null;
         try {
@@ -171,7 +172,7 @@ public class AuthenticationTestITCase ex
     }
 
     @Test
-    public void testUserSearch() {
+    public void testUserSearch() throws InvalidSearchConditionException {
         UserTO userTO = UserTestITCase.getUniqueSampleTO("testusersearch@test.org");
 
         MembershipTO membershipTO = new MembershipTO();
@@ -185,7 +186,7 @@ public class AuthenticationTestITCase ex
         userTO = createUser(userTO);
         assertNotNull(userTO);
 
-        UserService userService2 = setupCredentials(userService, userTO.getUsername(), "password123");
+        UserService userService2 = setupCredentials(userService, UserService.class, userTO.getUsername(),
"password123");
 
         AttributeCond isNullCond = new AttributeCond(AttributeCond.Type.ISNOTNULL);
         isNullCond.setSchema("loginDate");
@@ -200,7 +201,7 @@ public class AuthenticationTestITCase ex
         }
         assertTrue(userIds.contains(1L));
 
-        UserService userService3 = setupCredentials(userService, "user2", "password");
+        UserService userService3 = setupCredentials(userService, UserService.class, "user2",
"password");
 
         matchedUsers = userService3.search(searchCondition);
 
@@ -232,7 +233,7 @@ public class AuthenticationTestITCase ex
         userTO = createUser(userTO);
         assertNotNull(userTO);
 
-        UserService userService2 = setupCredentials(userService, userTO.getUsername(), "password123");
+        UserService userService2 = setupCredentials(userService, UserService.class, userTO.getUsername(),
"password123");
 
         UserTO readUserTO = userService2.read(userTO.getId());
 
@@ -242,7 +243,7 @@ public class AuthenticationTestITCase ex
 
         // authentications failed ...
 
-        UserService userService3 = setupCredentials(userService, userTO.getUsername(), "wrongpwd1");
+        UserService userService3 = setupCredentials(userService, UserService.class, userTO.getUsername(),
"wrongpwd1");
 
         Throwable t = null;
 
@@ -271,7 +272,7 @@ public class AuthenticationTestITCase ex
         assertNotNull(readUserTO.getFailedLogins());
         assertEquals(Integer.valueOf(2), readUserTO.getFailedLogins());
 
-        UserService userService4 = setupCredentials(userService, userTO.getUsername(), "password123");
+        UserService userService4 = setupCredentials(userService, UserService.class, userTO.getUsername(),
"password123");
 
         readUserTO = userService4.read(userTO.getId());
         assertNotNull(readUserTO);
@@ -294,7 +295,7 @@ public class AuthenticationTestITCase ex
         userTO = createUser(userTO);
         assertNotNull(userTO);
 
-        UserService userService2 = setupCredentials(userService, userTO.getUsername(), "password123");
+        UserService userService2 = setupCredentials(userService, UserService.class, userTO.getUsername(),
"password123");
 
         userTO = userService2.read(userTO.getId());
 
@@ -304,7 +305,7 @@ public class AuthenticationTestITCase ex
 
         // authentications failed ...
 
-        UserService userService3 = setupCredentials(userService, userTO.getUsername(), "wrongpwd1");
+        UserService userService3 = setupCredentials(userService, UserService.class, userTO.getUsername(),
"wrongpwd1");
 
         Throwable t = null;
 
@@ -347,7 +348,7 @@ public class AuthenticationTestITCase ex
 
         // last authentication before suspension
         // TODO remove after CXF migration is complete
-        userService3 = setupCredentials(userService, userTO.getUsername(), "wrongpwd1");
+        userService3 = setupCredentials(userService, UserService.class, userTO.getUsername(),
"wrongpwd1");
 
         try {
             userService3.read(userTO.getId());
@@ -370,7 +371,7 @@ public class AuthenticationTestITCase ex
 
         // check for authentication
         // TODO remove after CXF migration is complete
-        userService2 = setupCredentials(userService, userTO.getUsername(), "password123");
+        userService2 = setupCredentials(userService, UserService.class, userTO.getUsername(),
"password123");
 
         try {
             userService2.read(userTO.getId());
@@ -391,7 +392,7 @@ public class AuthenticationTestITCase ex
         assertEquals("active", userTO.getStatus());
 
         // TODO remove after CXF migration is complete
-        userService2 = setupCredentials(userService, userTO.getUsername(), "password123");
+        userService2 = setupCredentials(userService, UserService.class, userTO.getUsername(),
"password123");
 
         userTO = userService2.read(userTO.getId());
 
@@ -431,7 +432,7 @@ public class AuthenticationTestITCase ex
         role1Admin = createUser(role1Admin);
         assertNotNull(role1Admin);
 
-        UserService userService2 = setupCredentials(userService, role1Admin.getUsername(),
"password");
+        UserService userService2 = setupCredentials(userService, UserService.class, role1Admin.getUsername(),
"password");
 
         // User with role 1, created by user with child role created above
         UserTO role1User = UserTestITCase.getUniqueSampleTO("syncope48user@apache.org");

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java?rev=1440441&r1=1440440&r2=1440441&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java Wed
Jan 30 14:56:05 2013
@@ -197,7 +197,7 @@ public class RoleTestITCase extends Abst
         assertTrue(userTO.getMembershipMap().containsKey(1L));
         assertFalse(userTO.getMembershipMap().containsKey(3L));
 
-        RoleService roleService2 = setupCredentials(roleService, "user1", ADMIN_PWD);
+        RoleService roleService2 = setupCredentials(roleService, RoleService.class, "user1",
ADMIN_PWD);
 
         SyncopeClientException exception = null;
         try {
@@ -303,7 +303,7 @@ public class RoleTestITCase extends Abst
         roleMod.setName("Managing Director");
 
         // 3. try to update as user3, not owner of role 7 - fail
-        RoleService roleService2 = setupCredentials(roleService, "user2", ADMIN_PWD);
+        RoleService roleService2 = setupCredentials(roleService, RoleService.class, "user2",
ADMIN_PWD);
 
         try {
             roleService2.update(roleMod.getId(), roleMod);
@@ -314,7 +314,7 @@ public class RoleTestITCase extends Abst
 
         // 4. update as user5, owner of role 7 because owner of role 6 with
         // inheritance - success
-        RoleService roleService3 = setupCredentials(roleService, "user5", ADMIN_PWD);
+        RoleService roleService3 = setupCredentials(roleService, RoleService.class, "user5",
ADMIN_PWD);
 
         roleTO = roleService3.update(roleMod.getId(), roleMod);
         assertEquals("Managing Director", roleTO.getName());

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SearchTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SearchTestITCase.java?rev=1440441&r1=1440440&r2=1440441&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SearchTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SearchTestITCase.java Wed
Jan 30 14:56:05 2013
@@ -34,6 +34,7 @@ import org.apache.syncope.common.search.
 import org.apache.syncope.common.search.ResourceCond;
 import org.apache.syncope.common.to.RoleTO;
 import org.apache.syncope.common.to.UserTO;
+import org.apache.syncope.core.persistence.dao.InvalidSearchConditionException;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
 import org.junit.runners.MethodSorters;
@@ -42,7 +43,7 @@ import org.junit.runners.MethodSorters;
 public class SearchTestITCase extends AbstractTest {
 
     @Test
-    public void searchUser() {
+    public void searchUser() throws InvalidSearchConditionException {
         // LIKE
         AttributeCond fullnameLeafCond1 = new AttributeCond(AttributeCond.Type.LIKE);
         fullnameLeafCond1.setSchema("fullname");
@@ -83,7 +84,7 @@ public class SearchTestITCase extends Ab
     }
 
     @Test
-    public void searchByUsernameAndId() {
+    public void searchByUsernameAndId() throws InvalidSearchConditionException {
         final AttributableCond usernameLeafCond = new AttributableCond(AttributableCond.Type.EQ);
         usernameLeafCond.setSchema("username");
         usernameLeafCond.setExpression("user1");
@@ -106,7 +107,7 @@ public class SearchTestITCase extends Ab
     }
 
     @Test
-    public void searchByRolenameAndId() {
+    public void searchByRolenameAndId() throws InvalidSearchConditionException {
         final AttributableCond rolenameLeafCond = new AttributableCond(AttributableCond.Type.EQ);
         rolenameLeafCond.setSchema("name");
         rolenameLeafCond.setExpression("root");
@@ -129,7 +130,7 @@ public class SearchTestITCase extends Ab
     }
 
     @Test
-    public void searchUserByResourceName() {
+    public void searchUserByResourceName() throws InvalidSearchConditionException {
         ResourceCond ws2 = new ResourceCond();
         ws2.setResourceName("ws-target-resource2");
 
@@ -154,7 +155,7 @@ public class SearchTestITCase extends Ab
     }
 
     @Test
-    public void paginatedSearch() {
+    public void paginatedSearch() throws InvalidSearchConditionException {
         // LIKE
         AttributeCond fullnameLeafCond1 = new AttributeCond(AttributeCond.Type.LIKE);
         fullnameLeafCond1.setSchema("fullname");
@@ -194,7 +195,7 @@ public class SearchTestITCase extends Ab
     }
 
     @Test
-    public void searchCount() {
+    public void searchCount() throws InvalidSearchConditionException {
         AttributeCond isNullCond = new AttributeCond(AttributeCond.Type.ISNULL);
         isNullCond.setSchema("loginDate");
         NodeCond searchCond = NodeCond.getLeafCond(isNullCond);
@@ -205,7 +206,7 @@ public class SearchTestITCase extends Ab
     }
 
     @Test
-    public void searchByBooleanAttributableCond() {
+    public void searchByBooleanAttributableCond() throws InvalidSearchConditionException
{
         final AttributableCond cond = new AttributableCond(AttributableCond.Type.EQ);
         cond.setSchema("inheritAttributes");
         cond.setExpression("true");
@@ -218,7 +219,7 @@ public class SearchTestITCase extends Ab
     }
 
     @Test
-    public void searchByEntitlement() {
+    public void searchByEntitlement() throws InvalidSearchConditionException {
         final EntitlementCond userListCond = new EntitlementCond();
         userListCond.setExpression("USER_LIST");
 
@@ -235,7 +236,7 @@ public class SearchTestITCase extends Ab
     }
 
     @Test
-    public void searchByRelationshipAttributableCond() {
+    public void searchByRelationshipAttributableCond() throws InvalidSearchConditionException
{
         final AttributableCond userOwnerCond = new AttributableCond(AttributableCond.Type.EQ);
         userOwnerCond.setSchema("userOwner");
         userOwnerCond.setExpression("5");

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java?rev=1440441&r1=1440440&r2=1440441&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java Wed
Jan 30 14:56:05 2013
@@ -51,6 +51,7 @@ import org.apache.syncope.common.types.I
 import org.apache.syncope.common.types.PropagationTaskExecStatus;
 import org.apache.syncope.common.types.TaskType;
 import org.apache.syncope.common.types.TraceLevel;
+import org.apache.syncope.core.persistence.dao.InvalidSearchConditionException;
 import org.apache.syncope.core.sync.TestSyncActions;
 import org.apache.syncope.core.sync.impl.SyncJob;
 import org.apache.syncope.core.workflow.ActivitiDetector;
@@ -362,7 +363,7 @@ public class TaskTestITCase extends Abst
     }
 
     @Test
-    public void reconcileFromLDAP() {
+    public void reconcileFromLDAP() throws InvalidSearchConditionException {
         // Update sync task
         SyncTaskTO task = taskService.read(TaskType.SYNCHRONIZATION, 11L);
         assertNotNull(task);

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserRequestTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserRequestTestITCase.java?rev=1440441&r1=1440440&r2=1440441&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserRequestTestITCase.java
(original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserRequestTestITCase.java
Wed Jan 30 14:56:05 2013
@@ -37,6 +37,7 @@ import org.apache.syncope.common.to.User
 import org.apache.syncope.common.to.UserTO;
 import org.apache.syncope.common.types.SyncopeClientExceptionType;
 import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.core.persistence.dao.InvalidSearchConditionException;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
 import org.junit.runners.MethodSorters;
@@ -47,7 +48,7 @@ import org.springframework.web.client.Ht
 public class UserRequestTestITCase extends AbstractTest {
 
     @Test
-    public void create() {
+    public void create() throws InvalidSearchConditionException {
         // 1. set create request not allowed
         ConfigurationTO configurationTO = new ConfigurationTO();
         configurationTO.setKey("createRequest.allowed");
@@ -79,7 +80,7 @@ public class UserRequestTestITCase exten
         assertNotNull(configurationTO);
 
         // 4. as anonymous, request user create works
-        UserRequestService userRequestService2 = setupCredentials(userRequestService, null,
null);
+        UserRequestService userRequestService2 = setupCredentials(userRequestService, UserRequestService.class,
null, null);
         response = userRequestService2.create(new UserRequestTO(userTO));
         UserRequestTO request = getObject(response, UserRequestTO.class, userRequestService2);
 
@@ -121,7 +122,7 @@ public class UserRequestTestITCase exten
         }
 
         // 3. auth as user just created
-        UserRequestService userRequestService2 = setupCredentials(userRequestService, userTO.getUsername(),
+        UserRequestService userRequestService2 = setupCredentials(userRequestService, UserRequestService.class,
userTO.getUsername(),
                 initialPassword);
 
         // 4. update with same password: not matching password policy
@@ -174,7 +175,7 @@ public class UserRequestTestITCase exten
         }
 
         // 3. auth as user just created
-        UserRequestService userRequestService2 = setupCredentials(userRequestService, userTO.getUsername(),
+        UserRequestService userRequestService2 = setupCredentials(userRequestService, UserRequestService.class,
userTO.getUsername(),
                 initialPassword);
 
         // 4. now request user delete works

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java?rev=1440441&r1=1440440&r2=1440441&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java Wed
Jan 30 14:56:05 2013
@@ -107,7 +107,7 @@ public class UserTestITCase extends Abst
 
     @Test
     public void selfRead() {
-        UserService userService2 = setupCredentials(userService, "user1", ADMIN_PWD);
+        UserService userService2 = setupCredentials(userService, UserService.class, "user1",
ADMIN_PWD);
 
         try {
             userService2.read(1L);
@@ -586,7 +586,7 @@ public class UserTestITCase extends Abst
         assertNull(form.getOwner());
 
         // 3. claim task from user1, not in role 7 (designated for approval in workflow definition):
fail
-        UserService userService2 = setupCredentials(userService, "user1", ADMIN_PWD);
+        UserService userService2 = setupCredentials(userService, UserService.class, "user1",
ADMIN_PWD);
 
         try {
             userService2.claimForm(form.getTaskId());
@@ -596,7 +596,7 @@ public class UserTestITCase extends Abst
         }
 
         // 4. claim task from user4, in role 7
-        UserService userService3 = setupCredentials(userService, "user4", ADMIN_PWD);
+        UserService userService3 = setupCredentials(userService, UserService.class, "user4",
ADMIN_PWD);
 
         form = userService3.claimForm(form.getTaskId());
         assertNotNull(form);



Mime
View raw message