@Override
 protected void runOnce() throws Exception {
   // disable anonymous access
   GlobalConfigurationResource settings = SettingsMessageUtil.getCurrentSettings();
   settings.setSecurityAnonymousAccessEnabled(false);
   SettingsMessageUtil.save(settings);
 }
  @Test
  public void wrongAnonymousAccount() throws Exception {
    TestContainer.getInstance().getTestContext().useAdminForRequests();

    GlobalConfigurationResource globalConfig = SettingsMessageUtil.getCurrentSettings();
    globalConfig.setSecurityAnonymousUsername("zigfrid");

    Status status = SettingsMessageUtil.save(globalConfig);
    Assert.assertEquals(status.getCode(), 400, "Can't set an invalid user as anonymous");
  }
예제 #3
0
  @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());
  }
 private void setAnonymousAccess(boolean enabled) throws Exception {
   GlobalConfigurationResource settings = SettingsMessageUtil.getCurrentSettings();
   settings.setSecurityAnonymousAccessEnabled(enabled);
   SettingsMessageUtil.save(settings);
 }