Search in sources :

Example 26 with SVNURL

use of org.tmatesoft.svn.core.SVNURL in project intellij-community by JetBrains.

the class SvnUtilTest method testUrlAppend.

public void testUrlAppend() throws Exception {
    final SVNURL base = SVNURL.parseURIDecoded(URL1);
    final String subPath = "/one more space/and more";
    final SVNURL url1 = SvnUtil.appendMultiParts(base, subPath);
    Assert.assertEquals(SVNURL.parseURIDecoded(URL1 + subPath), url1);
    final SVNURL base1 = SVNURL.parseURIDecoded(URL2);
    final String subPath1 = "/one\\more\\space/and/more";
    final SVNURL url2 = SvnUtil.appendMultiParts(base1, subPath1);
    Assert.assertEquals(SVNURL.parseURIDecoded(URL2 + subPath1.replace('\\', '/')), url2);
    final String result = SVNPathUtil.append("http://one", "test/multi/parts");
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL)

Example 27 with SVNURL

use of org.tmatesoft.svn.core.SVNURL 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);
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL) SVNException(org.tmatesoft.svn.core.SVNException)

Example 28 with SVNURL

use of org.tmatesoft.svn.core.SVNURL 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);
    }
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL) SVNException(org.tmatesoft.svn.core.SVNException) SVNConfigFile(org.tmatesoft.svn.core.internal.wc.SVNConfigFile) File(java.io.File)

Example 29 with SVNURL

use of org.tmatesoft.svn.core.SVNURL in project intellij-community by JetBrains.

the class SvnIntegrateRootOptionsPanel method chooseUrl.

private boolean chooseUrl(final TextFieldWithBrowseButton textField, final SvnVcs vcs) {
    String url = textField.getText();
    SVNURL selectedUrl = SelectLocationDialog.selectLocation(vcs.getProject(), url);
    if (selectedUrl != null) {
        textField.setText(selectedUrl.toString());
        return true;
    } else {
        return false;
    }
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL)

Example 30 with SVNURL

use of org.tmatesoft.svn.core.SVNURL in project intellij-community by JetBrains.

the class SvnAuthenticationTest method testWhenAuthCredsNoInServers.

public void testWhenAuthCredsNoInServers() 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-auth-creds=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));
                commonScheme(url, false, null);
                Assert.assertEquals(2, listener.getCnt());
                Assert.assertEquals(1, myTestInteraction.getNumAuthWarn());
                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));
                commonScheme(url, false, null);
                Assert.assertEquals(4, listener.getCnt());
                Assert.assertEquals(1, myTestInteraction.getNumAuthWarn());
            } catch (SVNException e) {
                exception[0] = e;
            }
            result[0] = true;
        });
        Assert.assertTrue(result[0]);
        Assert.assertEquals(1, myTestInteraction.getNumAuthWarn());
        Assert.assertEquals(4, listener.getCnt());
        listener.assertForAwt();
        savedOnceListener.assertForAwt();
        savedOnceListener.assertNotSaved(url, ISVNAuthenticationManager.PASSWORD);
        if (exception[0] != null) {
            throw exception[0];
        }
    } finally {
        FileUtil.delete(servers);
        FileUtil.rename(oldServers, servers);
    }
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL) SVNException(org.tmatesoft.svn.core.SVNException) SVNConfigFile(org.tmatesoft.svn.core.internal.wc.SVNConfigFile) File(java.io.File)

Aggregations

SVNURL (org.tmatesoft.svn.core.SVNURL)93 SVNException (org.tmatesoft.svn.core.SVNException)37 File (java.io.File)31 SVNConfigFile (org.tmatesoft.svn.core.internal.wc.SVNConfigFile)15 VirtualFile (com.intellij.openapi.vfs.VirtualFile)13 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)8 VcsException (com.intellij.openapi.vcs.VcsException)7 Nullable (org.jetbrains.annotations.Nullable)7 SVNRevision (org.tmatesoft.svn.core.wc.SVNRevision)7 SvnTarget (org.tmatesoft.svn.core.wc2.SvnTarget)7 ArrayList (java.util.ArrayList)6 NotNull (org.jetbrains.annotations.NotNull)6 Info (org.jetbrains.idea.svn.info.Info)6 SvnBindException (org.jetbrains.idea.svn.commandLine.SvnBindException)5 FilePath (com.intellij.openapi.vcs.FilePath)4 SvnVcs (org.jetbrains.idea.svn.SvnVcs)3 SvnAuthenticationManager (org.jetbrains.idea.svn.auth.SvnAuthenticationManager)3 SVNDirEntry (org.tmatesoft.svn.core.SVNDirEntry)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 Project (com.intellij.openapi.project.Project)2