Exemplo n.º 1
0
  @Test
  public void testNullHTMLEscapedField() {
    LdapUserAndGroupConfigTestRequest resource = new LdapUserAndGroupConfigTestRequest();
    LdapUserAndGroupConfigTestRequestDTO dto = new LdapUserAndGroupConfigTestRequestDTO();

    resource.setData(dto);
    dto.setLdapFilter(null); // already null, but more clear for the test

    String xml = this.xstreamXML.toXML(resource);
    LdapUserAndGroupConfigTestRequestDTO result =
        ((LdapUserAndGroupConfigTestRequest) this.xstreamXML.fromXML(xml)).getData();

    Assert.assertNull(result.getLdapFilter());

    // simple json string with an explicit null value (generated from the Nexus UI)
    String payload = "{\"data\":{\"ldapFilter\":null}}";

    StringBuffer sb =
        new StringBuffer("{ \"")
            .append(LdapUserAndGroupConfigTestRequest.class.getName())
            .append("\" : ")
            .append(payload)
            .append(" }");
    // validate this parses without error
    xstreamJSON.fromXML(sb.toString());
  }
Exemplo n.º 2
0
  @Test
  public void testLdapUserAndGroupConfigTestRequest() throws Exception {
    LdapUserAndGroupConfigTestRequest resource = new LdapUserAndGroupConfigTestRequest();
    LdapUserAndGroupConfigTestRequestDTO dto = new LdapUserAndGroupConfigTestRequestDTO();

    resource.setData(dto);

    dto.setAuthScheme("authScheme");
    dto.setHost("host");
    dto.setPort(123);
    dto.setProtocol("protocol");
    dto.setRealm("realm");
    dto.setSearchBase("searchBase");
    dto.setSystemPassword("systemPassword");
    dto.setSystemUsername("systemUsername");
    dto.setUserMemberOfAttribute("userMemberOfAttribute");
    dto.setEmailAddressAttribute("emailAddressAttribute");
    dto.setGroupBaseDn("groupBaseDn");
    dto.setGroupIdAttribute("groupIdAttribute");
    dto.setGroupMemberFormat("groupMemberFormat");
    dto.setGroupMemberAttribute("groupMemberAttribute");
    dto.setGroupMemberFormat("groupMemberFormat");
    dto.setGroupObjectClass("groupObjectClass");
    dto.setUserBaseDn("userBaseDn");
    dto.setUserIdAttribute("userIdAttribute");
    dto.setUserObjectClass("userObjectClass");
    dto.setUserPasswordAttribute("userPasswordAttribute");
    dto.setUserRealNameAttribute("userRealNameAttribute");
    dto.setUserSubtree(true);

    validateXmlHasNoPackageNames(resource);
  }
  public Response sendTestMessage(LdapUserAndGroupConfigTestRequestDTO resource)
      throws IOException {

    XStreamRepresentation representation = new XStreamRepresentation(xstream, "", mediaType);

    String serviceURI = RequestFacade.SERVICE_LOCAL + "ldap/test_user_conf";

    LdapUserAndGroupConfigTestRequest repoResponseRequest = new LdapUserAndGroupConfigTestRequest();
    repoResponseRequest.setData(resource);

    // now set the payload
    representation.setPayload(repoResponseRequest);

    LOG.debug("sendMessage: " + representation.getText());

    return RequestFacade.sendMessage(serviceURI, Method.PUT, representation);
  }
Exemplo n.º 4
0
  @Test
  public void testLdapUserAndGroupConfigTestRequestWithEscape() throws Exception {
    LdapUserAndGroupConfigTestRequest resource = new LdapUserAndGroupConfigTestRequest();
    LdapUserAndGroupConfigTestRequestDTO dto = new LdapUserAndGroupConfigTestRequestDTO();

    resource.setData(dto);

    dto.setAuthScheme("authScheme&");
    dto.setHost("host&");
    dto.setPort(123);
    dto.setProtocol("protocol&");
    dto.setRealm("realm&");
    dto.setSearchBase("searchBase&");
    dto.setSystemPassword("systemPassword&");
    dto.setSystemUsername("systemUsername&");
    dto.setUserMemberOfAttribute("userMemberOfAttribute&");
    dto.setEmailAddressAttribute("emailAddressAttribute&");
    dto.setGroupBaseDn("groupBaseDn&");
    dto.setGroupIdAttribute("groupIdAttribute&");
    dto.setGroupMemberFormat("groupMemberFormat&");
    dto.setGroupMemberAttribute("groupMemberAttribute&");
    dto.setGroupMemberFormat("groupMemberFormat&");
    dto.setGroupObjectClass("groupObjectClass&");
    dto.setUserBaseDn("userBaseDn&");
    dto.setUserIdAttribute("userIdAttribute&");
    dto.setUserObjectClass("userObjectClass&");
    dto.setUserPasswordAttribute("userPasswordAttribute&");
    dto.setUserRealNameAttribute("userRealNameAttribute&");
    dto.setLdapFilter("ldapFilter&");
    dto.setUserSubtree(true);

    validateXmlHasNoPackageNames(resource);

    String xml = this.xstreamXML.toXML(resource);
    LdapUserAndGroupConfigTestRequestDTO result =
        ((LdapUserAndGroupConfigTestRequest) this.xstreamXML.fromXML(xml)).getData();

    Assert.assertEquals(result.getSearchBase(), "searchBase&");
    Assert.assertEquals(result.getSystemPassword(), "systemPassword&");
    Assert.assertEquals(result.getSystemUsername(), "systemUsername&");
    Assert.assertEquals(result.getGroupMemberFormat(), "groupMemberFormat&");
    Assert.assertEquals(result.getGroupBaseDn(), "groupBaseDn&");
    Assert.assertEquals(result.getUserBaseDn(), "userBaseDn&");
    Assert.assertEquals(result.getLdapFilter(), "ldapFilter&");

    Assert.assertEquals(result.getAuthScheme(), "authScheme&");
    Assert.assertEquals(result.getHost(), "host&");
    Assert.assertEquals(result.getPort(), 123);
    Assert.assertEquals(result.getProtocol(), "protocol&");
    Assert.assertEquals(result.getRealm(), "realm&");
    Assert.assertEquals(result.getUserMemberOfAttribute(), "userMemberOfAttribute&");
    Assert.assertEquals(result.getEmailAddressAttribute(), "emailAddressAttribute&");
    Assert.assertEquals(result.getGroupIdAttribute(), "groupIdAttribute&");
    Assert.assertEquals(result.getGroupMemberAttribute(), "groupMemberAttribute&");
    Assert.assertEquals(result.getGroupObjectClass(), "groupObjectClass&");
    Assert.assertEquals(result.getUserIdAttribute(), "userIdAttribute&");
    Assert.assertEquals(result.getUserObjectClass(), "userObjectClass&");
    Assert.assertEquals(result.getUserPasswordAttribute(), "userPasswordAttribute&");
    Assert.assertEquals(result.getUserRealNameAttribute(), "userRealNameAttribute&");
    Assert.assertEquals(result.isUserSubtree(), true);
  }