コード例 #1
0
  public static OMEROMetadataStoreClient mockStore(ServiceFactory sf, String password)
      throws Exception {

    System.setProperty("omero.testing", "true");
    OmeroContext inner = sf.getContext();
    OmeroContext outer =
        new OmeroContext(
            new String[] {
              "classpath:ome/services/messaging.xml", // To share events
              "classpath:ome/formats/fixture.xml",
              "classpath:ome/services/blitz-servantDefinitions.xml",
              "classpath:ome/services/throttling/throttling.xml",
              "classpath:ome/config.xml"
            },
            false);
    outer.setParent(inner);
    outer.refresh();

    EventContext ec = sf.getAdminService().getEventContext();
    String username = ec.getCurrentUserName();
    long groupid = ec.getCurrentGroupId();

    MockFixture fixture = new MockFixture(new MockObjectTestCase() {}, outer);
    omero.client client = fixture.newClient();
    // Fixing group permissions from 4.2.0
    client
        .createSession(username, password)
        .setSecurityContext(new omero.model.ExperimenterGroupI(groupid, false));
    OMEROMetadataStoreClient store = new OMEROMetadataStoreClient();
    store.initialize(client);
    return store;
  }
コード例 #2
0
  @Test
  public void testUserCanChangeOwnPassword() throws Exception {
    Experimenter e = createNewUser(rootAdmin);
    resetPasswordTo_ome(e);
    assertCanLogin(e.getOmeName(), "ome");

    ServiceFactory userServices = new ServiceFactory(new Login(e.getOmeName(), "ome"));
    userServices.getAdminService().changePassword("test");
    assertCanLogin(e.getOmeName(), "test");
    assertCannotLogin(e.getOmeName(), "ome");
  }
コード例 #3
0
  @Test(expectedExceptions = SecurityViolation.class)
  public void testUserCantChangeOthersPassword() throws Exception {
    Experimenter e = createNewUser(getSudoAdmin("ome"));
    resetPasswordTo_ome(e);
    assertCanLogin(e.getOmeName(), "ome");

    Experimenter target = createNewUser(getSudoAdmin("ome"));
    resetPasswordTo_ome(target);
    assertCanLogin(target.getOmeName(), "ome");

    ServiceFactory userServices = new ServiceFactory(new Login(e.getOmeName(), "ome"));
    userServices.getAdminService().changeUserPassword(target.getOmeName(), "test");
  }
コード例 #4
0
 @Test
 public void testBasics() throws Exception {
   search = sf.createSearchService();
   search.onlyType(Image.class);
   search.byFullText("root");
   assertTrue(search.hasNext());
   search.close();
 }
コード例 #5
0
 public Pixels getPixels() {
   return sf.getQueryService()
       .findByQuery(
           "select p from Dataset d "
               + "join d.imageLinks dil "
               + "join dil.child img "
               + "join img.pixels p where d.id = "
               + d.getId(),
           null);
 }
コード例 #6
0
  /**
   * checks for the necessary fields and initializes the {@link ImportLibrary}
   *
   * @throws Exception
   */
  public void setUp() throws Exception {
    d = new Dataset();
    d.setName(UUID.randomUUID().toString());
    d = sf.getUpdateService().saveAndReturnObject(d);

    File tinyTest = ResourceUtils.getFile("classpath:" + FILENAME);

    // super.put( tinyTest, d );
    // super.setUp();
  }