private StandardUserDetailsService getUserDetailsTestService(CoreContext ctx, boolean imEnabled) { User u = new User() { @Override public boolean hasPermission(PermissionName permission) { return true; } }; u.setUserName(USER_NAME); u.setUniqueId(); AddressBookEntry abe = new AddressBookEntry(); abe.setImId(USER_IM_ID); u.setAddressBookEntry(abe); u.setSettings(TestHelper.loadSettings("commserver/user-settings.xml")); u.setSettingTypedValue("im/im-account", imEnabled); AcdContext acdContext = createMock(AcdContext.class); StandardUserDetailsService uds = new StandardUserDetailsService(); uds.setCoreContext(ctx); uds.setAcdContext(acdContext); ctx.loadUserByUserNameOrAlias(USER_IM_ID); expectLastCall().andReturn(null); ctx.loadUserByConfiguredImId(USER_IM_ID); expectLastCall().andReturn(u); acdContext.getUsersWithAgents(); expectLastCall().andReturn(Collections.emptyList()); replay(ctx, acdContext); return uds; }
public void testLoadUserByUsername() { User u = new User() { @Override public boolean hasPermission(PermissionName permission) { return true; } }; u.setUserName(USER_NAME); u.setUniqueId(); CoreContext coreContext = createMock(CoreContext.class); AcdContext acdContext = createMock(AcdContext.class); StandardUserDetailsService uds = new StandardUserDetailsService(); uds.setCoreContext(coreContext); uds.setAcdContext(acdContext); coreContext.loadUserByUserNameOrAlias(USER_NAME); expectLastCall().andReturn(u); acdContext.getUsersWithAgents(); expectLastCall().andReturn(Collections.emptyList()); replay(coreContext, acdContext); // load the user details UserDetails details = uds.loadUserByUsername(USER_NAME); assertEquals(USER_NAME, details.getUsername()); GrantedAuthority[] authorities = details.getAuthorities(); assertTrue(contains(authorities, UserRole.Admin.toAuth())); assertTrue(contains(authorities, UserRole.User.toAuth())); assertFalse(contains(authorities, UserRole.AcdAgent.toAuth())); assertFalse(contains(authorities, UserRole.AcdSupervisor.toAuth())); assertTrue(contains(authorities, UserRole.AttendantAdmin.toAuth())); verify(coreContext, acdContext); }
public void testAcdBridgePublishSaveDelete() throws Exception { loadDataSetXml("admin/commserver/clearLocations.xml"); Location[] emptyLocations = m_out.getLocations(); assertEquals(0, emptyLocations.length); assertEquals(0, m_acdContext.getServers().size()); Location location = new Location(); location.setName("test location"); location.setAddress("192.168.1.2"); location.setFqdn("location1"); location.setInstalledBundles(asList("callCenterBundle")); m_out.storeLocation(location); assertEquals(1, m_acdContext.getServers().size()); assertEquals(0, m_conferenceBridgeContext.getBridges().size()); SipxService freeswitchService = new SipxFreeswitchService(); freeswitchService.setBeanId(SipxFreeswitchService.BEAN_ID); LocationSpecificService service = new LocationSpecificService(); service.setSipxService(freeswitchService); service.setLocation(location); location.addService(freeswitchService); location.setInstalledBundles(asList("callCenterBundle", "conferenceBundle")); m_out.storeLocation(location); assertEquals(1, m_acdContext.getServers().size()); assertEquals(1, m_conferenceBridgeContext.getBridges().size()); location.setInstalledBundles(asList("callCenterBundle")); m_out.storeLocation(location); assertEquals(1, m_acdContext.getServers().size()); assertEquals(0, m_conferenceBridgeContext.getBridges().size()); location.setInstalledBundles(Collections.<String>emptyList()); m_out.storeLocation(location); assertEquals(0, m_acdContext.getServers().size()); assertEquals(0, m_conferenceBridgeContext.getBridges().size()); }