コード例 #1
0
  protected void setUp() throws Exception {
    super.setUp();

    PermissionContextFactory ctxFactory = ComponentAccessor.getPermissionContextFactory();
    DefaultSchemeFactory schemeFactory = new DefaultSchemeFactory();
    OfBizDelegator ofBizDelegator = new DefaultOfBizDelegator(CoreFactory.getGenericDelegator());
    AssociationManager associationManager = CoreFactory.getAssociationManager();
    ManagerFactory.addService(
        IssueSecuritySchemeManager.class,
        new IssueSecuritySchemeManagerImpl(
            new DefaultProjectManager(),
            new PermissionTypeManager(),
            ctxFactory,
            schemeFactory,
            null,
            associationManager,
            ofBizDelegator,
            null));

    issueSchemeManager = ManagerFactory.getIssueSecuritySchemeManager();

    project =
        UtilsForTests.getTestEntity("Project", EasyMap.build("id", new Long(2), "lead", "paul"));
    project2 = UtilsForTests.getTestEntity("Project", new HashMap());
  }
コード例 #2
0
  public void testGetQueryWorksCorrectly() throws Exception {
    SecurityType securityType =
        (SecurityType) ManagerFactory.getPermissionTypeManager().getSchemeType("reporter");

    // Setup permissions so that a query is created
    GenericValue project = UtilsForTests.getTestEntity("Project", EasyMap.build("name", "Project"));
    PermissionSchemeManager permissionSchemeManager = ManagerFactory.getPermissionSchemeManager();
    GenericValue scheme = permissionSchemeManager.createScheme("Scheme", "scheme");
    permissionSchemeManager.addSchemeToProject(project, scheme);

    SchemeEntity schemeEntity =
        new SchemeEntity(securityType.getType(), null, new Long(Permissions.BROWSE));
    permissionSchemeManager.createSchemeEntity(scheme, schemeEntity);

    Query query = securityType.getQuery(u, project, null);
    assertEquals(
        "(+"
            + DocumentConstants.PROJECT_ID
            + ":"
            + project.getLong("id")
            + " +"
            + DocumentConstants.ISSUE_AUTHOR
            + ":owen)",
        query.toString(""));
  }
コード例 #3
0
  @Override
  protected void tearDown() throws Exception {
    super.tearDown();
    ManagerFactory.addService(FieldClausePermissionChecker.Factory.class, originalFactory);

    // remove our mock from the Manager Factory and put a normal one back in place
    ManagerFactory.addService(FieldVisibilityManager.class, new FieldVisibilityBean());
  }
コード例 #4
0
  protected void setUp() throws Exception {
    super.setUp();

    psm = ManagerFactory.getPermissionSchemeManager();
    pm = ManagerFactory.getPermissionManager();
    projm = ManagerFactory.getProjectManager();
    task = new UpgradeTask_Build47(psm, new SchemePermissions());
  }
コード例 #5
0
 public List getRecipients(IssueEvent event, String username) {
   User u = ManagerFactory.getUserManager().getUser(username);
   if (u != null) {
     return EasyList.build(new NotificationRecipient(u));
   }
   return Collections.EMPTY_LIST;
 }
コード例 #6
0
  protected void tearDown() throws Exception {
    user = null;
    secondaryUser = null;
    sr = null;

    ActionContext.getSession().clear();
    ComponentAccessor.getJiraAuthenticationContext().setLoggedInUser(null);
    PermissionManager pm = ManagerFactory.getPermissionManager();
    pm.removeGroupPermissions("jira-user");
    ImportUtils.setSubvertSecurityScheme(false);
    super.tearDown();
  }
コード例 #7
0
  public static Date parseDate(String paramValue, Locale locale) {
    if (StringUtils.isBlank(paramValue)) {
      return null;
    }

    try {
      Date date =
          ManagerFactory.getOutlookDateManager().getOutlookDate(locale).parseDatePicker(paramValue);
      if (date.getTime() < 0) // this is an invalid date
      {
        throw new DateTooEarlyException();
      } else {
        return date;
      }
    } catch (ParseException e) {
      log.warn("Could not parse: " + paramValue + " into a date");
    }

    return null;
  }
コード例 #8
0
 public SchemeManager getSchemeManager() {
   return ManagerFactory.getPermissionSchemeManager();
 }
コード例 #9
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    final FieldVisibilityManager visibilityBean = EasyMock.createMock(FieldVisibilityManager.class);
    EasyMock.expect(
            visibilityBean.isFieldHidden(
                (String) EasyMock.anyObject(), (Issue) EasyMock.anyObject()))
        .andReturn(false)
        .anyTimes();
    EasyMock.replay(visibilityBean);
    ManagerFactory.addService(FieldVisibilityManager.class, visibilityBean);

    originalFactory =
        ComponentManager.getComponentInstanceOfType(FieldClausePermissionChecker.Factory.class);
    ManagerFactory.addService(
        FieldClausePermissionChecker.Factory.class, new MockFieldClausePermissionFactory());
    bob = createMockUser("bob");

    final Group group = addUserToNewGroup(bob, "group");
    carl = createMockUser("carl");

    final GenericValue project =
        UtilsForTests.getTestEntity("Project", EasyMap.build("key", "TST"));

    final PermissionSchemeManager permissionSchemeManager =
        ManagerFactory.getPermissionSchemeManager();
    final GenericValue defaultScheme = permissionSchemeManager.createDefaultScheme();
    final SchemeEntity schemeEntity =
        new SchemeEntity(GroupDropdown.DESC, null, Permissions.BROWSE);
    permissionSchemeManager.createSchemeEntity(defaultScheme, schemeEntity);

    permissionSchemeManager.addSchemeToProject(project, defaultScheme);

    UtilsForTests.getTestEntity("Resolution", EasyMap.build("id", resolutionId));
    // Create two Issues with same comment but different level
    final GenericValue issue1 =
        UtilsForTests.getTestEntity(
            "Issue",
            EasyMap.build(
                "project",
                project.getLong("id"),
                "key",
                "TST-1",
                "resolution",
                resolutionId,
                "summary",
                SUMMARY_BODY));
    UtilsForTests.getTestEntity(
        "Action",
        EasyMap.build(
            "issue",
            issue1.getLong("id"),
            "type",
            ActionConstants.TYPE_COMMENT,
            "body",
            COMMENT_BODY));

    final GenericValue issue2 =
        UtilsForTests.getTestEntity(
            "Issue",
            EasyMap.build(
                "project",
                project.getLong("id"),
                "key",
                "TST-2",
                "resolution",
                resolutionId,
                "summary",
                SUMMARY_BODY));
    UtilsForTests.getTestEntity(
        "Action",
        EasyMap.build(
            "issue",
            issue2.getLong("id"),
            "type",
            ActionConstants.TYPE_COMMENT,
            "body",
            COMMENT_BODY,
            "level",
            group.getName()));

    final GenericValue issue3 =
        UtilsForTests.getTestEntity(
            "Issue",
            EasyMap.build(
                "project",
                project.getLong("id"),
                "key",
                "TST-3",
                "resolution",
                resolutionId,
                "summary",
                ANOTHER_SUMMARY_BODY));
    UtilsForTests.getTestEntity(
        "Action",
        EasyMap.build(
            "issue",
            issue3.getLong("id"),
            "type",
            ActionConstants.TYPE_COMMENT,
            "body",
            ANOTHER_COMMENT_BODY,
            "level",
            group.getName()));

    ManagerFactory.getIndexManager().reIndexAll();
  }
コード例 #10
0
  protected void setUp() throws Exception {
    super.setUp();

    user = createMockUser("logged-in-user");
    secondaryUser = createMockUser("testuser");
    g = createMockGroup("jira-user");
    addUserToGroup(user, g);
    addUserToGroup(secondaryUser, g);
    JiraTestUtil.loginUser(user);
    ComponentAccessor.getApplicationProperties()
        .setOption(APKeys.JIRA_OPTION_ALLOWUNASSIGNED, true);
    ManagerFactory.getGlobalPermissionManager().addPermission(Permissions.ADMINISTER, null);

    SchemeManager permManager = ManagerFactory.getPermissionSchemeManager();
    GenericValue scheme = permManager.createDefaultScheme();
    PermissionManager pm = ManagerFactory.getPermissionManager();
    pm.addPermission(Permissions.CREATE_ISSUE, scheme, "jira-user", "group");
    pm.addPermission(Permissions.BROWSE, scheme, "jira-user", "group");
    pm.addPermission(Permissions.RESOLVE_ISSUE, scheme, "jira-user", "group");
    pm.addPermission(Permissions.ASSIGN_ISSUE, scheme, "jira-user", "group");
    pm.addPermission(Permissions.CLOSE_ISSUE, scheme, "jira-user", "group");
    pm.addPermission(Permissions.WORK_ISSUE, scheme, "jira-user", "group");
    pm.addPermission(Permissions.ASSIGNABLE_USER, scheme, "jira-user", "group");

    // Build IssueConstants
    UpgradeTask_Build11 upgradeTask_build11 =
        new UpgradeTask_Build11(ComponentAccessor.getConstantsManager());
    upgradeTask_build11.doUpgrade(false);

    // Build the default statuses
    UpgradeTask_Build27 upgradeTask_build27 = new UpgradeTask_Build27();
    upgradeTask_build27.doUpgrade(false);

    // Create field screens
    UpgradeTask upgradeTask = (UpgradeTask) JiraUtils.loadComponent(UpgradeTask_Build83.class);
    upgradeTask.doUpgrade(false);

    // Build default IssueTypeScheme
    UpgradeTask upgradeTask101 = (UpgradeTask) JiraUtils.loadComponent(UpgradeTask_Build101.class);
    upgradeTask101.doUpgrade(false);

    JiraAuthenticationContext authenticationContext =
        ComponentAccessor.getJiraAuthenticationContext();
    // Log in user
    authenticationContext.setLoggedInUser(user);
    GenericValue project =
        UtilsForTests.getTestEntity(
            "Project",
            EasyMap.build(
                "key", "ABC", "name", "A Project", "lead", user.getName(), "counter", new Long(1)));
    ComponentAccessor.getIssueTypeScreenSchemeManager().associateWithDefaultScheme(project);
    ManagerFactory.getProjectManager().refresh();

    final PermissionSchemeManager permissionSchemeManager =
        ManagerFactory.getPermissionSchemeManager();
    permissionSchemeManager.addSchemeToProject(project, scheme);

    // Create a REAL issue (with valid transitions and everything) with key ABC-2
    final MutableIssue issue1 = ComponentAccessor.getIssueFactory().getIssue();
    issue1.setProject(project);
    issue1.setAssignee(user);
    GenericValue issueTypeGV = ComponentAccessor.getConstantsManager().getIssueType("1");
    issue1.setIssueType(issueTypeGV);
    ComponentAccessor.getIssueManager().createIssue(user, issue1);

    // Create a second REAL issue with key ABC-3
    final MutableIssue issue2 = ComponentAccessor.getIssueFactory().getIssue();
    issue2.setProject(project);
    issue2.setAssignee(secondaryUser);
    issue2.setIssueType(issueTypeGV);
    ComponentAccessor.getIssueManager().createIssue(secondaryUser, issue2);

    // Create a SearchRequest to return the two issues
    sr =
        UtilsForTests.getTestEntity(
            "SearchRequest",
            EasyMap.build(
                "id",
                new Long(10241),
                "name",
                "test",
                "author",
                "logged-in-user",
                "user",
                "logged-in-user",
                "group",
                "jira-user",
                "project",
                project.get("id"),
                "request",
                "project = " + project.get("id")));
  }
コード例 #11
0
 public boolean doValidation(String key, Map parameters) {
   Object value = parameters.get(key);
   return (value != null
       && TextUtils.stringSet((String) value)
       && ManagerFactory.getUserManager().getUser((String) value) != null);
 }
コード例 #12
0
 public String getRequestURI() {
   return ManagerFactory.getApplicationProperties().getString(APKeys.JIRA_BASEURL);
 }
コード例 #13
0
 protected GenericValue getConstant(GenericValue i1) {
   return ManagerFactory.getConstantsManager().getIssueType(i1.getString("type"));
 }