
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
Test your FTP calls offline.
Is It Working? | Is It Tested? | Code Quality | # of Downloads | Get Involved! |
---|---|---|---|---|
![]() | ![]() | ![]() | ![]() | ![]() |
---|
Add this line to your application's Gemfile:
group :test do
gem 'ftpmock'
end
If you know your way around tests
require 'ftpmock'
RSpec.configure do |config|
config.around(:example) do |example|
Ftpmock.on! do
example.run
end
end
end
If you need to see a full example
require 'rubygems'
require 'test/unit'
require 'ftpmock'
# Optional (default values)
Ftpmock.configure do |c|
c.path = 'test/ftp_records'
c.verbose = true
end
class FtpmockTest < Test::Unit::TestCase
def test_ubuntu_mirror
Ftpmock.on! do
# Ubuntu Download - University of Pittsburgh
ftp = Net::FTP.new
assert_equal(Ftpmock::NetFtpProxy, ftp.class)
assert ftp.connect('mirror.cs.pitt.edu', 21)
assert ftp.login('', '')
t = Time.now
3.times do |i|
list = ftp.list('/ubuntu/releases')
assert list.size.positive?
ftp.get('/ubuntu/releases/robots.txt', 'tmp/ubuntu_robots.txt')
assert File.exist?('tmp/ubuntu_robots.txt')
puts "[Take #{i+1}] #{(Time.now-t).round(3)}s"
end
end
end
end
Run this test once, and Ftpmock will record the FTP requests to test/ftp_records/mirror-cs-pitt-edu_21__/
Run it again, and Ftpmock will replay the responses from mirror.cs.pitt.edu when the FTP request is made.
Your tests are now blazing fast because no real FTP requests are made anymore.
The test will continue to pass, even if you are offline, or if the University of Pittsburgh FTP servers are down for maintenance.
The responses will be accurate since they will contain the same list and files you get from a real request.
Unlike VCR, Ftpmock combines your four credentials (address + port + username + password) and caches onto the exact same directory, optimizing for both storage and readability.
After checking out the repo, run bin/setup
to install dependencies.
Then, run bundle exec rake spec
to run the tests.
You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
.
links: lib/ftpmock/core
links: lib/ftpmock/proxies/net_ftp_proxy.rb , https://apidock.com/ruby/Net/FTP & https://github.com/ruby/ruby/tree/master/lib/net
links: lib/ftpmock/proxies/net_sftp_proxy.rb , https://rubygems.org/gems/net-sftp & https://github.com/net-ssh/net-sftp
Bug reports and pull requests are welcome on GitHub at https://github.com/thejamespinto/ftpmock.
Changelog can be found at CHANGELOG.md
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that ftpmock demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.