Examples of PlexusResource


Examples of org.sonatype.plexus.rest.resource.PlexusResource

  public void testAddUser()
      throws Exception
  {

    PlexusResource resource = this.lookup(PlexusResource.class, "UserListPlexusResource");

    UserResourceRequest resourceRequest = new UserResourceRequest();
    UserResource userResource = new UserResource();
    resourceRequest.setData(userResource);
    userResource.setEmail("test@test.com");
    userResource.setFirstName("firstAddUser");
    userResource.setStatus("active");
    userResource.setUserId("testAddUser");
    userResource.addRole("admin");

    // try
    // {

    resource.post(null, this.buildRequest(), null, resourceRequest);
    // }
    // catch ( PlexusResourceException e )
    // {
    // ErrorResponse errorResponse = (ErrorResponse) e.getResultObject();
    // ErrorMessage errorMessage = (ErrorMessage) errorResponse.getErrors().get( 0 );
    // Assert.fail( e.getMessage() + ": " + errorMessage.getMsg() );
    // }

    // now list
    resource.get(null, this.buildRequest(), null, null);

  }
View Full Code Here

Examples of org.sonatype.plexus.rest.resource.PlexusResource

  public void testInvalidEmailAddUser()
      throws Exception
  {

    PlexusResource resource = this.lookup(PlexusResource.class, "UserListPlexusResource");

    UserResourceRequest resourceRequest = new UserResourceRequest();
    UserResource userResource = new UserResource();
    resourceRequest.setData(userResource);
    userResource.setEmail("testInvalidEmailAddUser");
    userResource.setFirstName("firstTestInvalidEmailAddUser");
    userResource.setLastName("firstTestInvalidEmailAddUser");
    userResource.setStatus("active");
    userResource.setUserId("testInvalidEmailAddUser");
    userResource.addRole("admin");

    try {

      resource.post(null, this.buildRequest(), null, resourceRequest);
      Assert.fail("expected PlexusResourceException");
    }
    catch (PlexusResourceException e) {
      ErrorResponse errorResponse = (ErrorResponse) e.getResultObject();
      ErrorMessage errorMessage = (ErrorMessage) errorResponse.getErrors().get(0);
      Assert.assertTrue(errorMessage.getId().contains("email"));
    }

    // now list
    resource.get(null, this.buildRequest(), null, null);
  }
View Full Code Here

Examples of org.sonatype.plexus.rest.resource.PlexusResource

  public void testUserIdWithSpace()
      throws Exception
  {

    PlexusResource resource = this.lookup(PlexusResource.class, "UserListPlexusResource");

    UserResourceRequest resourceRequest = new UserResourceRequest();
    UserResource userResource = new UserResource();
    resourceRequest.setData(userResource);
    userResource.setEmail("testUserIdWithSpace@testUserIdWithSpace.com");
    userResource.setFirstName("testUserIdWithSpace");
    userResource.setLastName("Last Name testUserIdWithSpace");
    userResource.setStatus("active");
    userResource.setUserId("test User Id With Space");
    userResource.addRole("admin");

    try {

      resource.post(null, this.buildRequest(), null, resourceRequest);
      Assert.fail("expected PlexusResourceException");
    }
    catch (PlexusResourceException e) {
      ErrorResponse errorResponse = (ErrorResponse) e.getResultObject();
      ErrorMessage errorMessage = (ErrorMessage) errorResponse.getErrors().get(0);
      Assert.assertTrue(errorMessage.getId().contains("userId"));
    }

    // fix it
    userResource.setUserId("testUserIdWithSpace");
    resource.post(null, this.buildRequest(), null, resourceRequest);

    // NOTE: update not supported

  }
View Full Code Here

Examples of org.sonatype.plexus.rest.resource.PlexusResource

      throws Exception
  {
    // test user creation with NO status

    // add a user
    PlexusResource resource = this.lookup(PlexusResource.class, "UserListPlexusResource");

    UserResourceRequest resourceRequest = new UserResourceRequest();
    UserResource userResource = new UserResource();
    resourceRequest.setData(userResource);
    userResource.setEmail("testUpdateUserValidation@test.com");
    userResource.setLastName("testUpdateUserValidation");
    userResource.setStatus("active");
    userResource.setUserId("testUpdateUserValidation");
    userResource.addRole("admin");

    resource.post(null, this.buildRequest(), null, resourceRequest);

    // remove the status
    userResource.setStatus("");

    resource = this.lookup(PlexusResource.class, "UserPlexusResource");
    try {
      resource.put(null, this.buildRequest(), null, resourceRequest);
      Assert.fail("expected PlexusResourceException");
    }
    catch (PlexusResourceException e) {
      // expected
    }
View Full Code Here

Examples of org.sonatype.plexus.rest.resource.PlexusResource

      throws Exception
  {
    // test user creation with NO status

    // add a user
    PlexusResource resource = this.lookup(PlexusResource.class, "UserListPlexusResource");

    UserResourceRequest resourceRequest = new UserResourceRequest();
    UserResource userResource = new UserResource();
    resourceRequest.setData(userResource);
    userResource.setEmail("testInvalidEmailUpdateUserValidation@test.com");
    userResource.setLastName("testInvalidEmailUpdateUserValidation");
    userResource.setStatus("active");
    userResource.setUserId("testInvalidEmailUpdateUserValidation");
    userResource.addRole("admin");

    resource.post(null, this.buildRequest(), null, resourceRequest);

    // remove the status
    userResource.setEmail("invalidEmailAddress");

    resource = this.lookup(PlexusResource.class, "UserPlexusResource");
    try {
      resource.put(null, this.buildRequest(), null, resourceRequest);
      Assert.fail("expected PlexusResourceException");
    }
    catch (PlexusResourceException e) {
      ErrorResponse errorResponse = (ErrorResponse) e.getResultObject();
      ErrorMessage errorMessage = (ErrorMessage) errorResponse.getErrors().get(0);
View Full Code Here

Examples of org.sonatype.plexus.rest.resource.PlexusResource

  @Test
  public void testModifiable()
      throws Exception
  {
    PlexusResource pr = this.lookup(PlexusResource.class, "LdapClearCachePlexusResource");
    Assert.assertTrue(pr.isModifiable());
  }
View Full Code Here

Examples of org.sonatype.plexus.rest.resource.PlexusResource

  @Test
  public void testReadable()
      throws Exception
  {
    PlexusResource pr = this.lookup(PlexusResource.class, "LdapClearCachePlexusResource");
    Assert.assertFalse(pr.isReadable());
  }
View Full Code Here

Examples of org.sonatype.plexus.rest.resource.PlexusResource

  public void testClearCache()
      throws Exception
  {
    LdapManager ldapManager = this.lookup(LdapManager.class);

    PlexusResource pr = this.lookup(PlexusResource.class, "LdapClearCachePlexusResource");
    Request request = this.buildRequest("default");
    Response response = new Response(request);

    // all systems are good
    Assert.assertNotNull(ldapManager.getUser("rwalker"));

    // This part is not true anymore, as Shiro caching is used, not homegrown in LdapManager
    // ==
    // stop the main server
    // this.mainConnector.stop();
    // make sure cache is active
    // Assert.assertNotNull(ldapManager.getUser("rwalker"));

    // delete the cache
    pr.delete(null, request, response);

    // fake out the connector again
    this.resetLdapConnectors();
    this.mainConnector.stop();
View Full Code Here

Examples of org.sonatype.plexus.rest.resource.PlexusResource

{

  public void testPostWithSpace()
      throws Exception
  {
    PlexusResource resource = this.lookup(PlexusResource.class, "RoleListPlexusResource");

    RoleResourceRequest roleRequest = new RoleResourceRequest();
    roleRequest.setData(new RoleResource());

    roleRequest.getData().setId("with spaces");
    roleRequest.getData().setDescription("foo");
    roleRequest.getData().setName("Foo Bar");
    roleRequest.getData().setSessionTimeout(60);
    roleRequest.getData().addPrivilege("1001");

    Request request = new Request();
    Reference ref = new Reference("http://localhost:12345/");
    request.setRootRef(ref);
    request.setResourceRef(new Reference(ref, "roles"));

    Response response = new Response(request);

    RoleResourceResponse roleResponse = (RoleResourceResponse) resource.post(null, request, response, roleRequest);

    Assert.assertEquals("with spaces", roleResponse.getData().getId());

    // ok now we try the gets
    resource = this.lookup(PlexusResource.class, "RolePlexusResource");

    // first with +
    request.getAttributes().put("roleId", "with+spaces");
    roleResponse = (RoleResourceResponse) resource.get(null, request, response, null);
    Assert.assertEquals("with spaces", roleResponse.getData().getId());

    // then with %20
    request.getAttributes().put("roleId", "with%20spaces");
    roleResponse = (RoleResourceResponse) resource.get(null, request, response, null);
    Assert.assertEquals("with spaces", roleResponse.getData().getId());

  }
View Full Code Here

Examples of org.sonatype.plexus.rest.resource.PlexusResource

  @Test
  public void testModifiable()
      throws Exception
  {
    PlexusResource pr = this.lookup(PlexusResource.class, "LdapServerListPlexusResource");
    Assert.assertTrue(pr.isModifiable());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.