Examples of GlobalConfigurationResource


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

  }

  private void setupProxyConfig()
      throws IOException
  {
    final GlobalConfigurationResource resource = SettingsMessageUtil.getCurrentSettings();

    RemoteProxySettingsDTO proxy = resource.getRemoteProxySettings();

    if (proxy == null) {
      proxy = new RemoteProxySettingsDTO();
      resource.setRemoteProxySettings(proxy);
    }

    proxy.setHttpProxySettings(new RemoteHttpProxySettingsDTO());
    proxy.getHttpProxySettings().setProxyHostname("http://somejunkproxyurl");
    proxy.getHttpProxySettings().setProxyPort(555);
View Full Code Here

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

  }

  private void setAnonymousAccess(boolean enabled)
      throws Exception
  {
    GlobalConfigurationResource settings = SettingsMessageUtil.getCurrentSettings();
    settings.setSecurityAnonymousAccessEnabled(enabled);
    SettingsMessageUtil.save(settings);
  }
View Full Code Here

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

  @Test
  public void testCase1()
      throws Exception
  {
    // disable anonymous access
    GlobalConfigurationResource settings = SettingsMessageUtil.getCurrentSettings();
    settings.setSecurityAnonymousAccessEnabled(false);
    SettingsMessageUtil.save(settings);

    Status responseStatus;

    // verify assumptions, we have the stuff deployed and present
View Full Code Here

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

  @Override
  protected void runOnce()
      throws Exception
  {
    TestContainer.getInstance().getTestContext().useAdminForRequests();
    GlobalConfigurationResource settings = SettingsMessageUtil.getCurrentSettings();
    settings.setSecurityAnonymousAccessEnabled(false);
    SettingsMessageUtil.save(settings);
  }
View Full Code Here

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

{
  @Test
  public void checkNonProxyHosts()
      throws Exception
  {
    GlobalConfigurationResource settings = SettingsMessageUtil.getCurrentSettings();

    settings.setRemoteProxySettings(new RemoteProxySettingsDTO());
    settings.getRemoteProxySettings().setHttpProxySettings(new RemoteHttpProxySettingsDTO());
    settings.getRemoteProxySettings().getHttpProxySettings().setProxyHostname("proxyHost");
    settings.getRemoteProxySettings().getHttpProxySettings().setProxyPort(3211);
    settings.getRemoteProxySettings().addNonProxyHost("foo");
    settings.getRemoteProxySettings().addNonProxyHost("bar");

    Assert.assertEquals(204, SettingsMessageUtil.save(settings).getCode());

    settings = SettingsMessageUtil.getCurrentSettings();
    Assert.assertEquals(2, settings.getRemoteProxySettings().getNonProxyHosts().size());

    CRemoteProxySettings proxySettings = getNexusConfigUtil().getNexusConfig().getRemoteProxySettings();
    Assert.assertEquals(proxySettings.getNonProxyHosts().get(0), "foo");
    Assert.assertEquals(proxySettings.getNonProxyHosts().get(1), "bar");
    Assert.assertEquals(2, proxySettings.getNonProxyHosts().size());
View Full Code Here

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

    invokeAsAdministrator(new Callable<Object>()
    {
      @Override
      public Object call() throws Exception {
        final GlobalConfigurationResource globalConfig = SettingsMessageUtil.getCurrentSettings();
        if (shouldBeAdmin) {
          globalConfig.setSecurityAnonymousAccessEnabled(true);
          SettingsMessageUtil.save(globalConfig);
        }

        UserResource user = getUser(globalConfig.getSecurityAnonymousUsername());

        if (shouldBeAdmin) {
          if (!user.getRoles().contains(ADMIN_ROLE)) {
            user.addRole(ADMIN_ROLE);
            updateUser(user);
View Full Code Here

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

  public boolean isAnonymousAdministrator() throws Exception {
    return invokeAsAdministrator(new Callable<Boolean>()
    {
      @Override
      public Boolean call() throws Exception {
        final GlobalConfigurationResource globalConfig = SettingsMessageUtil.getCurrentSettings();
        return getUser(globalConfig.getSecurityAnonymousUsername()).getRoles().contains(ADMIN_ROLE);
      }
    });
  }
View Full Code Here

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

  @Test
  public void checkNonProxyHostsEmptyAndNulls()
      throws Exception
  {
    GlobalConfigurationResource settings = SettingsMessageUtil.getCurrentSettings();

    settings.setRemoteProxySettings(new RemoteProxySettingsDTO());
    settings.getRemoteProxySettings().setHttpProxySettings(new RemoteHttpProxySettingsDTO());
    settings.getRemoteProxySettings().getHttpProxySettings().setProxyHostname("proxyHost");
    settings.getRemoteProxySettings().getHttpProxySettings().setProxyPort(3211);
    settings.getRemoteProxySettings().addNonProxyHost("");
    settings.getRemoteProxySettings().addNonProxyHost("foo");
    settings.getRemoteProxySettings().addNonProxyHost(null);

    Assert.assertEquals(204, SettingsMessageUtil.save(settings).getCode());

    settings = SettingsMessageUtil.getCurrentSettings();
    Assert.assertEquals(1, settings.getRemoteProxySettings().getNonProxyHosts().size());

    CRemoteProxySettings proxySettings = getNexusConfigUtil().getNexusConfig().getRemoteProxySettings();
    Assert.assertEquals(proxySettings.getNonProxyHosts().get(0), "foo");
    Assert.assertEquals(1, proxySettings.getNonProxyHosts().size());
  }
View Full Code Here

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

  @Test
  public void checkNonProxyHostsEmpty()
      throws Exception
  {
    GlobalConfigurationResource settings = SettingsMessageUtil.getCurrentSettings();

    settings.setRemoteProxySettings(new RemoteProxySettingsDTO());
    settings.getRemoteProxySettings().setHttpProxySettings(new RemoteHttpProxySettingsDTO());
    settings.getRemoteProxySettings().getHttpProxySettings().setProxyHostname("proxyHost");
    settings.getRemoteProxySettings().getHttpProxySettings().setProxyPort(3211);
    settings.getRemoteProxySettings().getNonProxyHosts().clear();

    Assert.assertEquals(204, SettingsMessageUtil.save(settings).getCode());

    settings = SettingsMessageUtil.getCurrentSettings();
    Assert.assertEquals(0, settings.getRemoteProxySettings().getNonProxyHosts().size());

    CRemoteProxySettings proxySettings = getNexusConfigUtil().getNexusConfig().getRemoteProxySettings();
    Assert.assertEquals(0, proxySettings.getNonProxyHosts().size());
  }
View Full Code Here

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

{
  @Test
  public void checkRestApiConfig()
      throws Exception
  {
    GlobalConfigurationResource settings = SettingsMessageUtil.getCurrentSettings();

    // *NEXUS-3840
    assertEquals(settings.getGlobalRestApiSettings().getUiTimeout(), 60);
    // *

    Assert.assertNotNull(settings.getGlobalRestApiSettings());

    // enable it, not that even the baseUrl is not set, it will be filled with a defaut one
    RestApiSettings restApiSettings = new RestApiSettings();
    settings.setGlobalRestApiSettings(restApiSettings);
    SettingsMessageUtil.save(settings);
    settings = SettingsMessageUtil.getCurrentSettings();

    Assert.assertNotNull(settings.getGlobalRestApiSettings());
    Assert.assertTrue(StringUtils.isNotEmpty(settings.getGlobalRestApiSettings().getBaseUrl()));
    Assert.assertEquals(settings.getGlobalRestApiSettings().isForceBaseUrl(), false);

    // now edit it
    restApiSettings.setBaseUrl("http://myhost/nexus");
    restApiSettings.setForceBaseUrl(true);
    settings.setGlobalRestApiSettings(restApiSettings);
    SettingsMessageUtil.save(settings);
    settings = SettingsMessageUtil.getCurrentSettings();

    Assert.assertNotNull(settings.getGlobalRestApiSettings());
    Assert.assertEquals(settings.getGlobalRestApiSettings().getBaseUrl(), "http://myhost/nexus");
    Assert.assertEquals(settings.getGlobalRestApiSettings().isForceBaseUrl(), true);

    //now unset it
    settings.setGlobalRestApiSettings(null);
    SettingsMessageUtil.save(settings);

    Assert.assertNull(settings.getGlobalRestApiSettings());
  }
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.