private ConfigGenerator createConfigGenerator() {
    ConfigGenerator cg = new ConfigGenerator();

    DomainManager domainManager = TestUtil.getMockDomainManager();
    EasyMock.replay(domainManager);

    AuthRules authRules = new AuthRules();
    authRules.setDomainManager(domainManager);
    cg.setAuthRules(authRules);

    MappingRules mappingRules = new MappingRules();
    mappingRules.setDomainManager(domainManager);
    cg.setMappingRules(mappingRules);

    FallbackRules fallbackRules = new FallbackRules();
    fallbackRules.setDomainManager(domainManager);
    cg.setFallbackRules(fallbackRules);

    ForwardingRules forwardingRules = new ForwardingRules();
    cg.setForwardingRules(forwardingRules);

    forwardingRules.setVelocityEngine(TestHelper.getVelocityEngine());
    SbcManager sbcManager = createNiceMock(SbcManager.class);
    replay(sbcManager);

    forwardingRules.setSbcManager(sbcManager);

    SipxProxyService proxyService = new SipxProxyService();
    proxyService.setModelDir("sipxproxy");
    proxyService.setModelName("sipxproxy.xml");
    proxyService.setModelFilesContext(TestHelper.getModelFilesContext());
    proxyService.setBeanName(SipxProxyService.BEAN_ID);
    proxyService.setSipPort("9901");
    proxyService.setDomainManager(domainManager);

    SipxService statusService = new SipxStatusService();
    statusService.setBeanName(SipxStatusService.BEAN_ID);
    statusService.setModelFilesContext(TestHelper.getModelFilesContext());
    statusService.setSettings(TestHelper.loadSettings("sipxstatus/sipxstatus.xml"));
    Setting statusConfigSettings = statusService.getSettings().getSetting("status-config");
    statusConfigSettings.getSetting("SIP_STATUS_SIP_PORT").setValue("9905");

    SipxRegistrarService registrarService = new SipxRegistrarService();
    registrarService.setBeanName(SipxRegistrarService.BEAN_ID);
    registrarService.setRegistrarEventSipPort("9906");
    registrarService.setSipPort("9907");

    SipxServiceManager sipxServiceManager =
        TestUtil.getMockSipxServiceManager(true, proxyService, registrarService, statusService);
    forwardingRules.setSipxServiceManager(sipxServiceManager);

    return cg;
  }
Пример #2
0
  public void testAddUser() throws Exception {
    List<Map<String, String>> items = new ArrayList<Map<String, String>>();

    PermissionManagerImpl pm = new PermissionManagerImpl();
    pm.setModelFilesContext(TestHelper.getModelFilesContext());

    User user = new User();
    user.setPermissionManager(pm);

    Group g = new Group();
    PermissionName.INTERNATIONAL_DIALING.setEnabled(g, false);
    PermissionName.LONG_DISTANCE_DIALING.setEnabled(g, false);
    PermissionName.TOLL_FREE_DIALING.setEnabled(g, false);
    PermissionName.LOCAL_DIALING.setEnabled(g, true);
    PermissionName.SIPX_VOICEMAIL.setEnabled(g, false);
    PermissionName.FREESWITH_VOICEMAIL.setEnabled(g, false);
    PermissionName.EXCHANGE_VOICEMAIL.setEnabled(g, true);

    user.addGroup(g);
    user.setUserName("goober");

    Permissions permissions = new Permissions();
    permissions.addUser(items, user, "sipx.sipfoundry.org");

    assertEquals(PERM_COUNT, items.size());
    assertEquals("sip:[email protected]", items.get(0).get("identity"));
    assertEquals("LocalDialing", items.get(0).get("permission"));

    assertEquals("sip:[email protected]", items.get(3).get("identity"));
    assertEquals("ExchangeUMVoicemailServer", items.get(3).get("permission"));

    assertEquals("sip:[email protected]", items.get(4).get("identity"));
    assertEquals("ExchangeUMVoicemailServer", items.get(4).get("permission"));
  }
  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;
  }
  @Override
  protected void setUp() throws Exception {
    XMLUnit.setIgnoreWhitespace(true);
    phone = new PolycomPhone();
    PolycomModel model = new PolycomModel();
    model.setMaxLineCount(6);
    phone.setModel(model);
    PhoneTestDriver.supplyTestData(phone);

    m_location = new MemoryProfileLocation();

    VelocityProfileGenerator pg = new VelocityProfileGenerator();
    pg.setVelocityEngine(TestHelper.getVelocityEngine());
    m_pg = pg;
  }
Пример #5
0
  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);
  }
Пример #6
0
  public void testGenerateEmpty() 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();

    CallGroupContext callGroupContext = createMock(CallGroupContext.class);
    callGroupContext.getCallGroups();
    expectLastCall().andReturn(Collections.EMPTY_LIST);

    replay(coreContext, callGroupContext);

    Permissions permissions = new Permissions();
    permissions.setCoreContext(coreContext);
    permissions.setCallGroupContext(callGroupContext);

    List<Map<String, String>> items = permissions.generate();
    assertEquals(SPEC_COUNT * PERM_COUNT, items.size());
    // 5 permissions per special user

    for (SpecialUserType su : SpecialUserType.values()) {
      int i = su.ordinal();

      String name = "sip:" + su.getUserName() + "@host.company.com";
      assertEquals(name, items.get(i * PERM_COUNT).get("identity"));
      assertEquals(name, items.get((i + 1) * PERM_COUNT - 1).get("identity"));
    }
    verify(coreContext, callGroupContext);
  }
Пример #7
0
 @Override
 protected void setUp() throws IOException {
   m_zipFile = TestHelper.getResourceAsFile(getClass(), "zip-test.zip");
   m_expandDir = TestHelper.createTempDir("zip-test");
 }