}
private void doTestLogic()
throws Exception
{
ApplicationConfigurationSource source = this.getConfigSource();
Configuration config = source.loadConfiguration();
// make sure the smtp-password is what we expect
Assert.assertEquals("Incorrect SMTP password found in nexus.xml", "smtp-password", config
.getSmtpConfiguration().getPassword());
// set the clear passwords
String password = "clear-text";
// smtp
config.getSmtpConfiguration().setPassword(password);
// global proxy
config.setRemoteProxySettings(new CRemoteProxySettings());
final CRemoteHttpProxySettings httpProxySettings = new CRemoteHttpProxySettings();
httpProxySettings.setProxyHostname("localhost");
httpProxySettings.setProxyPort(1234);
httpProxySettings.setAuthentication(new CRemoteAuthentication());
httpProxySettings.getAuthentication().setPassword(password);
final CRemoteHttpProxySettings httpsProxySettings = new CRemoteHttpProxySettings();
httpsProxySettings.setProxyHostname("localhost");
httpsProxySettings.setProxyPort(1234);
httpsProxySettings.setAuthentication(new CRemoteAuthentication());
httpsProxySettings.getAuthentication().setPassword(password);
config.getRemoteProxySettings().setHttpProxySettings(httpProxySettings);
config.getRemoteProxySettings().setHttpsProxySettings(httpsProxySettings);
// config.getSecurity().setAnonymousPassword( password );
//
// // anon username
// config.getSecurity().setAnonymousPassword( password );
// repo auth pass
CRepository central = this.getCentralRepo(config);
central.getRemoteStorage().setAuthentication(new CRemoteAuthentication());
central.getRemoteStorage().getAuthentication().setPassword(password);
// now we need to make the file valid....
config.getRemoteProxySettings().getHttpProxySettings().setProxyPort(1234);
// save it
source.storeConfiguration();
XStream xs = new XStream();
xs.processAnnotations(new Class[] { Xpp3Dom.class });
Assert.assertTrue("Configuration is corroupt, passwords are encrypted (in memory). ",
xs.toXML(config).contains(password));
// now get the file and look for the "clear-text"
String configString = FileUtils.readFileToString(new File(this.getNexusConfiguration()));
Assert.assertFalse("Clear text password found in nexus.xml:\n" + configString, configString
.contains(password));
// make sure we do not have the default smtp password either
Assert.assertFalse("Old SMTP password found in nexus.xml", configString.contains("smtp-password"));
// now load it again and make sure the password is clear text
Configuration newConfig = source.loadConfiguration();
Assert.assertEquals(password, newConfig.getSmtpConfiguration().getPassword());
Assert.assertEquals(
password, newConfig.getRemoteProxySettings().getHttpProxySettings().getAuthentication().getPassword()
);
Assert.assertEquals(