Search in sources :

Example 11 with FileTransferClient

use of com.adaptris.filetransfer.FileTransferClient in project interlok by adaptris.

the class StandardSftpConnectionTest method testConnectOnly_StrictKnownHosts_KnownHost.

@Test
public void testConnectOnly_StrictKnownHosts_KnownHost() throws Exception {
    Assume.assumeTrue(areTestsEnabled());
    File tempHostsFile = copyHostsFile(new File(PROPERTIES.getProperty(CFG_KNOWN_HOSTS_FILE)));
    StandardSftpConnection conn = createConnection();
    conn.setConfiguration(new InlineConfigRepositoryBuilder(true).build());
    conn.setKnownHostsFile(tempHostsFile.getCanonicalPath());
    try {
        start(conn);
        FileTransferClient c = conn.connect(getDestinationString());
        assertTrue(c.isConnected());
        c.disconnect();
    } finally {
        stop(conn);
    }
}
Also used : FileTransferClient(com.adaptris.filetransfer.FileTransferClient) File(java.io.File) Test(org.junit.Test)

Example 12 with FileTransferClient

use of com.adaptris.filetransfer.FileTransferClient in project interlok by adaptris.

the class StandardSftpConnectionTest method testConnectOnly_LenientKnownHosts_UnknownHost.

@Test
public void testConnectOnly_LenientKnownHosts_UnknownHost() throws Exception {
    Assume.assumeTrue(areTestsEnabled());
    File tempHostsFile = copyHostsFile(new File(PROPERTIES.getProperty(CFG_UNKNOWN_HOSTS_FILE)));
    StandardSftpConnection conn = createConnection();
    conn.setConfiguration(new InlineConfigRepositoryBuilder(false).build());
    conn.setKnownHostsFile(tempHostsFile.getCanonicalPath());
    try {
        start(conn);
        FileTransferClient c = conn.connect(getDestinationString());
        assertTrue(c.isConnected());
        c.disconnect();
    } finally {
        stop(conn);
    }
}
Also used : FileTransferClient(com.adaptris.filetransfer.FileTransferClient) File(java.io.File) Test(org.junit.Test)

Example 13 with FileTransferClient

use of com.adaptris.filetransfer.FileTransferClient in project interlok by adaptris.

the class FtpPasswordConnectionCase method testConnect_BadEncodedPassword.

@Test
public void testConnect_BadEncodedPassword() throws Exception {
    Assume.assumeTrue(areTestsEnabled());
    FileTransferConnectionUsingPassword connection = (FileTransferConnectionUsingPassword) createConnection();
    connection.setDefaultPassword("PW:BHFYENGMWEYQ");
    try {
        start(connection);
        FileTransferClient client = connection.connect(getDestinationString());
        fail();
    } catch (IOException | PasswordException expected) {
    } finally {
        stop(connection);
    }
}
Also used : PasswordException(com.adaptris.security.exc.PasswordException) FileTransferClient(com.adaptris.filetransfer.FileTransferClient) IOException(java.io.IOException) Test(org.junit.Test)

Example 14 with FileTransferClient

use of com.adaptris.filetransfer.FileTransferClient in project interlok by adaptris.

the class FtpPasswordConnectionCase method testConnect_PasswordOverride.

@Test
public void testConnect_PasswordOverride() throws Exception {
    Assume.assumeTrue(areTestsEnabled());
    FileTransferConnectionUsingPassword connection = (FileTransferConnectionUsingPassword) createConnection();
    connection.setDefaultPassword(null);
    try {
        start(connection);
        log.trace("testConnection_PasswordOverride = " + getDestinationStringWithOverride());
        FileTransferClient client = connection.connect(getDestinationStringWithOverride());
    } finally {
        stop(connection);
    }
}
Also used : FileTransferClient(com.adaptris.filetransfer.FileTransferClient) Test(org.junit.Test)

Example 15 with FileTransferClient

use of com.adaptris.filetransfer.FileTransferClient in project interlok by adaptris.

the class FtpPasswordConnectionCase method testConnect_NoPassword.

@Test
public void testConnect_NoPassword() throws Exception {
    Assume.assumeTrue(areTestsEnabled());
    FileTransferConnectionUsingPassword connection = (FileTransferConnectionUsingPassword) createConnection();
    connection.setDefaultPassword(null);
    try {
        start(connection);
        FileTransferClient client = connection.connect(getDestinationString());
        fail();
    } catch (Exception expected) {
    } finally {
        stop(connection);
    }
}
Also used : FileTransferClient(com.adaptris.filetransfer.FileTransferClient) IOException(java.io.IOException) PasswordException(com.adaptris.security.exc.PasswordException) Test(org.junit.Test)

Aggregations

FileTransferClient (com.adaptris.filetransfer.FileTransferClient)39 Test (org.junit.Test)30 File (java.io.File)4 IOException (java.io.IOException)4 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)3 PasswordException (com.adaptris.security.exc.PasswordException)3 CoreException (com.adaptris.core.CoreException)2 ProduceException (com.adaptris.core.ProduceException)2 CommonsNetFtpClient (com.adaptris.ftp.CommonsNetFtpClient)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 After (org.junit.After)2 InputFieldHint (com.adaptris.annotation.InputFieldHint)1 FileNameCreator (com.adaptris.core.FileNameCreator)1 ServiceException (com.adaptris.core.ServiceException)1 FileTransferException (com.adaptris.filetransfer.FileTransferException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 Random (java.util.Random)1