use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnAuthenticationTest method testWhenNotSaved.
public void testWhenNotSaved() throws Exception {
final TestListener listener = new TestListener(mySynchObject);
myAuthenticationManager.addListener(listener);
final SavedOnceListener savedOnceListener = new SavedOnceListener();
myAuthenticationManager.addListener(savedOnceListener);
myInteractiveProvider.setSaveData(false);
final SVNURL url = SVNURL.parseURIEncoded("http://some.host.com/repo");
final SVNException[] exception = new SVNException[1];
final Boolean[] result = new Boolean[1];
synchronousBackground(() -> {
try {
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
commonScheme(url, false, null);
//long start = System.currentTimeMillis();
//waitListenerStep(start, listener, 2);
Assert.assertEquals(2, listener.getCnt());
savedOnceListener.assertNotSaved(url, ISVNAuthenticationManager.PASSWORD);
// cause is not cleared though
savedOnceListener.reset();
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
commonScheme(url, false, null);
Assert.assertEquals(4, listener.getCnt());
//start = System.currentTimeMillis();
//waitListenerStep(start, listener, 4);
} catch (SVNException e) {
exception[0] = e;
}
result[0] = true;
});
Assert.assertTrue(result[0]);
myTestInteraction.assertNothing();
Assert.assertEquals(4, listener.getCnt());
listener.assertForAwt();
savedOnceListener.assertForAwt();
savedOnceListener.assertNotSaved(url, ISVNAuthenticationManager.PASSWORD);
if (exception[0] != null) {
throw exception[0];
}
}
use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnAuthenticationTest method testWhenPassPhraseSaveNo.
public void testWhenPassPhraseSaveNo() throws Exception {
final TestListener listener = new TestListener(mySynchObject);
myAuthenticationManager.addListener(listener);
final SavedOnceListener savedOnceListener = new SavedOnceListener();
myAuthenticationManager.addListener(savedOnceListener);
final File servers = new File(myConfiguration.getConfigurationDirectory(), "servers");
final File oldServers = new File(myConfiguration.getConfigurationDirectory(), "config_old");
FileUtil.copy(servers, oldServers);
try {
FileUtil.appendToFile(servers, "\nstore-ssl-client-cert-pp=no\n");
final SVNURL url = SVNURL.parseURIEncoded("https://some.host.com/repo");
final SVNException[] exception = new SVNException[1];
final Boolean[] result = new Boolean[1];
synchronousBackground(() -> {
try {
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
commonScheme(url, false, null);
Assert.assertEquals(3, listener.getCnt());
Assert.assertEquals(1, myTestInteraction.getNumSSLWarn());
myTestInteraction.reset();
savedOnceListener.assertForAwt();
savedOnceListener.reset();
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
commonScheme(url, false, null);
Assert.assertEquals(6, listener.getCnt());
Assert.assertEquals(1, myTestInteraction.getNumSSLWarn());
} catch (SVNException e) {
exception[0] = e;
}
result[0] = true;
});
Assert.assertTrue(result[0]);
Assert.assertEquals(1, myTestInteraction.getNumSSLWarn());
Assert.assertEquals(6, listener.getCnt());
listener.assertForAwt();
savedOnceListener.assertForAwt();
savedOnceListener.assertSaved(url, ISVNAuthenticationManager.SSL);
if (exception[0] != null) {
throw exception[0];
}
} finally {
FileUtil.delete(servers);
FileUtil.rename(oldServers, servers);
}
}
use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnAuthenticationTest method testWhenPassSaveNoInServers.
public void testWhenPassSaveNoInServers() throws Exception {
final TestListener listener = new TestListener(mySynchObject);
myAuthenticationManager.addListener(listener);
final SavedOnceListener savedOnceListener = new SavedOnceListener();
myAuthenticationManager.addListener(savedOnceListener);
final File servers = new File(myConfiguration.getConfigurationDirectory(), "servers");
final File oldServers = new File(myConfiguration.getConfigurationDirectory(), "config_old");
FileUtil.copy(servers, oldServers);
try {
FileUtil.appendToFile(servers, "\nstore-passwords=no\n");
final SVNURL url = SVNURL.parseURIEncoded("http://some.host.com/repo");
final SVNException[] exception = new SVNException[1];
final Boolean[] result = new Boolean[1];
synchronousBackground(() -> {
try {
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
commonScheme(url, false, null);
Assert.assertEquals(3, listener.getCnt());
Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
myTestInteraction.reset();
savedOnceListener.assertForAwt();
savedOnceListener.reset();
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
commonScheme(url, false, null);
Assert.assertEquals(6, listener.getCnt());
Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
} catch (SVNException e) {
exception[0] = e;
}
result[0] = true;
});
Assert.assertTrue(result[0]);
Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
Assert.assertEquals(6, listener.getCnt());
listener.assertForAwt();
savedOnceListener.assertForAwt();
savedOnceListener.assertSaved(url, ISVNAuthenticationManager.PASSWORD);
if (exception[0] != null) {
throw exception[0];
}
} finally {
FileUtil.delete(servers);
FileUtil.rename(oldServers, servers);
}
}
use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnAuthenticationTest method testWhenPassSaveNoInConfig.
public void testWhenPassSaveNoInConfig() throws Exception {
final TestListener listener = new TestListener(mySynchObject);
myAuthenticationManager.addListener(listener);
final SavedOnceListener savedOnceListener = new SavedOnceListener();
myAuthenticationManager.addListener(savedOnceListener);
final File config = new File(myConfiguration.getConfigurationDirectory(), "config");
final String contents = FileUtil.loadFile(config);
final String auth = "[auth]";
final int idx = contents.indexOf(auth);
Assert.assertTrue(idx != -1);
final String newContents = contents.substring(0, idx + auth.length()) + "\nstore-passwords=no\n" + contents.substring(idx + auth.length());
final File oldConfig = new File(myConfiguration.getConfigurationDirectory(), "config_old");
FileUtil.rename(config, oldConfig);
try {
config.createNewFile();
FileUtil.appendToFile(config, newContents);
final SVNURL url = SVNURL.parseURIEncoded("http://some.host.com/repo");
final SVNException[] exception = new SVNException[1];
final Boolean[] result = new Boolean[1];
synchronousBackground(() -> {
try {
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
commonScheme(url, false, null);
Assert.assertEquals(3, listener.getCnt());
Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
myTestInteraction.reset();
savedOnceListener.assertForAwt();
savedOnceListener.reset();
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
commonScheme(url, false, null);
Assert.assertEquals(6, listener.getCnt());
Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
} catch (SVNException e) {
exception[0] = e;
}
result[0] = true;
});
Assert.assertTrue(result[0]);
Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
Assert.assertEquals(6, listener.getCnt());
listener.assertForAwt();
savedOnceListener.assertForAwt();
savedOnceListener.assertSaved(url, ISVNAuthenticationManager.PASSWORD);
if (exception[0] != null) {
throw exception[0];
}
} finally {
FileUtil.delete(config);
FileUtil.rename(oldConfig, config);
}
}
use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnAuthenticationTest method testWhenPassSaveNoForGroup.
public void testWhenPassSaveNoForGroup() throws Exception {
final TestListener listener = new TestListener(mySynchObject);
myAuthenticationManager.addListener(listener);
final SavedOnceListener savedOnceListener = new SavedOnceListener();
myAuthenticationManager.addListener(savedOnceListener);
final File servers = new File(myConfiguration.getConfigurationDirectory(), "servers");
final String contents = FileUtil.loadFile(servers);
final String groups = "[groups]";
final int idx = contents.indexOf(groups);
Assert.assertTrue(idx != -1);
final String newContents = contents.substring(0, idx + groups.length()) + "\nsomegroup=some*\n" + contents.substring(idx + groups.length()) + "\n[somegroup]\nstore-passwords=no\n";
final File oldServers = new File(myConfiguration.getConfigurationDirectory(), "config_old");
FileUtil.rename(servers, oldServers);
try {
servers.createNewFile();
FileUtil.appendToFile(servers, newContents);
final SVNURL url = SVNURL.parseURIEncoded("http://some.host.com/repo");
final SVNException[] exception = new SVNException[1];
final Boolean[] result = new Boolean[1];
synchronousBackground(() -> {
try {
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
commonScheme(url, false, null);
Assert.assertEquals(3, listener.getCnt());
Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
myTestInteraction.reset();
savedOnceListener.assertForAwt();
savedOnceListener.reset();
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
commonScheme(url, false, null);
Assert.assertEquals(6, listener.getCnt());
Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
} catch (SVNException e) {
exception[0] = e;
}
result[0] = true;
});
Assert.assertTrue(result[0]);
Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
Assert.assertEquals(6, listener.getCnt());
listener.assertForAwt();
savedOnceListener.assertForAwt();
savedOnceListener.assertSaved(url, ISVNAuthenticationManager.PASSWORD);
if (exception[0] != null) {
throw exception[0];
}
} finally {
FileUtil.delete(servers);
FileUtil.rename(oldServers, servers);
}
}
Aggregations