Comments (2)
@Assafkalfa I do not remember how the code under test was working but the test was implemented quite simply (based on the code in PR #15 :
@Rule
public final FakeSftpServerRule sftpServer = new FakeSftpServerRule();
@Test
public void should_send_file() throws Exception {
// add identity
Path authorizedKeysPath = Paths.get(FtrServiceTest.class.getResource("/unit-test-user.pub").toURI());
sftpServer.addIdentity("jon.snow", authorizedKeysPath);
// call code under test
//check
assertTrue("remote file not found", sftpServer.existsFile("/666_myfile.txt"));
}
It was a one time usage so I cannot help you on other usage of this component.
from fake-sftp-server-rule.
I know it's a little old (and using junit4) but I find a way to use a public key:
download the source (only one file) from the git and add to 'startServer' after 'setPort':
SimpleGeneratorHostKeyProvider keyPairProvider = hostKeyPath != null ? new SimpleGeneratorHostKeyProvider(hostKeyPath)
: new SimpleGeneratorHostKeyProvider();
server.setKeyPairProvider(keyPairProvider);
server.setPublickeyAuthenticator(new AuthorizedKeysAuthenticator(new File(hostKeyPath.toString())));
of course, add private Path hostKeyPath = null in the variables and a setter:
public FakeSftpServerRule setHostKeyPath(Path hostKeyPath) {
this.hostKeyPath = hostKeyPath;
if (server != null)
restartServer();
return this;
}
from fake-sftp-server-rule.
Related Issues (20)
- TestNG support HOT 3
- incompatibility with sshd-core 2.0.0 HOT 3
- junit5 compatible version HOT 9
- Require to use the fake sftp server with java 1.7 HOT 1
- Known host file not configured, using user known host file: C:\Users\Sam/.ssh/known_hosts HOT 2
- ServiceConfigurationError when calling @Rule HOT 1
- PowerMock and FakeSftpServerRule Server wont start HOT 1
- Support Junit5 Jupiter HOT 2
- Getting Software caused connection abort: socket write error HOT 1
- Set file modification time during upload
- Get a directory listing or use wildcard with existsFile
- How to simulate failure scenario ? HOT 3
- FakeSftpServerRule.createDirectory should accept a varargs parameter HOT 2
- Support for junit 5 HOT 1
- pom dependency error com.github.marschall 1.0.1-SNAPSHOT HOT 1
- Cleaning file system HOT 6
- Support for user accounts/testing credentials HOT 1
- fake-sftp-server-rule compatible with java 7 HOT 1
- multiple errors HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fake-sftp-server-rule.