@Override
  protected void setUp() throws Exception {
    super.setUp();
    pscUserService = registerMockFor(PscUserService.class);
    ssaXmlSerializer = registerNiceMockFor(StudySubjectAssignmentXmlSerializer.class);

    Site nu = createSite("NU", "IL036");
    Study a = createBasicTemplate("A");
    StudySite a_nu = createStudySite(a, nu);
    a_nu.approveAmendment(a.getAmendment(), new Date());
    a_nu_1 = createAssignment(a_nu, createSubject("First", "One"));

    StudySegment ae0s1 = a.getPlannedCalendar().getEpochs().get(0).getStudySegments().get(0);
    ScheduledStudySegment scheduledStudySegment = createScheduledStudySegment(ae0s1);
    a_nu_1.getScheduledCalendar().addStudySegment(scheduledStudySegment);

    jo =
        new PscUserBuilder("jo")
            .add(PscRole.STUDY_SUBJECT_CALENDAR_MANAGER)
            .forAllSites()
            .forAllStudies()
            .toUser();
    alice =
        new PscUserBuilder("alice")
            .add(PscRole.STUDY_SUBJECT_CALENDAR_MANAGER)
            .forAllSites()
            .forAllStudies()
            .toUser();

    setCurrentUser(alice);
    UriTemplateParameters.USERNAME.putIn(request, "jo");
    expect(pscUserService.getAuthorizableUser("jo")).andStubReturn(jo);
    expect(pscUserService.getManagedAssignments(jo, alice))
        .andStubReturn(createExpectedUssars(jo, a_nu_1));
  }
  public void test404ForUnknownUser() throws Exception {
    UriTemplateParameters.USERNAME.putIn(request, "testUser");
    expect(pscUserService.getAuthorizableUser("testUser")).andReturn(null);

    doGet();
    assertResponseStatus(Status.CLIENT_ERROR_NOT_FOUND, "Unknown user: testUser");
  }
示例#3
0
  @SuppressWarnings({"unchecked"})
  public static AdministerUserCommand create(
      PscUser existingUser,
      ProvisioningSessionFactory psFactory,
      AuthorizationManager authorizationManager,
      AuthenticationSystem authenticationSystem,
      ApplicationSecurityManager applicationSecurityManager,
      PscUserService pscUserService,
      CsmUserCache csmUserCache,
      PscUser provisioner) {
    AdministerUserCommand command =
        new AdministerUserCommand(
            existingUser,
            psFactory,
            authorizationManager,
            authenticationSystem,
            applicationSecurityManager,
            csmUserCache);
    if (provisioner == null) return command;

    VisibleAuthorizationInformation visAuthInfo =
        pscUserService.getVisibleAuthorizationInformationFor(provisioner);
    command.setProvisionableSites(visAuthInfo.getSites());
    command.setProvisionableRoles(
        visAuthInfo.getRoles().toArray(new SuiteRole[visAuthInfo.getRoles().size()]));
    command.setProvisionableRoleGroups(
        visAuthInfo.getRoles().toArray(new SuiteRole[visAuthInfo.getRoles().size()]));
    command.setProvisionableManagedStudies(visAuthInfo.getStudiesForTemplateManagement());
    command.setProvisionableParticipatingStudies(visAuthInfo.getStudiesForSiteParticipation());

    if (provisioner.getMembership(PscRole.USER_ADMINISTRATOR) != null) {
      SuiteRoleMembership ua = provisioner.getMembership(PscRole.USER_ADMINISTRATOR);
      command.setCanProvisionAllSites(ua.isAllSites());
      command.setCanProvisionManagingAllStudies(true);
      command.setCanProvisionParticipateInAllStudies(true);
    } else if (provisioner.getMembership(PscRole.SYSTEM_ADMINISTRATOR) != null) {
      command.setCanProvisionAllSites(true);
    }

    return command;
  }
 private void expectManagedAssignments(
     PscUser manager, PscUser viewer, StudySubjectAssignment... assignments) {
   expect(pscUserService.getManagedAssignments(manager, viewer))
       .andReturn(createExpectedUssars(viewer, assignments));
 }