use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnAuthenticationTest method testPlaintextSSLPrompt.
public void testPlaintextSSLPrompt() throws Exception {
SVNJNAUtil.setJNAEnabled(false);
// yes, no
final TestListener listener = new TestListener(mySynchObject);
myAuthenticationManager.addListener(listener);
final SavedOnceListener savedOnceListener = new SavedOnceListener();
myAuthenticationManager.addListener(savedOnceListener);
myTestInteraction.setSSLPlaintextAnswer(true);
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.save));
commonScheme(url, false, null);
long start = System.currentTimeMillis();
waitListenerStep(start, listener, 3);
Assert.assertEquals(1, myTestInteraction.getNumSSLPlaintextPrompt());
savedOnceListener.assertSaved(url, ISVNAuthenticationManager.SSL);
savedOnceListener.reset();
myTestInteraction.reset();
UIUtil.invokeAndWaitIfNeeded((Runnable) () -> {
try {
clearAuthCache();
} catch (Exception e) {
throw new RuntimeException(e);
}
});
myTestInteraction.setSSLPlaintextAnswer(false);
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);
start = System.currentTimeMillis();
waitListenerStep(start, listener, 6);
Assert.assertEquals(1, myTestInteraction.getNumSSLPlaintextPrompt());
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
myTestInteraction.reset();
savedOnceListener.reset();
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);
start = System.currentTimeMillis();
waitListenerStep(start, listener, 9);
Assert.assertEquals(1, myTestInteraction.getNumSSLPlaintextPrompt());
} catch (SVNException e) {
exception[0] = e;
}
result[0] = true;
});
Assert.assertTrue(result[0]);
Assert.assertEquals(1, myTestInteraction.getNumSSLPlaintextPrompt());
Assert.assertEquals(9, listener.getCnt());
listener.assertForAwt();
savedOnceListener.assertForAwt();
savedOnceListener.assertSaved(url, ISVNAuthenticationManager.SSL);
if (exception[0] != null) {
throw exception[0];
}
SVNJNAUtil.setJNAEnabled(true);
}
use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnAuthenticationTest method testPlaintextPromptAndSecondPrompt.
public void testPlaintextPromptAndSecondPrompt() throws Exception {
SVNJNAUtil.setJNAEnabled(false);
// yes, no
final TestListener listener = new TestListener(mySynchObject);
myAuthenticationManager.addListener(listener);
final SavedOnceListener savedOnceListener = new SavedOnceListener();
myAuthenticationManager.addListener(savedOnceListener);
myTestInteraction.setPlaintextAnswer(false);
final SVNURL url = SVNURL.parseURIEncoded("http://some.host.com/repo");
final SVNURL url2 = SVNURL.parseURIEncoded("http://some.other.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);
long start = System.currentTimeMillis();
waitListenerStep(start, listener, 3);
Assert.assertEquals(1, myTestInteraction.getNumPlaintextPrompt());
// actually password not saved, but save was called
savedOnceListener.assertSaved(url, ISVNAuthenticationManager.PASSWORD);
savedOnceListener.reset();
myTestInteraction.reset();
listener.addStep(new Trinity<>(ProviderType.persistent, url2, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url2, Type.request));
listener.addStep(new Trinity<>(ProviderType.persistent, url2, Type.without_pasword_save));
commonScheme(url2, false, "anotherRealm");
start = System.currentTimeMillis();
waitListenerStep(start, listener, 6);
Assert.assertEquals(1, myTestInteraction.getNumPlaintextPrompt());
} catch (SVNException e) {
exception[0] = e;
}
result[0] = true;
});
Assert.assertTrue(result[0]);
Assert.assertEquals(1, myTestInteraction.getNumPlaintextPrompt());
Assert.assertEquals(6, listener.getCnt());
listener.assertForAwt();
savedOnceListener.assertForAwt();
// didn't called to save for 2nd time
savedOnceListener.assertNotSaved(url, ISVNAuthenticationManager.PASSWORD);
if (exception[0] != null) {
throw exception[0];
}
SVNJNAUtil.setJNAEnabled(true);
}
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);
}
}
use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnBusyOnAddTest method getStatus.
@Nullable
private String getStatus(final File ioFile) throws SVNException {
try {
SVNStatusClient readClient = new SVNStatusClient((ISVNRepositoryPool) null, new DefaultSVNOptions());
final SVNStatus status = readClient.doStatus(ioFile, false);
return status == null ? null : status.getNodeStatus().toString();
} catch (SVNException e) {
if (SVNErrorCode.WC_NOT_WORKING_COPY.equals(e.getErrorMessage().getErrorCode())) {
return null;
}
throw e;
}
}
use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnBusyOnAddTest method testStatusDoesNotLockForWrite.
public void testStatusDoesNotLockForWrite() throws Exception {
final File ioFile = new File(myWorkingCopyRoot, filename);
ioFile.getParentFile().mkdirs();
/*SVNWCClient client11 = new SVNWCClient((ISVNRepositoryPool)null, new DefaultSVNOptions());
client11.doAdd(ioFile.getParentFile(), true, false, true, true);*/
ioFile.createNewFile();
try {
final SVNStatusClient readClient = new SVNStatusClient((ISVNRepositoryPool) null, new DefaultSVNOptions());
final Semaphore semaphore = new Semaphore();
final Semaphore semaphoreMain = new Semaphore();
final Semaphore semaphoreWokeUp = new Semaphore();
final AtomicReference<Boolean> wasUp = new AtomicReference<>(false);
final ISVNStatusHandler handler = status -> {
semaphore.waitFor();
wasUp.set(true);
};
semaphore.down();
semaphoreMain.down();
semaphoreWokeUp.down();
final SVNException[] exception = new SVNException[1];
Thread thread = new Thread(() -> {
try {
semaphoreMain.up();
readClient.doStatus(myWorkingCopyRoot, true, false, true, false, handler);
semaphoreWokeUp.up();
} catch (SVNException e) {
exception[0] = e;
}
}, "svn test");
thread.start();
semaphoreMain.waitFor();
TimeoutUtil.sleep(5);
SVNWCClient client = new SVNWCClient((ISVNRepositoryPool) null, new DefaultSVNOptions());
client.doAdd(ioFile.getParentFile(), true, false, true, true);
semaphore.up();
semaphoreWokeUp.waitFor();
Assert.assertEquals(true, wasUp.get().booleanValue());
if (exception[0] != null) {
throw exception[0];
}
thread.join();
} finally {
ioFile.delete();
}
}
Aggregations