Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deps and fix tests for new Ruby versions #59

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby

name: Ruby
on: [push]
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: [ '2.7', '3.0', '3.1', '3.2', '3.3', '3.4' ]
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run tests
run: bundle exec rake
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

64 changes: 0 additions & 64 deletions Gemfile.lock

This file was deleted.

27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,20 +256,20 @@ See [RFC Compliance](doc/rfc-compliance.md) for details

The tests pass with these Rubies:

* ruby-1.9.3
* ruby-2.0
* ruby-2.1
* ruby-2.2
* ruby-2.3
* ruby-2.4 (but see below)
* ruby-2.7 (EOL: 2023-03-31)
* ruby-3.0 (EOL: 2024-03-31)
* ruby-3.1 (EOL: 2025-03-31)
* ruby-3.2
* ruby-3.3
* ruby-3.4

For Ruby 1.8, use an ftpd version before 0.8. In your Gemfile:

gem 'ftpd', '<0.8'

This gem runs fine in Ruby 2.4, but the tests that use TLS are skipped
in Ruby 2.4. That is because the double_bag_ftps gem that the tests
use for TLS does not work in Ruby 2.4.
For Ruby 2.6, use ftpd version 2.1.0. In your Gemfile:

gem 'ftpd', '2.1.0'

## OS compatability

Expand All @@ -278,7 +278,7 @@ use for TLS does not work in Ruby 2.4.
Ftpd runs on:

* Linux
* OSX
* MacOS

## Windows

Expand All @@ -302,6 +302,12 @@ major version.

### Tests

On MacOS, you need to add a loopback alias for 127.0.0.2 (used in specs):

```bash
sudo ifconfig lo0 alias 127.0.0.2 up
```

To run the cucumber (functional) tests:

$ rake test:features
Expand Down Expand Up @@ -371,6 +377,7 @@ Among those who have improved ftpd are:
* Michael de Silva
* Mike Ragalie
* cransom
* Jonathan Tron

If I've forgotten to add you, please remind me, or submit a merge
request.
Expand Down
1 change: 1 addition & 0 deletions cucumber.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default: --publish-quiet
2 changes: 2 additions & 0 deletions features/ftp_server/features.feature
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ Feature: Features

Scenario: IPV6 Extensions
Given the test server is started
And the client connects
When the client successfully requests features
Then the response should include feature "EPRT"
And the response should include feature "EPSV"

Scenario: RFC 3659 Extensions
Given the test server is started
And the client connects
When the client successfully requests features
Then the response should include feature "SIZE"
Then the response should include feature "MDTM"
6 changes: 3 additions & 3 deletions features/ftp_server/timeout.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ Feature: Port
So that I can claim RFC compliance

Scenario: Session idle too long
Given the test server has session timeout set to 0.5 seconds
Given the test server has session timeout set to 1 seconds
And the test server is started
And a successful login
When the client is idle for 0.6 seconds
When the client is idle for 1.1 seconds
Then the client should not be connected

Scenario: Session not idle too long
Given the test server has session timeout set to 0.5 seconds
Given the test server has session timeout set to 1 seconds
And the test server is started
And a successful login
When the client is idle for 0 seconds
Expand Down
5 changes: 2 additions & 3 deletions features/step_definitions/connect.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

require 'double_bag_ftps'
require 'net/ftp'

When /^the( \w+)? client connects(?: with (\w+) TLS)?$/ do
Expand All @@ -17,9 +16,9 @@
end

When /^the (\d+)rd client tries to connect$/ do |client_name|
client(client_name).start
client(client_name.to_s).start
capture_error do
client(client_name).connect(server.host, server.port)
client(client_name.to_s).connect(server.host, server.port)
end
end

Expand Down
37 changes: 18 additions & 19 deletions features/support/test_client.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# frozen_string_literal: true

require 'double_bag_ftps'
require 'net/ftp'

if Gem::Version.new(Net::FTP::VERSION) <= Gem::Version.new("0.3.8") && defined? Net::FTP::BufferedSSLSocket
class Net::FTP::BufferedSSLSocket
def shutdown(*args)
@io.__send__(:stop)
end
end
end

class TestClient

CannotTestTls = Class.new(StandardError)
Expand Down Expand Up @@ -135,8 +142,8 @@ def connected?
ftp.noop
true
rescue Net::FTPTempError => e
!!e.to_s =~ /^421/
rescue EOFError
e.message !~ /^421/
rescue EOFError, Net::FTPConnectionError
false
end
end
Expand All @@ -146,7 +153,7 @@ def set_option(option)
end

private

RAW_METHOD_REGEX = /^send_(.*)$/

def ftp
Expand Down Expand Up @@ -180,28 +187,20 @@ def make_ftp

def make_tls_ftp(ftps_mode)
ensure_can_test_tls
ftp = DoubleBagFTPS.new
context_opts = {
:verify_mode => OpenSSL::SSL::VERIFY_NONE
opts = {
:ssl => {
:verify_mode => OpenSSL::SSL::VERIFY_NONE,
},
:implicit_ftps => ftps_mode==:implicit
}
ftp.ssl_context = DoubleBagFTPS.create_ssl_context(context_opts)
ftp.ftps_mode = ftps_mode
ftp
Net::FTP.new nil, opts
end

def ensure_can_test_tls
return if can_test_tls?
return if defined?(OpenSSL::SSL)
raise CannotTestTls, "Cannot test TLS with this Ruby version"
end

def can_test_tls?
!double_bag_ftps_busted?
end

def double_bag_ftps_busted?
Gem::Dependency.new('', '~> 2.4.0').match?('', RUBY_VERSION)
end

def make_non_tls_ftp
Net::FTP.new
end
Expand Down
16 changes: 8 additions & 8 deletions ftpd.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Readme

README_PATH = File.expand_path("README.md", File.dirname(__FILE__))
private_constant :README_PATH

def remove_markdown_link(description)
regex = %r{
\[
Expand Down Expand Up @@ -76,16 +76,16 @@ Gem::Specification.new do |s|
s.files += Dir["lib/**/*.rb"]
s.homepage = "http://github.com/wconrad/ftpd"
s.licenses = ["MIT"]
s.required_ruby_version = ">= 1.9.3"
s.required_ruby_version = ">= 2.7.8"
s.rubygems_version = "2.5.1"
s.summary = "Pure Ruby FTP server library"
s.add_runtime_dependency("memoizer", "~> 1.0")
s.add_development_dependency("cucumber", "~> 2.0")
s.add_development_dependency("double-bag-ftps", "~> 0.1", ">= 0.1.4")
s.add_development_dependency("rake", "~> 11.1")
s.add_development_dependency("redcarpet", "~> 3.1")
s.add_development_dependency("net-ftp", "~> 0.3")
s.add_development_dependency("cucumber", "~> 9.1")
s.add_development_dependency("rake", "~> 13.1")
s.add_development_dependency("redcarpet", "~> 3.6")
s.add_development_dependency("rspec", "~> 3.1")
s.add_development_dependency("rspec-its", "~> 1.0")
s.add_development_dependency("timecop", "~> 0.7")
s.add_development_dependency("yard", "~> 0.8.7")
s.add_development_dependency("timecop", "~> 0.9")
s.add_development_dependency("yard", "~> 0.9")
end
Loading