Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

xsawyerx (8978)

  (email not shown publicly)

Journal of xsawyerx (8978)

Wednesday January 07, 2009
11:16 AM

Presenting Test::SFTP

[ #38230 ]
On a project at $work I was counting heavily on Net::SFTP to upload to, download from or check files on servers. Unfortunately I got weird results here and there. I figured if I could only have a testing framework for Net::SFTP, I could use it instead of doing hackery around it. I could also write a testing suite based on it. Testing suites are one of the best tools available to a sysadmin.

Anyway, without further ado, I present you Test::SFTP 0.01!

Test::SFTP provides the following methods:
  • connect (internally-used method)
  • can_connect
  • cannot_connect
  • is_status
  • is_status_number
  • is_status_string
  • can_get
  • cannot_get
  • can_put
  • cannot_put
  • can_ls
  • cannot_ls

Also, it has the following attributes:

  • Net::SFTP attributes:
    • host
    • user
    • password
    • debug
    • warn
    • ssh_args
  • object
  • connected
  • auto_connect

A few highlights:

  • Allows direct object access through $t_sftp->object
  • Uses Moose!
  • Automatic connect when using methods that require connectivity
  • Allows pretty much all major Net::SFTP methods
  • Complete testing suite (unlike Net::SFTP *cough*) for all functions, bearing you set TEST_SFTP_RUN_TEST=1

Some more stuff I want to add:

  • Allow not to connect automatically - forget to write it in the first version
  • Support every Net::SFTP methods
  • Timeout option for connection
  • Support the remote path in can_get, cannot_get
  • Write an SSH server or something, to control the testing

Things will have to wait a bit with this, because I've gotten the crucial part I needed from it. I'll definitely keep it updated, but probably will take more than a few days to be updated with more stuff. :)


The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.