@Override protected void addItems(final List<Map<String, String>> items) { final String domainName = getSipDomain(); CoreContext coreContext = getCoreContext(); final String realm = coreContext.getAuthorizationRealm(); Closure<User> closure = new Closure<User>() { @Override public void execute(User user) { addUser(items, user, domainName, realm); } }; forAllUsersDo(getCoreContext(), closure); for (SpecialUserType specialUserType : SpecialUserType.values()) { addSpecialUser(items, specialUserType, domainName, realm); } List<CallGroup> callGroups = m_callGroupContext.getCallGroups(); for (CallGroup callGroup : callGroups) { if (callGroup.isEnabled()) { addCallGroup(items, callGroup, domainName, realm); } } }
public void testCallGroupPerms() throws Exception { PermissionManagerImpl pm = new PermissionManagerImpl(); pm.setModelFilesContext(TestHelper.getModelFilesContext()); User testUser = new User(); testUser.setPermissionManager(pm); CoreContext coreContext = createMock(CoreContext.class); coreContext.getDomainName(); expectLastCall().andReturn("host.company.com"); coreContext.loadUsersByPage(null, null, null, 0, DaoUtils.PAGE_SIZE, "id", true); expectLastCall().andReturn(Collections.EMPTY_LIST); coreContext.newUser(); expectLastCall().andReturn(testUser).anyTimes(); CallGroup callGroup1 = new CallGroup(); callGroup1.setName("sales"); callGroup1.setEnabled(true); CallGroup callGroup2 = new CallGroup(); callGroup2.setName("marketing"); callGroup2.setEnabled(true); CallGroup callGroup3 = new CallGroup(); callGroup3.setName("disabled"); CallGroupContext callGroupContext = createMock(CallGroupContext.class); callGroupContext.getCallGroups(); expectLastCall().andReturn(Arrays.asList(callGroup1, callGroup2, callGroup3)); replay(coreContext, callGroupContext); Permissions permissions = new Permissions(); permissions.setCoreContext(coreContext); permissions.setCallGroupContext(callGroupContext); List<Map<String, String>> items = permissions.generate(); int start = SPEC_COUNT * PERM_COUNT; assertEquals(start + 10, items.size()); assertEquals("sip:[email protected]", items.get(start + 0).get("identity")); assertEquals("sip:[email protected]", items.get(start + 4).get("identity")); assertEquals("sip:[email protected]", items.get(start + 5).get("identity")); assertEquals("sip:[email protected]", items.get(start + 9).get("identity")); verify(coreContext, callGroupContext); }
void addCallGroup( List<Map<String, String>> items, CallGroup callGroup, String domainName, String realm) { String sipPasswordHash = callGroup.getSipPasswordHash(realm); String uri = SipUri.format(null, callGroup.getName(), domainName); addCredentialsItem(items, uri, callGroup.getName(), sipPasswordHash, sipPasswordHash, realm); }