James Moger
2014-04-11 e5d6095f0d804cb62d00fbb164f7c49371d412d6
Add missing unit test utility class
1 files added
33 ■■■■■ changed files
src/test/java/com/gitblit/tests/JschConfigTestSessionFactory.java 33 ●●●●● patch | view | raw | blame | history
src/test/java/com/gitblit/tests/JschConfigTestSessionFactory.java
New file
@@ -0,0 +1,33 @@
package com.gitblit.tests;
import java.security.KeyPair;
import org.eclipse.jgit.transport.JschConfigSessionFactory;
import org.eclipse.jgit.transport.OpenSshConfig;
import org.eclipse.jgit.util.FS;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
public class JschConfigTestSessionFactory extends JschConfigSessionFactory {
    final KeyPair keyPair;
    public JschConfigTestSessionFactory(KeyPair keyPair) {
        this.keyPair = keyPair;
    }
    @Override
    protected void configure(OpenSshConfig.Host host, Session session) {
        session.setConfig("StrictHostKeyChecking", "no");
    }
    @Override
    protected JSch getJSch(final OpenSshConfig.Host hc, FS fs) throws JSchException {
        JSch jsch = super.getJSch(hc, fs);
//        jsch.removeAllIdentity();
//        jsch.addIdentity("unittest", keyPair.getPrivate().getEncoded(), keyPair.getPublic().getEncoded(), null);
        return jsch;
    }
}