@Test public void testSecureJCRFoldersMigration() throws Exception { NodeHierarchyCreator nodeHierarchyCreator = mock(NodeHierarchyCreator.class); RepositoryEntry entry = mock(RepositoryEntry.class); when(entry.getDefaultWorkspaceName()).thenReturn("collaboration"); ExtendedSession session = mock(ExtendedSession.class); ManageableRepository repo = mock(ManageableRepository.class); when(repo.getConfiguration()).thenReturn(entry); when(repo.getSystemSession(any())).thenReturn(session); RepositoryService repositoryService = mock(RepositoryService.class); when(repositoryService.getCurrentRepository()).thenReturn(repo); ExtendedNode rootNode = mock(ExtendedNode.class); when(session.getRootNode()).thenReturn(rootNode); ExtendedNode loginHistoryNode = mock(ExtendedNode.class); when(rootNode.hasNode("exo:LoginHistoryHome")).thenReturn(true); when(rootNode.getNode("exo:LoginHistoryHome")).thenReturn(loginHistoryNode); ExtendedNode usersNode = mock(ExtendedNode.class); when(nodeHierarchyCreator.getJcrPath("usersPath")).thenReturn("/Users"); when(session.getItem("/Users")).thenReturn(usersNode); ExtendedNode gadgetsNode = mock(ExtendedNode.class); when(session.getItem("/production/app:gadgets")).thenReturn(gadgetsNode); PLFSecureJCRFoldersUpgradePlugin plugin = new PLFSecureJCRFoldersUpgradePlugin(repositoryService, nodeHierarchyCreator, new InitParams()); plugin.processUpgrade("5.1.0", "5.2.0"); verify(rootNode, times(1)).removePermission(IdentityConstants.ANY); verify(gadgetsNode, times(1)).removePermission(IdentityConstants.ANY); verify(usersNode, times(1)).removePermission("*:/platform/users"); verify(loginHistoryNode, times(1)).removePermission("*:/platform/users"); }
@Override public void processUpgrade(String oldVersion, String newVersion) { SessionProvider sessionProvider = SessionProvider.createSystemProvider(); migrateCollaboration(sessionProvider); migrateGadgets(sessionProvider); migrateUsers(sessionProvider); migrateLoginHistory(sessionProvider); sessionProvider.close(); }
PLFSecureJCRFoldersUpgradePlugin extends UpgradeProductPlugin { @Override public void processUpgrade(String oldVersion, String newVersion) { SessionProvider sessionProvider = SessionProvider.createSystemProvider(); migrateCollaboration(sessionProvider); migrateGadgets(sessionProvider); migrateUsers(sessionProvider); migrateLoginHistory(sessionProvider); sessionProvider.close(); } }
PLFSecureJCRFoldersUpgradePlugin extends UpgradeProductPlugin { @Override public void processUpgrade(String oldVersion, String newVersion) { SessionProvider sessionProvider = SessionProvider.createSystemProvider(); migrateCollaboration(sessionProvider); migrateGadgets(sessionProvider); migrateUsers(sessionProvider); migrateLoginHistory(sessionProvider); sessionProvider.close(); } PLFSecureJCRFoldersUpgradePlugin(RepositoryService repoService, NodeHierarchyCreator nodeHierarchyCreator, InitParams initParams); }
PLFSecureJCRFoldersUpgradePlugin extends UpgradeProductPlugin { @Override public void processUpgrade(String oldVersion, String newVersion) { SessionProvider sessionProvider = SessionProvider.createSystemProvider(); migrateCollaboration(sessionProvider); migrateGadgets(sessionProvider); migrateUsers(sessionProvider); migrateLoginHistory(sessionProvider); sessionProvider.close(); } PLFSecureJCRFoldersUpgradePlugin(RepositoryService repoService, NodeHierarchyCreator nodeHierarchyCreator, InitParams initParams); @Override void processUpgrade(String oldVersion, String newVersion); }
PLFSecureJCRFoldersUpgradePlugin extends UpgradeProductPlugin { @Override public void processUpgrade(String oldVersion, String newVersion) { SessionProvider sessionProvider = SessionProvider.createSystemProvider(); migrateCollaboration(sessionProvider); migrateGadgets(sessionProvider); migrateUsers(sessionProvider); migrateLoginHistory(sessionProvider); sessionProvider.close(); } PLFSecureJCRFoldersUpgradePlugin(RepositoryService repoService, NodeHierarchyCreator nodeHierarchyCreator, InitParams initParams); @Override void processUpgrade(String oldVersion, String newVersion);  }