Search in sources :

Example 31 with FileTransferClient

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

the class RelaxedFtpCase method tearDown.

@After
public void tearDown() throws Exception {
    if (areTestsEnabled()) {
        FileTransferClient client = connectRawClient();
        cleanup(client, getRemoteDirectory());
        client.rmdir(getRemoteDirectory());
        client.disconnect();
    }
}
Also used : FileTransferClient(com.adaptris.filetransfer.FileTransferClient) After(org.junit.After)

Example 32 with FileTransferClient

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

the class StandardSftpConnectionTest method testConnectOnly_Composite_Fails.

@Test
public void testConnectOnly_Composite_Fails() throws Exception {
    Assume.assumeTrue(areTestsEnabled());
    StandardSftpConnection conn = createConnection();
    SftpAuthenticationWrapper auth = new SftpAuthenticationWrapper(new SftpKeyAuthentication(PROPERTIES.getProperty(CFG_PRIVATE_KEY_FILE), "PW:abde"), new SftpKeyAuthentication("/some/path/that/does/not/exist", PROPERTIES.getProperty(CFG_PRIVATE_KEY_PW)));
    conn.setAuthentication(auth);
    try {
        start(conn);
        FileTransferClient c = conn.connect(getDestinationString());
        fail();
    } catch (IOException | PasswordException expected) {
    } finally {
        stop(conn);
    }
}
Also used : PasswordException(com.adaptris.security.exc.PasswordException) FileTransferClient(com.adaptris.filetransfer.FileTransferClient) IOException(java.io.IOException) Test(org.junit.Test)

Example 33 with FileTransferClient

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

the class StandardSftpConnectionTest method testConnectOnly_StrictKnownHosts_UnknownHost.

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

Example 34 with FileTransferClient

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

the class StandardSftpConnectionTest method testConnectOnly_LenientKnownHosts_KnownHost.

@Test
public void testConnectOnly_LenientKnownHosts_KnownHost() throws Exception {
    Assume.assumeTrue(areTestsEnabled());
    File tempHostsFile = copyHostsFile(new File(PROPERTIES.getProperty(CFG_KNOWN_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 35 with FileTransferClient

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

the class StandardSftpConnectionTest method testConnectOnly_PasswordAuth_Override.

@Test
public void testConnectOnly_PasswordAuth_Override() throws Exception {
    Assume.assumeTrue(areTestsEnabled());
    StandardSftpConnection conn = createConnection();
    try {
        conn.setAuthentication(new SftpPasswordAuthentication(""));
        start(conn);
        FileTransferClient c = conn.connect(getDestinationStringWithOverridePassword());
        assertTrue(c.isConnected());
        c.disconnect();
    } finally {
        stop(conn);
    }
}
Also used : FileTransferClient(com.adaptris.filetransfer.FileTransferClient) 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