Skip to content

Commit 54376b7

Browse files
committed
Add SFTP integration test
Signed-off-by: Jeroen van Erp <[email protected]>
1 parent f0e92c9 commit 54376b7

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (C)2009 - SSHJ Contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.hierynomus.sshj.sftp;
17+
18+
import static org.junit.Assert.assertFalse;
19+
import static org.junit.Assert.assertNull;
20+
21+
import org.junit.jupiter.api.Test;
22+
import org.testcontainers.junit.jupiter.Container;
23+
import org.testcontainers.junit.jupiter.Testcontainers;
24+
25+
import com.hierynomus.sshj.SshdContainer;
26+
27+
import net.schmizz.sshj.SSHClient;
28+
import net.schmizz.sshj.sftp.FileAttributes;
29+
import net.schmizz.sshj.sftp.SFTPClient;
30+
31+
@Testcontainers
32+
public class SftpIntegrationTest {
33+
@Container
34+
private static SshdContainer sshd = new SshdContainer();
35+
36+
@Test
37+
public void shouldCheckFileExistsForNonExistingFile_GH894() throws Throwable {
38+
try (SSHClient client = sshd.getConnectedClient()) {
39+
client.authPublickey("sshj", "src/test/resources/id_rsa");
40+
try (SFTPClient sftp = client.newSFTPClient()) {
41+
String file = "/home/sshj/i_do_not_exist.txt";
42+
FileAttributes exists = sftp.statExistence(file);
43+
assertNull(exists);
44+
}
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)