Package org.sonatype.plexus.rest.resource

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


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

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

  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

{

  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

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

  @Test
  public void testPost()
      throws Exception
  {
    PlexusResource pr = this.lookup(PlexusResource.class, "LdapServerListPlexusResource");

    LdapServerRequest ldapServerRequest = new LdapServerRequest();
    LdapServerConfigurationDTO dto = new LdapServerConfigurationDTO();
    ldapServerRequest.setData(dto);
    // dto.setId( "testPost" ); // this will be generated
    dto.setName("Test Post");
    dto.setConnectionInfo(this.buildConnectionInfoDTO());
    dto.setUserAndGroupConfig(this.buildUserAndGroupAuthConfigurationDTO());

    Request request = this.buildRequest();
    LdapServerRequest postResult = (LdapServerRequest) pr.post(null, request, null, ldapServerRequest);

    // we need to update the ID in the original, because it was set on the server
    Assert.assertNotNull(postResult.getData().getId());
    dto.setId(postResult.getData().getId());
View Full Code Here

  @Test
  public void testPost2()
      throws Exception
  {
    PlexusResource pr = this.lookup(PlexusResource.class, "LdapServerListPlexusResource");

    LdapServerRequest ldapServerRequest = new LdapServerRequest();
    LdapServerConfigurationDTO dto = new LdapServerConfigurationDTO();
    LdapConnectionInfoDTO connectionDto = new LdapConnectionInfoDTO();
    LdapUserAndGroupAuthConfigurationDTO userGroupDto = new LdapUserAndGroupAuthConfigurationDTO();

    ldapServerRequest.setData(dto);
    dto.setConnectionInfo(connectionDto);
    dto.setUserAndGroupConfig(userGroupDto);

    dto.setName("test");
    connectionDto.setHost("test");
    connectionDto.setPort(389);
    connectionDto.setSearchBase("test");
    connectionDto.setAuthScheme("none");
    connectionDto.setProtocol("ldap");
    connectionDto.setBackupMirrorProtocol("ldap");
    connectionDto.setBackupMirrorHost("asdf");
    connectionDto.setBackupMirrorPort(389);
    connectionDto.setConnectionTimeout(33);
    connectionDto.setConnectionRetryDelay(44);
    connectionDto.setCacheTimeout(55);
    userGroupDto.setEmailAddressAttribute("qasdf");
    userGroupDto.setLdapGroupsAsRoles(true);
    userGroupDto.setUserPasswordAttribute("asdf");
    userGroupDto.setUserIdAttribute("asdf");
    userGroupDto.setUserObjectClass("asdf");
    userGroupDto.setUserRealNameAttribute("asdf");
    userGroupDto.setUserSubtree(false);
    userGroupDto.setGroupSubtree(false);
    userGroupDto.setUserMemberOfAttribute("asdf");

    Request request = this.buildRequest();

    LdapServerRequest postResult = (LdapServerRequest) pr.post(null, request, null, ldapServerRequest);

    // we need to update the ID in the original, because it was set on the server
    Assert.assertNotNull(postResult.getData().getId());
    dto.setId(postResult.getData().getId());
View Full Code Here

  {
    // delete the one generated by the test class
    this.lookup(LdapConfigurationManager.class).deleteLdapServerConfiguration("default");

    List<String> expectedIds = new ArrayList<String>();
    PlexusResource pr = this.lookup(PlexusResource.class, "LdapServerListPlexusResource");

    Request request = this.buildRequest();

    // ONE
    LdapServerRequest ldapServerRequest = new LdapServerRequest();
    LdapServerConfigurationDTO dto = new LdapServerConfigurationDTO();
    ldapServerRequest.setData(dto);
    dto.setName("testGet-1");
    dto.setConnectionInfo(this.buildConnectionInfoDTO());
    dto.getConnectionInfo().setHost("testGet1");
    dto.setUserAndGroupConfig(this.buildUserAndGroupAuthConfigurationDTO());

    LdapServerRequest postResult = (LdapServerRequest) pr.post(null, request, null, ldapServerRequest);
    Assert.assertNotNull(postResult.getData().getId());
    expectedIds.add(postResult.getData().getId());

    // TWO
    ldapServerRequest = new LdapServerRequest();
    dto = new LdapServerConfigurationDTO();
    ldapServerRequest.setData(dto);
    dto.setName("testGet-2");
    dto.setConnectionInfo(this.buildConnectionInfoDTO());
    dto.getConnectionInfo().setPort(7788);
    dto.setUserAndGroupConfig(this.buildUserAndGroupAuthConfigurationDTO());

    postResult = (LdapServerRequest) pr.post(null, request, null, ldapServerRequest);
    Assert.assertNotNull(postResult.getData().getId());
    expectedIds.add(postResult.getData().getId());

    // THREE
    ldapServerRequest = new LdapServerRequest();
    dto = new LdapServerConfigurationDTO();
    ldapServerRequest.setData(dto);
    dto.setName("testGet-3");
    dto.setConnectionInfo(this.buildConnectionInfoDTO());
    dto.getConnectionInfo().setSearchBase("ou=testGet3");
    dto.setUserAndGroupConfig(this.buildUserAndGroupAuthConfigurationDTO());

    postResult = (LdapServerRequest) pr.post(null, request, null, ldapServerRequest);
    Assert.assertNotNull(postResult.getData().getId());
    expectedIds.add(postResult.getData().getId());

    // now test get
    LdapServerListResponse listResponse = (LdapServerListResponse) pr.get(null, request, null, null);
    List<LdapServerListEntryDTO> results = listResponse.getData();

    //these should be in order as they where created
    Assert.assertEquals(expectedIds.get(0), results.get(0).getId());
    Assert.assertEquals("testGet-1", results.get(0).getName());
View Full Code Here

    ldapServer1.getUserAndGroupConfig().setPreferredPasswordEncoding("Clear"); // doesn't matter the actual value

    ldapConfigurationManager.addLdapServerConfiguration(ldapServer1);

    // now get the second one
    PlexusResource pr = this.lookup(PlexusResource.class, "LdapServerPlexusResource");
    LdapServerRequest ldapResponse = (LdapServerRequest) pr.get(
        null,
        this.buildRequest(ldapServer1.getId()),
        null,
        null);
View Full Code Here

TOP

Related Classes of org.sonatype.plexus.rest.resource.PlexusResource

Copyright © 2018 www.massapicom. 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.