karelia/ConnectionKit

Unit tests for SFTP protocol

Closed this issue · 3 comments

Need some tests for the CK2 SFTP implementation

I have some tests uncommitted that run against my local SSH server. The question is, how to avoid checking in your password as part of that?

The way I usually do it is to read the password from NSUserDefaults.

If the value is missing, assert with an error telling the user to run defaults write otest CK2SFTPTestPassword <pass>" from the command-line to set the password.

E.g, from CURLProtocolTests:

NSString* ftpTest = [[NSUserDefaults standardUserDefaults] objectForKey:@"CURLHandleTestsFTPServer"];
STAssertNotNil(ftpTest, @"need to set a test server address using defaults, e.g: defaults write otest CURLHandleTestsFTPServer \"ftp://user:password@ftp.test.com\"");

Alternatively, it might be possible to run another instance of sshd on a custom port as a normal user, then have the test use that. The first answer is probably easier though :)