Package org.sonatype.nexus.client.core

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


   */
  @Test
  public void testLoginToSelfSignedLdapServer()
      throws Exception
  {
    final NexusClient nexusClient = getNexusClient();

    final LdapServerConfigurationDTO ldapServerConfig = getLdapServerConfiguration();
    final URI uri = getLdapServerUri(ldapServerConfig);

    // trust ldap server certificate
    nexusClient.getSubsystem(Certificates.class).get(uri.getHost(), uri.getPort(), uri.getScheme()).save();

    // disable Nexus TrustStore for default server
    nexusClient.getSubsystem(TrustStore.class).disableFor(ldapTrustStoreKey(ldapServerConfig.getId()));

    // test without sending the ldap server id. This will result in not using Nexus SSL Trust Store which
    // should result in a failure
    try {
      testLogin(ldapServerConfig, false);
      assertThat("Expected to fail with Exception", false);
    }
    catch (Exception e) {
      assertThat(e.getMessage(), containsString("unable to find valid certification path"));
    }

    // test with sending the ldap server id. Nexus SSL Trust Store will not be used as is not enabled
    // which should result in a failure
    try {
      testLogin(ldapServerConfig, true);
      assertThat("Expected to fail with Exception", false);
    }
    catch (Exception e) {
      assertThat(e.getMessage(), containsString("unable to find valid certification path"));
    }

    // enable Nexus TrustStore for default server
    nexusClient.getSubsystem(TrustStore.class).enableFor(ldapTrustStoreKey(ldapServerConfig.getId()));

    // test with sending the ldap server id. Nexus SSL Trust Store will be used as it is enabled
    // which should result in a success
    testLogin(ldapServerConfig, true);

View Full Code Here


    assertThat("Version read must not return null!", version, notNullValue());
    assertThat("Version read must not return the default (it should succeed in reading the stuff up)!", version,
        not(equalTo("foo")));

    final NexusClientFactory factory = new JerseyNexusClientFactory();
    final NexusClient client = factory.createFor(BaseUrl.baseUrlFrom("https://repository.sonatype.org/"));
    assertThat(client.getNexusStatus(), notNullValue());
    final String userAgent =
        (String) ((ApacheHttpClient4) ((JerseyNexusClient) client).getClient()).getClientHandler().getHttpClient()
            .getParams().getParameter(
                CoreProtocolPNames.USER_AGENT);
    assertThat("UA must not be null!", userAgent, notNullValue());
View Full Code Here

  @Test
  public void createWithGoodUrl()
      throws MalformedURLException
  {
    final NexusClientFactory factory = new JerseyNexusClientFactory();
    final NexusClient client = factory.createFor(BaseUrl.baseUrlFrom("https://repository.sonatype.org/"));
    Assert.assertNotNull(client.getNexusStatus());
  }
View Full Code Here

  {
    try {
      // RSO as NOT any modern instance? Impossible.
      final NexusClientFactory factory =
          new JerseyNexusClientFactory(LogicalConditions.not(NexusStatusConditions.anyModern()));
      final NexusClient client = factory.createFor(BaseUrl.baseUrlFrom("https://repository.sonatype.org/"));
    }
    catch (IllegalStateException e) {
      e.printStackTrace();
      throw e;
    }
View Full Code Here

    try {
      // RSO with version 1.0? No chance, those times has passed.
      final NexusClientFactory factory =
          new JerseyNexusClientFactory(LogicalConditions.and(EditionConditions.anyEdition(),
              VersionConditions.withVersion("[1.0]")));
      final NexusClient client = factory.createFor(BaseUrl.baseUrlFrom("https://repository.sonatype.org/"));
    }
    catch (IllegalStateException e) {
      e.printStackTrace();
      throw e;
    }
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.client.core.NexusClient

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.