Examples of NexusClient


Examples of com.sonatype.maven.shell.nexus.NexusClient

    @Override
    protected NexusClient getClient(final Variables vars) {
        assert vars != null;

        NexusClient client;

        // Close if a client already exists
        try {
            client = super.getClient(vars);
            client.close();
        }
        catch (NexusClient.NotConnectedFailure e) {
            // ignore
        }
View Full Code Here

Examples of com.sonatype.maven.shell.nexus.NexusClient

{
    public Object execute(final CommandContext context) throws Exception {
        assert context != null;
        Variables vars = context.getVariables();

        NexusClient client = getClient(vars);

        return execute(context, client);
    }
View Full Code Here

Examples of com.sonatype.maven.shell.nexus.NexusClient

    }

    protected NexusClient getClient(final Variables vars) {
        assert vars != null;
       
        NexusClient client = vars.get(NexusClient.class);
        if (client == null) {
            throw new NexusClient.NotConnectedFailure();
        }
        return client;
    }
View Full Code Here

Examples of org.sonatype.nexus.client.core.NexusClient

  }

  protected NexusClient createNexusClientForRemoteHeader(final String headerName,
                                                         final String headerValue)
  {
    final NexusClient nexusClient = createNexusClientForAnonymous(nexus());
    ((JerseyNexusClient) nexusClient).getClient().addFilter(new ClientFilter()
    {
      @Override
      public ClientResponse handle(final ClientRequest clientRequest) throws ClientHandlerException {
        clientRequest.getHeaders().putSingle(headerName, headerValue);
View Full Code Here

Examples of org.sonatype.nexus.client.core.NexusClient

      throws Exception
  {
    configureRemoteHeader("REMOTE_USER");
    configureSecurityRealms();

    final NexusClient rutAuthClient = createNexusClientForRemoteHeader("REMOTE_USER", "admin");

    // if we can get the users it means that authentication was successful and we have enough rights
    rutAuthClient.getSubsystem(Users.class).get();
  }
View Full Code Here

Examples of org.sonatype.nexus.client.core.NexusClient

      throws Exception
  {
    configureRemoteHeader("REMOTE_USER");
    configureSecurityRealms();

    final NexusClient rutAuthClient = createNexusClientForRemoteHeader("REMOTE_USER", "deployment");

    // if we can get the repositories it means that authentication was successful and we have enough rights
    rutAuthClient.getSubsystem(Repositories.class).get();

    thrown.expect(NexusClientAccessForbiddenException.class); // 403
    // we should not be able to access users as we do not have enough rights
    rutAuthClient.getSubsystem(Users.class).get();
  }
View Full Code Here

Examples of org.sonatype.nexus.client.core.NexusClient

      throws Exception
  {
    configureRemoteHeader("REMOTE_USER");
    configureSecurityRealms();

    final NexusClient rutAuthClient = createNexusClientForRemoteHeader("REMOTE_USER", "unknown");

    thrown.expect(NexusClientResponseException.class); // 401
    // we should not be able to access repositories as we do not have enough rights
    rutAuthClient.getSubsystem(Repositories.class).get();
  }
View Full Code Here

Examples of org.sonatype.nexus.client.core.NexusClient

  public void kenaiLogsInWithGoodCredentials()
      throws Exception
  {
    createKenaiBaseRoleIfNeeded();
    // see KenaiAuthcBehaviour: "authenticated" users are those having password = username + "123"
    final NexusClient kenaiAuthenticatedClient = createNexusClient(nexus(), "kenaiuser", "kenaiuser123");
    final Roles kenaiAuthenticatedRoles = kenaiAuthenticatedClient.getSubsystem(Roles.class);
    final Collection<Role> existingRoles = kenaiAuthenticatedRoles.get();
    // most likely redundant, as it all this above would not work, a NexusClientResponseException 401 would be
    // thrown at kenaiAuthenticatedRoles.get();
    assertThat(existingRoles, not(empty()));
  }
View Full Code Here

Examples of org.sonatype.nexus.client.core.NexusClient

      throws Exception
  {
    createKenaiBaseRoleIfNeeded();
    // see KenaiAuthcBehaviour: "authenticated" users are those having password = username + "123"
    // this user below will have BAD credentials
    final NexusClient kenaiAuthenticatedClient = createNexusClient(nexus(), "kenaiuser", "kenaiuserABC");
    assertThat("Line above should throw NexusClientResponseException with 401 response!", false);
  }
View Full Code Here

Examples of org.sonatype.nexus.client.core.NexusClient

  @Test
  public void testUserWithSingleQuotePassword() {
    Users users = client().getSubsystem(Users.class);
    String password = "\"";
    users.create("test").withPassword(password).withRole("nx-admin").withEmail("no@where.com").save();
    NexusClient client = createNexusClient(nexus(), "test", password);
    //will fail if can't authenticate
    Assert.assertThat(client.getNexusStatus(), Is.is(notNullValue()));
  }
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.