You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by fm...@apache.org on 2013/05/31 16:49:17 UTC

svn commit: r1488260 - in /syncope/trunk: ./ core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java

Author: fmartelli
Date: Fri May 31 14:49:16 2013
New Revision: 1488260

URL: http://svn.apache.org/r1488260
Log:
[SYNCOPE-383] merged from 1_1_X

Modified:
    syncope/trunk/   (props changed)
    syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java

Propchange: syncope/trunk/
------------------------------------------------------------------------------
  Merged /syncope/branches/1_1_X:r1487838-1488258

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java?rev=1488260&r1=1488259&r2=1488260&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java Fri May 31 14:49:16 2013
@@ -244,17 +244,12 @@ public class UserDataBinder extends Abst
 
         SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
 
-        // when requesting to add user to new resources, either directly or
-        // through role subscription, password is mandatory (issue 147)
-        // first, let's take current resources into account
         Set<String> currentResources = user.getResourceNames();
 
         // password
         if (StringUtils.isNotBlank(userMod.getPassword())) {
             setPassword(user, userMod.getPassword(), scce);
-
             user.setChangePwdDate(new Date());
-
             propByRes.addAll(ResourceOperation.UPDATE, currentResources);
         }
 
@@ -365,28 +360,6 @@ public class UserDataBinder extends Abst
             }
         }
 
-        // now, let's see if there are new resource subscriptions without providing password
-        if (StringUtils.isBlank(userMod.getPassword())) {
-            Set<String> updatedResources = user.getResourceNames();
-            updatedResources.removeAll(currentResources);
-
-            for (String resourceName : updatedResources) {
-                final ExternalResource resource = resourceDAO.find(resourceName);
-
-                if (!user.canDecodePassword() && resource != null && !resource.isRandomPwdIfNotProvided()
-                        && resource.getUmapping() != null && !MappingUtil.getMatchingMappingItems(
-                        resource.getUmapping().getItems(), "password", IntMappingType.Password).isEmpty()) {
-
-                    SyncopeClientException sce =
-                            new SyncopeClientException(SyncopeClientExceptionType.RequiredValuesMissing);
-                    sce.addElement("Password cannot be empty when subscribing to new resources");
-                    scce.addException(sce);
-
-                    throw scce;
-                }
-            }
-        }
-
         propByRes.addAll(ResourceOperation.DELETE, toBeDeprovisioned);
         propByRes.addAll(ResourceOperation.UPDATE, toBeProvisioned);
 

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=1488260&r1=1488259&r2=1488260&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 Fri May 31 14:49:16 2013
@@ -317,35 +317,6 @@ public class UserTestITCase extends Abst
     }
 
     @Test
-    public void issue147() {
-        // 1. create an user without role nor resources
-        UserTO userTO = getUniqueSampleTO("147@t.com");
-
-        userTO = createUser(userTO);
-        assertNotNull(userTO);
-        assertTrue(userTO.getResources().isEmpty());
-
-        // 2. try to update by adding a resource, but no password: must fail
-        UserMod userMod = new UserMod();
-        userMod.setId(userTO.getId());
-        userMod.addResourceToBeAdded("ws-target-resource-2");
-
-        SyncopeClientException sce = null;
-        try {
-            userService.update(userMod.getId(), userMod);
-        } catch (SyncopeClientCompositeErrorException scce) {
-            sce = scce.getException(SyncopeClientExceptionType.RequiredValuesMissing);
-        }
-        assertNotNull(sce);
-
-        // 3. provide password: now update must work
-        userMod.setPassword("newPassword");
-        userTO = userService.update(userMod.getId(), userMod);
-        assertNotNull(userTO);
-        assertEquals(1, userTO.getResources().size());
-    }
-
-    @Test
     public void createUserWithDbPropagation() {
         UserTO userTO = getUniqueSampleTO("yyy@yyy.yyy");
         userTO.addResource(RESOURCE_NAME_TESTDB);
@@ -2219,13 +2190,42 @@ public class UserTestITCase extends Abst
             assertNotNull(scce.getException(SyncopeClientExceptionType.NotFound));
         }
     }
-    
-        @Test
+
+    @Test
     public void issueSYNCOPE373() {
         UserTO userTO = userService.readSelf();
         assertEquals(ADMIN_UNAME, userTO.getUsername());
     }
 
+    @Test
+    public void issueSYNCOPE383() {
+        // 1. create user on testdb and testdb2
+        UserTO userTO = getUniqueSampleTO("syncope383@apache.org");
+        userTO.getResources().clear();
+        userTO = createUser(userTO);
+        assertNotNull(userTO);
+
+        // 2. assign resource without specifying a new pwd and check propagation failure
+        UserMod userMod = new UserMod();
+        userMod.setId(userTO.getId());
+        userMod.addResourceToBeAdded(RESOURCE_NAME_TESTDB);
+        userTO = userService.update(userMod.getId(), userMod);
+        assertEquals(RESOURCE_NAME_TESTDB, userTO.getResources().iterator().next());
+        assertFalse(userTO.getPropagationStatusTOs().get(0).getStatus().isSuccessful());
+
+        // 3. request to change password only on testdb
+        userMod = new UserMod();
+        userMod.setId(userTO.getId());
+        userMod.setPassword(getUUIDString());
+        PropagationRequestTO pwdPropRequest = new PropagationRequestTO();
+        pwdPropRequest.addResource(RESOURCE_NAME_TESTDB);
+        userMod.setPwdPropRequest(pwdPropRequest);
+
+        userTO = userService.update(userMod.getId(), userMod);
+        assertEquals(RESOURCE_NAME_TESTDB, userTO.getResources().iterator().next());
+        assertTrue(userTO.getPropagationStatusTOs().get(0).getStatus().isSuccessful());
+    }
+
     private boolean getBooleanAttribute(ConnObjectTO connObjectTO, String attrName) {
         return Boolean.parseBoolean(getStringAttribute(connObjectTO, attrName));
     }