Examples of RepositoryTargetResource


Examples of org.sonatype.nexus.rest.model.RepositoryTargetResource

  @Test
  public void invalidContentClass()
      throws IOException
  {

    RepositoryTargetResource resource = new RepositoryTargetResource();

    // resource.setId( "createTest" );
    resource.setContentClass("INVALID_CLASS");
    resource.setName("invalidContentClass");

    List<String> patterns = new ArrayList<String>();
    patterns.add(".*foo.*");
    resource.setPatterns(patterns);

    Response response = this.messageUtil.sendMessage(Method.POST, resource);
    String responseText = response.getEntity().getText();

    if (response.getStatus().isSuccess()) {
View Full Code Here

Examples of org.sonatype.nexus.rest.model.RepositoryTargetResource

  @Test
  public void duplicateTargetTest()
      throws IOException
  {
    RepositoryTargetResource resource = new RepositoryTargetResource();
    // resource.setId( "createTest" );
    resource.setContentClass("maven1");
    resource.setName("duplicateTargetTest");

    List<String> patterns = new ArrayList<String>();
    patterns.add(".*foo.*");
    resource.setPatterns(patterns);

    Response response = this.messageUtil.sendMessage(Method.POST, resource);

    if (!response.getStatus().isSuccess()) {
      Assert.fail("Could not create Target: " + response.getStatus());
    }

    // get the Resource object
    RepositoryTargetResource responseResource = this.messageUtil.getResourceFromResponse(response);

    String id1 = responseResource.getId();

    // make sure it was updated
    this.messageUtil.verifyTargetsConfig(responseResource);

    // send again
    response = this.messageUtil.sendMessage(Method.POST, resource);

    if (!response.getStatus().isSuccess()) {
      Assert.fail("Could not create Target: " + response.getStatus());
    }

    // get the Resource object
    responseResource = this.messageUtil.getResourceFromResponse(response);
    String id2 = responseResource.getId();

    // make sure it was updated
    this.messageUtil.verifyTargetsConfig(responseResource);

    Assert.assertNotSame(id1, id2);
View Full Code Here

Examples of org.sonatype.nexus.rest.model.RepositoryTargetResource

  @Test
  public void updateValidation()
      throws IOException
  {
    RepositoryTargetResource resource = new RepositoryTargetResource();
    // resource.setId( "createTest" );
    resource.setContentClass("maven1");
    resource.setName("updateValidation");

    List<String> patterns = new ArrayList<String>();
    patterns.add(".*foo.*");
    resource.setPatterns(patterns);

    Response response = this.messageUtil.sendMessage(Method.POST, resource);

    if (!response.getStatus().isSuccess()) {
      Assert.fail("Could not create user: " + response.getStatus());
    }

    // get the Resource object
    RepositoryTargetResource responseResource = this.messageUtil.getResourceFromResponse(response);

    // make sure the id != null
    Assert.assertTrue(StringUtils.isNotEmpty(responseResource.getId()));

    Assert.assertEquals(responseResource.getContentClass(), resource.getContentClass());
    Assert.assertEquals(responseResource.getName(), resource.getName());
    Assert.assertEquals(resource.getPatterns(), responseResource.getPatterns());

    // verify config
    this.messageUtil.verifyTargetsConfig(responseResource);

    // update the Id
    resource.setId(responseResource.getId());

        /*
         * NO Name
         */
    resource.setContentClass("maven1");
View Full Code Here

Examples of org.sonatype.nexus.rest.model.RepositoryTargetResource

  @Before
  public void setupTargets()
      throws Exception
  {
    // create my repo targets
    RepositoryTargetResource fooTarget = new RepositoryTargetResource();
    fooTarget.setContentClass("maven2");
    fooTarget.setName("Foo");
    fooTarget.addPattern(".*nexu.537/repo.-foo.*");
    fooTarget = this.targetUtil.createTarget(fooTarget);

    RepositoryTargetResource barTarget = new RepositoryTargetResource();
    barTarget.setContentClass("maven2");
    barTarget.setName("Bar");
    barTarget.addPattern(".*nexu.537/repo.-bar.*");
    barTarget = this.targetUtil.createTarget(barTarget);

    // now create a couple privs
    PrivilegeResource fooPriv = new PrivilegeResource();
    fooPriv.addMethod("create");
    fooPriv.addMethod("read");
    fooPriv.addMethod("update");
    fooPriv.addMethod("delete");
    fooPriv.setName("FooPriv");
    fooPriv.setType(TargetPrivilegeDescriptor.TYPE);
    fooPriv.setRepositoryTargetId(fooTarget.getId());
    fooPriv.setRepositoryId("repo1");
    // get the Resource object
    List<PrivilegeStatusResource> fooPrivs = this.privUtil.createPrivileges(fooPriv);

    for (Iterator<PrivilegeStatusResource> iter = fooPrivs.iterator(); iter.hasNext(); ) {
      PrivilegeStatusResource privilegeBaseStatusResource = iter.next();

      if (getSecurityConfigUtil().getPrivilegeProperty(privilegeBaseStatusResource,
          ApplicationPrivilegeMethodPropertyDescriptor.ID).equals("create,read")) {
        fooPrivCreateId = privilegeBaseStatusResource.getId();
      }
      else if (getSecurityConfigUtil().getPrivilegeProperty(privilegeBaseStatusResource,
          ApplicationPrivilegeMethodPropertyDescriptor.ID).equals("read")) {
        fooPrivReadId = privilegeBaseStatusResource.getId();
      }
      else if (getSecurityConfigUtil().getPrivilegeProperty(privilegeBaseStatusResource,
          ApplicationPrivilegeMethodPropertyDescriptor.ID).equals("update,read")) {
        fooPrivUpdateId = privilegeBaseStatusResource.getId();
      }
      else if (getSecurityConfigUtil().getPrivilegeProperty(privilegeBaseStatusResource,
          ApplicationPrivilegeMethodPropertyDescriptor.ID).equals("delete,read")) {
        fooPrivDeleteId = privilegeBaseStatusResource.getId();
      }
      else {
        Assert.fail("Unknown Privilege found, id: "
            + privilegeBaseStatusResource.getId()
            + " method: "
            + getSecurityConfigUtil().getPrivilegeProperty(privilegeBaseStatusResource,
            ApplicationPrivilegeMethodPropertyDescriptor.ID));
      }
    }

    // now create a couple privs
    PrivilegeResource barPriv = new PrivilegeResource();
    barPriv.addMethod("create");
    barPriv.addMethod("read");
    barPriv.addMethod("update");
    barPriv.addMethod("delete");
    barPriv.setName("BarPriv");
    barPriv.setType(TargetPrivilegeDescriptor.TYPE);
    barPriv.setRepositoryTargetId(barTarget.getId());
    barPriv.setRepositoryId("repo1");

    // get the Resource object
    List<PrivilegeStatusResource> barPrivs = this.privUtil.createPrivileges(barPriv);

View Full Code Here

Examples of org.sonatype.nexus.rest.model.RepositoryTargetResource

  @Test
  public void maven1ContentClassTest()
      throws IOException
  {

    RepositoryTargetResource resource = new RepositoryTargetResource();

    // resource.setId( "createTest" );
    resource.setContentClass("maven1");
    resource.setName("maven1ContentClassTest");

    List<String> patterns = new ArrayList<String>();
    patterns.add(".*foo.*");
    resource.setPatterns(patterns);

    Response response = this.messageUtil.sendMessage(Method.POST, resource);

    if (!response.getStatus().isSuccess()) {
      Assert.fail("Could not create Repository Target: " + response.getStatus());
    }

    // get the Resource object
    RepositoryTargetResource responseResource = this.messageUtil.getResourceFromResponse(response);

    // make sure the id != null
    Assert.assertTrue(StringUtils.isNotEmpty(responseResource.getId()));

    Assert.assertEquals(responseResource.getContentClass(), resource.getContentClass());
    Assert.assertEquals(responseResource.getName(), resource.getName());
    Assert.assertEquals(resource.getPatterns(), responseResource.getPatterns());

    this.messageUtil.verifyTargetsConfig(responseResource);
  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.RepositoryTargetResource

  @Test
  public void maven2ContentClassTest()
      throws IOException
  {

    RepositoryTargetResource resource = new RepositoryTargetResource();

    // resource.setId( "createTest" );
    resource.setContentClass("maven2");
    resource.setName("maven2ContentClassTest");

    List<String> patterns = new ArrayList<String>();
    patterns.add(".*foo.*");
    resource.setPatterns(patterns);

    Response response = this.messageUtil.sendMessage(Method.POST, resource);

    if (!response.getStatus().isSuccess()) {
      Assert.fail("Could not create Repository Target: " + response.getStatus());
    }

    // get the Resource object
    RepositoryTargetResource responseResource = this.messageUtil.getResourceFromResponse(response);

    // make sure the id != null
    Assert.assertTrue(StringUtils.isNotEmpty(responseResource.getId()));

    Assert.assertEquals(responseResource.getContentClass(), resource.getContentClass());
    Assert.assertEquals(responseResource.getName(), resource.getName());
    Assert.assertEquals(resource.getPatterns(), responseResource.getPatterns());

    this.messageUtil.verifyTargetsConfig(responseResource);
  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.RepositoryTargetResource

  // eclipseContentClass is disabled for beta5!
  public void eclipseContentClassTest()
      throws IOException
  {
    // m2namespace
    RepositoryTargetResource resource = new RepositoryTargetResource();

    // resource.setId( "createTest" );
    resource.setContentClass("eclipse-update-site");
    resource.setName("eclipseContentClassTest");

    List<String> patterns = new ArrayList<String>();
    patterns.add(".*foo.*");
    resource.setPatterns(patterns);

    Response response = this.messageUtil.sendMessage(Method.POST, resource);

    if (!response.getStatus().isSuccess()) {
      Assert.fail("Could not create Repository Target: " + response.getStatus());
    }

    // get the Resource object
    RepositoryTargetResource responseResource = this.messageUtil.getResourceFromResponse(response);

    // make sure the id != null
    Assert.assertTrue(StringUtils.isNotEmpty(responseResource.getId()));

    Assert.assertEquals(responseResource.getContentClass(), resource.getContentClass());
    Assert.assertEquals(responseResource.getName(), resource.getName());
    Assert.assertEquals(resource.getPatterns(), responseResource.getPatterns());

    this.messageUtil.verifyTargetsConfig(responseResource);
  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.RepositoryTargetResource

  // m2NamespaceContentclass is disabled for beta5!
  public void m2NamespaceContentClassTest()
      throws IOException
  {

    RepositoryTargetResource resource = new RepositoryTargetResource();

    // resource.setId( "createTest" );
    resource.setContentClass("m2namespace");
    resource.setName("m2NamespaceContentClassTest");

    List<String> patterns = new ArrayList<String>();
    patterns.add(".*foo.*");
    resource.setPatterns(patterns);

    Response response = this.messageUtil.sendMessage(Method.POST, resource);

    if (!response.getStatus().isSuccess()) {
      Assert.fail("Could not create Repository Target: " + response.getStatus());
    }

    // get the Resource object
    RepositoryTargetResource responseResource = this.messageUtil.getResourceFromResponse(response);

    // make sure the id != null
    Assert.assertTrue(StringUtils.isNotEmpty(responseResource.getId()));

    Assert.assertEquals(responseResource.getContentClass(), resource.getContentClass());
    Assert.assertEquals(responseResource.getName(), resource.getName());
    Assert.assertEquals(resource.getPatterns(), responseResource.getPatterns());

    this.messageUtil.verifyTargetsConfig(responseResource);
  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.RepositoryTargetResource

  @Test
  public void createTestWithId()
      throws IOException
  {

    RepositoryTargetResource resource = new RepositoryTargetResource();

    // FIXME: This should be allowed
    // resource.setId( "createTestWithId" );
    resource.setContentClass("maven1");
    resource.setName("createTestWithId");

    List<String> patterns = new ArrayList<String>();
    patterns.add(".*foo.*");
    patterns.add(".*bar.*");
    resource.setPatterns(patterns);

    Response response = this.messageUtil.sendMessage(Method.POST, resource);

    if (!response.getStatus().isSuccess()) {
      Assert.fail("Could not create Repository Target: " + response.getStatus());
    }

    // get the Resource object
    RepositoryTargetResource responseResource = this.messageUtil.getResourceFromResponse(response);

    // make sure the id != null
    Assert.assertTrue(StringUtils.isNotEmpty(responseResource.getId()));

    // FIXME: This should be allowed
    // Assert.assertEquals( resource.getId(), responseResource.getId() );
    Assert.assertEquals(responseResource.getContentClass(), resource.getContentClass());
    Assert.assertEquals(responseResource.getName(), resource.getName());
    Assert.assertEquals(resource.getPatterns(), responseResource.getPatterns());

    this.messageUtil.verifyTargetsConfig(responseResource);
  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.RepositoryTargetResource

      throws Exception
  {
    TestContainer.getInstance().getTestContext().useAdminForRequests();

    // First create the targets
    RepositoryTargetResource test1Target =
        createTarget("filterTarget1", Collections.singletonList("/nexus778/test1/.*"));
    RepositoryTargetResource test2Target =
        createTarget("filterTarget2", Collections.singletonList("/nexus778/test2/.*"));

    // Then create the privileges
    PrivilegeStatusResource priv1 = createPrivilege("filterPriv1", test1Target.getId());
    PrivilegeStatusResource priv2 = createPrivilege("filterPriv2", test2Target.getId());

    // Then create the roles
    List<String> combined = new ArrayList<String>();
    combined.add(priv1.getId());
    combined.add(priv2.getId());
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.