Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Test your FTP calls offline.
Is It Working? | Is It Tested? | Code Quality | # of Downloads | Get Involved! |
---|---|---|---|---|
Ruby 2.3 | Ruby 2.4 | Ruby 2.5 | Ruby 2.6 | Ruby 2.7 |
---|
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.