Merged 5.1-MC1 (5.1.0) to HEAD (5.1)

119047 adavis: Merged 5.1.N (5.1.1) to 5.1-MC1 (5.1.0)
      117329 adavis: Merged 5.0.2-CLOUD42 (Cloud ) to 5.1.N (5.1.1)
         117237 adavis: Merged 5.0.2-CLOUD (Cloud ) to 5.0.2-CLOUD42 (Cloud )
            114506 adavis: Merged BCRYPT to 5.0.2-CLOUD
               113723 gjames: Fixing up failing AuthenticationTest for MNT-14892


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@119885 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jean-Pierre Huynh
2015-12-10 09:57:56 +00:00
parent 31e8befadf
commit e7ad963bbc

View File

@@ -109,6 +109,8 @@ public class AuthenticationTest extends TestCase
private NodeRef typesNodeRef; private NodeRef typesNodeRef;
private NodeRef personAndyNodeRef; private NodeRef personAndyNodeRef;
private static char[] DONT_CARE_PASSWORD = "1 really don't care".toCharArray();
// TODO: pending replacement // TODO: pending replacement
private Dialect dialect; private Dialect dialect;
@@ -390,19 +392,19 @@ public class AuthenticationTest extends TestCase
public void testCreateUsers() public void testCreateUsers()
{ {
authenticationService.createAuthentication(AuthenticationUtil.getGuestUserName(), "".toCharArray()); authenticationService.createAuthentication(AuthenticationUtil.getGuestUserName(), DONT_CARE_PASSWORD);
authenticationService.authenticate(AuthenticationUtil.getGuestUserName(), "".toCharArray()); authenticationService.authenticate(AuthenticationUtil.getGuestUserName(),DONT_CARE_PASSWORD);
// Guest is treated like any other user // Guest is treated like any other user
assertEquals(AuthenticationUtil.getGuestUserName(), authenticationService.getCurrentUserName()); assertEquals(AuthenticationUtil.getGuestUserName(), authenticationService.getCurrentUserName());
authenticationService.createAuthentication("Andy", "".toCharArray()); authenticationService.createAuthentication("Andy", DONT_CARE_PASSWORD);
authenticationService.authenticate("Andy", "".toCharArray()); authenticationService.authenticate("Andy", DONT_CARE_PASSWORD);
assertEquals("Andy", authenticationService.getCurrentUserName()); assertEquals("Andy", authenticationService.getCurrentUserName());
if (! tenantService.isEnabled()) if (! tenantService.isEnabled())
{ {
authenticationService.createAuthentication("Mr.Woof.Banana@chocolate.chip.cookie.com", "".toCharArray()); authenticationService.createAuthentication("Mr.Woof.Banana@chocolate.chip.cookie.com", DONT_CARE_PASSWORD);
authenticationService.authenticate("Mr.Woof.Banana@chocolate.chip.cookie.com", "".toCharArray()); authenticationService.authenticate("Mr.Woof.Banana@chocolate.chip.cookie.com", DONT_CARE_PASSWORD);
assertEquals("Mr.Woof.Banana@chocolate.chip.cookie.com", authenticationService.getCurrentUserName()); assertEquals("Mr.Woof.Banana@chocolate.chip.cookie.com", authenticationService.getCurrentUserName());
} }
else else
@@ -410,12 +412,12 @@ public class AuthenticationTest extends TestCase
// TODO - could create tenant domain 'chocolate.chip.cookie.com' // TODO - could create tenant domain 'chocolate.chip.cookie.com'
} }
authenticationService.createAuthentication("Andy_Woof/Domain", "".toCharArray()); authenticationService.createAuthentication("Andy_Woof/Domain", DONT_CARE_PASSWORD);
authenticationService.authenticate("Andy_Woof/Domain", "".toCharArray()); authenticationService.authenticate("Andy_Woof/Domain", DONT_CARE_PASSWORD);
assertEquals("Andy_Woof/Domain", authenticationService.getCurrentUserName()); assertEquals("Andy_Woof/Domain", authenticationService.getCurrentUserName());
authenticationService.createAuthentication("Andy_ Woof/Domain", "".toCharArray()); authenticationService.createAuthentication("Andy_ Woof/Domain", DONT_CARE_PASSWORD);
authenticationService.authenticate("Andy_ Woof/Domain", "".toCharArray()); authenticationService.authenticate("Andy_ Woof/Domain", DONT_CARE_PASSWORD);
assertEquals("Andy_ Woof/Domain", authenticationService.getCurrentUserName()); assertEquals("Andy_ Woof/Domain", authenticationService.getCurrentUserName());
if (! tenantService.isEnabled()) if (! tenantService.isEnabled())
@@ -428,8 +430,8 @@ public class AuthenticationTest extends TestCase
un = "Andy `\u00ac\u00a6!\u00a3$%^&*()-_=+\t\n[]{};'#:@~,./<>?|"; un = "Andy `\u00ac\u00a6!\u00a3$%^&*()-_=+\t\n[]{};'#:@~,./<>?|";
} }
authenticationService.createAuthentication(un, "".toCharArray()); authenticationService.createAuthentication(un, DONT_CARE_PASSWORD);
authenticationService.authenticate(un, "".toCharArray()); authenticationService.authenticate(un, DONT_CARE_PASSWORD);
assertEquals(un, authenticationService.getCurrentUserName()); assertEquals(un, authenticationService.getCurrentUserName());
} }
else else
@@ -500,7 +502,7 @@ public class AuthenticationTest extends TestCase
assertTrue(AndyDetails.isCredentialsNonExpired()); assertTrue(AndyDetails.isCredentialsNonExpired());
assertTrue(AndyDetails.isEnabled()); assertTrue(AndyDetails.isEnabled());
assertNotSame("cabbage", AndyDetails.getPassword()); assertNotSame("cabbage", AndyDetails.getPassword());
assertEquals(AndyDetails.getPassword(), compositePasswordEncoder.encodePreferred("cabbage", null)); assertTrue(compositePasswordEncoder.matches(compositePasswordEncoder.getPreferredEncoding(),"cabbage", AndyDetails.getPassword(), null));
assertEquals(1, AndyDetails.getAuthorities().length); assertEquals(1, AndyDetails.getAuthorities().length);
// Object oldSalt = dao.getSalt(AndyDetails); // Object oldSalt = dao.getSalt(AndyDetails);
@@ -580,9 +582,9 @@ public class AuthenticationTest extends TestCase
public void testAuthentication() public void testAuthentication()
{ {
dao.createUser("GUEST", "".toCharArray()); dao.createUser("GUEST", DONT_CARE_PASSWORD);
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("GUEST", ""); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("GUEST", DONT_CARE_PASSWORD);
token.setAuthenticated(false); token.setAuthenticated(false);
Authentication result = authenticationManager.authenticate(token); Authentication result = authenticationManager.authenticate(token);
@@ -1133,8 +1135,8 @@ public class AuthenticationTest extends TestCase
public void testAuthenticationServiceGetNewTicket() public void testAuthenticationServiceGetNewTicket()
{ {
authenticationService.createAuthentication("GUEST", "".toCharArray()); authenticationService.createAuthentication("GUEST", DONT_CARE_PASSWORD);
authenticationService.authenticate("GUEST", "".toCharArray()); authenticationService.authenticate("GUEST", DONT_CARE_PASSWORD);
// create an authentication object e.g. the user // create an authentication object e.g. the user
authenticationService.createAuthentication("Andy", "auth1".toCharArray()); authenticationService.createAuthentication("Andy", "auth1".toCharArray());
@@ -1166,8 +1168,8 @@ public class AuthenticationTest extends TestCase
public void testAuthenticationService1() public void testAuthenticationService1()
{ {
authenticationService.createAuthentication("GUEST", "".toCharArray()); authenticationService.createAuthentication("GUEST", DONT_CARE_PASSWORD);
authenticationService.authenticate("GUEST", "".toCharArray()); authenticationService.authenticate("GUEST", DONT_CARE_PASSWORD);
// create an authentication object e.g. the user // create an authentication object e.g. the user
authenticationService.createAuthentication("Andy", "auth1".toCharArray()); authenticationService.createAuthentication("Andy", "auth1".toCharArray());
@@ -1202,8 +1204,8 @@ public class AuthenticationTest extends TestCase
public void testAuthenticationService2() public void testAuthenticationService2()
{ {
authenticationService.createAuthentication("GUEST", "".toCharArray()); authenticationService.createAuthentication("GUEST", DONT_CARE_PASSWORD);
authenticationService.authenticate("GUEST", "".toCharArray()); authenticationService.authenticate("GUEST", DONT_CARE_PASSWORD);
// create an authentication object e.g. the user // create an authentication object e.g. the user
authenticationService.createAuthentication("Andy", "auth1".toCharArray()); authenticationService.createAuthentication("Andy", "auth1".toCharArray());
@@ -1238,8 +1240,8 @@ public class AuthenticationTest extends TestCase
public void testAuthenticationService3() public void testAuthenticationService3()
{ {
authenticationService.createAuthentication("GUEST", "".toCharArray()); authenticationService.createAuthentication("GUEST", DONT_CARE_PASSWORD);
authenticationService.authenticate("GUEST", "".toCharArray()); authenticationService.authenticate("GUEST", DONT_CARE_PASSWORD);
// create an authentication object e.g. the user // create an authentication object e.g. the user
authenticationService.createAuthentication("Andy", "auth1".toCharArray()); authenticationService.createAuthentication("Andy", "auth1".toCharArray());
@@ -1285,8 +1287,8 @@ public class AuthenticationTest extends TestCase
public void testAuthenticationService4() public void testAuthenticationService4()
{ {
authenticationService.createAuthentication("GUEST", "".toCharArray()); authenticationService.createAuthentication("GUEST", DONT_CARE_PASSWORD);
authenticationService.authenticate("GUEST", "".toCharArray()); authenticationService.authenticate("GUEST", DONT_CARE_PASSWORD);
// create an authentication object e.g. the user // create an authentication object e.g. the user
authenticationService.createAuthentication("Andy", "auth1".toCharArray()); authenticationService.createAuthentication("Andy", "auth1".toCharArray());
@@ -1342,8 +1344,8 @@ public class AuthenticationTest extends TestCase
public void testAuthenticationService() public void testAuthenticationService()
{ {
authenticationService.createAuthentication("GUEST", "".toCharArray()); authenticationService.createAuthentication("GUEST", DONT_CARE_PASSWORD);
authenticationService.authenticate("GUEST", "".toCharArray()); authenticationService.authenticate("GUEST", DONT_CARE_PASSWORD);
// create an authentication object e.g. the user // create an authentication object e.g. the user
authenticationService.createAuthentication("Andy", "auth1".toCharArray()); authenticationService.createAuthentication("Andy", "auth1".toCharArray());
@@ -1402,8 +1404,8 @@ public class AuthenticationTest extends TestCase
public void testAuthenticationService0() public void testAuthenticationService0()
{ {
authenticationService.createAuthentication("GUEST", "".toCharArray()); authenticationService.createAuthentication("GUEST", DONT_CARE_PASSWORD);
authenticationService.authenticate("GUEST", "".toCharArray()); authenticationService.authenticate("GUEST", DONT_CARE_PASSWORD);
// create an authentication object e.g. the user // create an authentication object e.g. the user
authenticationService.createAuthentication("Andy", "auth1".toCharArray()); authenticationService.createAuthentication("Andy", "auth1".toCharArray());
@@ -1459,10 +1461,10 @@ public class AuthenticationTest extends TestCase
public void testPubAuthenticationService1() public void testPubAuthenticationService1()
{ {
authenticationComponent.setSystemUserAsCurrentUser(); authenticationComponent.setSystemUserAsCurrentUser();
pubAuthenticationService.createAuthentication("GUEST", "".toCharArray()); pubAuthenticationService.createAuthentication("GUEST", DONT_CARE_PASSWORD);
authenticationComponent.clearCurrentSecurityContext(); authenticationComponent.clearCurrentSecurityContext();
pubAuthenticationService.authenticate("GUEST", "".toCharArray()); pubAuthenticationService.authenticate("GUEST", DONT_CARE_PASSWORD);
// create an authentication object e.g. the user // create an authentication object e.g. the user
@@ -1507,10 +1509,10 @@ public class AuthenticationTest extends TestCase
public void testPubAuthenticationService2() public void testPubAuthenticationService2()
{ {
authenticationComponent.setSystemUserAsCurrentUser(); authenticationComponent.setSystemUserAsCurrentUser();
pubAuthenticationService.createAuthentication("GUEST", "".toCharArray()); pubAuthenticationService.createAuthentication("GUEST", DONT_CARE_PASSWORD);
authenticationComponent.clearCurrentSecurityContext(); authenticationComponent.clearCurrentSecurityContext();
pubAuthenticationService.authenticate("GUEST", "".toCharArray()); pubAuthenticationService.authenticate("GUEST", DONT_CARE_PASSWORD);
// create an authentication object e.g. the user // create an authentication object e.g. the user
@@ -1554,10 +1556,10 @@ public class AuthenticationTest extends TestCase
public void testPubAuthenticationService3() public void testPubAuthenticationService3()
{ {
authenticationComponent.setSystemUserAsCurrentUser(); authenticationComponent.setSystemUserAsCurrentUser();
pubAuthenticationService.createAuthentication("GUEST", "".toCharArray()); pubAuthenticationService.createAuthentication("GUEST", DONT_CARE_PASSWORD);
authenticationComponent.clearCurrentSecurityContext(); authenticationComponent.clearCurrentSecurityContext();
pubAuthenticationService.authenticate("GUEST", "".toCharArray()); pubAuthenticationService.authenticate("GUEST", DONT_CARE_PASSWORD);
// create an authentication object e.g. the user // create an authentication object e.g. the user
@@ -1619,12 +1621,12 @@ public class AuthenticationTest extends TestCase
assertNull(authenticationComponent.getCurrentAuthentication()); assertNull(authenticationComponent.getCurrentAuthentication());
authenticationComponent.setSystemUserAsCurrentUser(); authenticationComponent.setSystemUserAsCurrentUser();
pubAuthenticationService.createAuthentication("GUEST", "".toCharArray()); pubAuthenticationService.createAuthentication("GUEST", DONT_CARE_PASSWORD);
authenticationComponent.clearCurrentSecurityContext(); authenticationComponent.clearCurrentSecurityContext();
assertNull(authenticationComponent.getCurrentAuthentication()); assertNull(authenticationComponent.getCurrentAuthentication());
pubAuthenticationService.authenticate("GUEST", "".toCharArray()); pubAuthenticationService.authenticate("GUEST", DONT_CARE_PASSWORD);
pubAuthenticationService.authenticate("GUEST", "".toCharArray()); pubAuthenticationService.authenticate("GUEST", DONT_CARE_PASSWORD);
authenticationComponent.clearCurrentSecurityContext(); authenticationComponent.clearCurrentSecurityContext();
assertNull(authenticationComponent.getCurrentAuthentication()); assertNull(authenticationComponent.getCurrentAuthentication());
@@ -1680,12 +1682,12 @@ public class AuthenticationTest extends TestCase
assertNull(authenticationComponent.getCurrentAuthentication()); assertNull(authenticationComponent.getCurrentAuthentication());
authenticationComponent.setSystemUserAsCurrentUser(); authenticationComponent.setSystemUserAsCurrentUser();
pubAuthenticationService.createAuthentication("GUEST", "".toCharArray()); pubAuthenticationService.createAuthentication("GUEST", DONT_CARE_PASSWORD);
authenticationComponent.clearCurrentSecurityContext(); authenticationComponent.clearCurrentSecurityContext();
assertNull(authenticationComponent.getCurrentAuthentication()); assertNull(authenticationComponent.getCurrentAuthentication());
pubAuthenticationService.authenticate("GUEST", "".toCharArray()); pubAuthenticationService.authenticate("GUEST", DONT_CARE_PASSWORD);
pubAuthenticationService.authenticate("GUEST", "".toCharArray()); pubAuthenticationService.authenticate("GUEST", DONT_CARE_PASSWORD);
authenticationComponent.clearCurrentSecurityContext(); authenticationComponent.clearCurrentSecurityContext();
assertNull(authenticationComponent.getCurrentAuthentication()); assertNull(authenticationComponent.getCurrentAuthentication());