protected String buildPassword(String uid) { return buildPassword(uid, false); }
@Override protected void cleanUp() throws Exception { if (provider != null) { provider.close(); } if (s != null) { s.logout(); } super.cleanUp(); }
protected Group getTestGroup(Session session) throws NotExecutableException, RepositoryException { for (Principal principal : getPrincipalSetFromSession(session)) { Authorizable auth = getUserManager(session).getAuthorizable(principal); if (auth != null && auth.isGroup()) { return (Group) auth; } } // may happen -> don't throw RepositoryException throw new NotExecutableException("No Group found."); } }
@Override protected void setUp() throws Exception { super.setUp(); impl = (UserManagerImpl) userMgr; }
@Override protected void tearDown() throws Exception { super.tearDown(); }
@Override protected void setUp() throws Exception { super.setUp(); try { userMgr = getUserManager(superuser); } catch (Exception e) { superuser.logout(); throw e; } }
protected Principal getTestPrincipal() throws RepositoryException { String pn = "any_principal" + UUID.randomUUID(); return getTestPrincipal(pn); }
@Override protected void setUp() throws Exception { super.setUp(); }
@Override protected void tearDown() throws Exception { // reset the actions setActions(null); super.tearDown(); }
/** * Conditional save if the userManager expects an extra save() call. * NOTE: only works if changes are made with UserManager affect the passed * session object (i.e. if the Session hold within the UserManager is * the same as the passes Session s. * * @param s * @throws RepositoryException */ protected static void save(Session s) throws RepositoryException, NotExecutableException { UserManager umgr = getUserManager(s); if (!umgr.isAutoSave() && s.hasPendingChanges()) { s.save(); } }
@Override protected void setUp() throws Exception { super.setUp(); if (!(userMgr instanceof UserManagerImpl)) { throw new NotExecutableException("UserManagerImpl expected -> cannot perform test."); } NameResolver resolver = (SessionImpl) superuser; pPrincipalName = resolver.getJCRName(UserConstants.P_PRINCIPAL_NAME); }
@Override protected void tearDown() throws Exception { principalProvider.close(); super.tearDown(); }
protected User getTestUser(Session session) throws NotExecutableException, RepositoryException { Authorizable auth = getUserManager(session).getAuthorizable(session.getUserID()); if (auth != null && !auth.isGroup()) { return (User) auth; } // should never happen. An Session should always have a corresponding User. throw new NotExecutableException("Unable to retrieve a User."); }
protected String buildPassword(Principal p) { return buildPassword(p.getName(), false); }
@Override protected void setUp() throws Exception { super.setUp(); if (superuser instanceof SessionImpl) { NameResolver resolver = (SessionImpl) superuser; protectedUserProps.add(resolver.getJCRName(UserConstants.P_PASSWORD)); protectedUserProps.add(resolver.getJCRName(UserConstants.P_IMPERSONATORS)); protectedUserProps.add(resolver.getJCRName(UserConstants.P_PRINCIPAL_NAME)); protectedUserProps.add(resolver.getJCRName(UserConstants.P_DISABLED)); protectedGroupProps.add(resolver.getJCRName(UserConstants.P_MEMBERS)); protectedGroupProps.add(resolver.getJCRName(UserConstants.P_PRINCIPAL_NAME)); } else { throw new NotExecutableException(); } }
@Override protected void tearDown() throws Exception { // remove all created groups again for (Authorizable createdGroup : createdGroups) { try { createdGroup.remove(); superuser.save(); } catch (RepositoryException e) { log.error("Failed to remove Group " + createdGroup.getID() + " during tearDown."); } } super.tearDown(); }
@Override protected void setUp() throws Exception { super.setUp(); Principal test = getTestPrincipal(); String pw = buildPassword(test); newUser = userMgr.createUser(test.getName(), pw); save(superuser); impersonation = newUser.getImpersonation(); }
@Override public void tearDown() throws Exception { for (Authorizable authorizable : authorizables) { if (!systemDefined.contains(authorizable)) { authorizable.remove(); } } authorizables.clear(); groups.clear(); users.clear(); if (!userMgr.isAutoSave()) { superuser.save(); } super.tearDown(); }
@Override protected void setUp() throws Exception { super.setUp(); if (!(userMgr instanceof UserManagerImpl)) { throw new NotExecutableException(); } UserManagerImpl umgr = (UserManagerImpl) userMgr; // Workaround for testing cache behaviour that relies on observation: // - retrieve session attached to the userManager implementation. // - using superuser will not work if users are stored in a different workspace. Authorizable a = umgr.getAuthorizable(getPrincipalSetFromSession(superuser).iterator().next()); Session s = ((AuthorizableImpl) a).getNode().getSession(); principalProvider = new DefaultPrincipalProvider(s, umgr); principalProvider.init(new Properties()); }
@Override protected void tearDown() throws Exception { // remove all created groups again for (Object createdUser : createdUsers) { Authorizable auth = (Authorizable) createdUser; try { auth.remove(); superuser.save(); } catch (RepositoryException e) { log.warn("Failed to remove User " + auth.getID() + " during tearDown."); } } super.tearDown(); }