1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Promote net-pop to the bundled gems

This commit is contained in:
Hiroshi SHIBATA 2021-05-26 15:52:29 +09:00
parent d5bc6b2337
commit aa9726f7b9
Notes: git 2021-05-27 14:42:37 +09:00
8 changed files with 4 additions and 1234 deletions

View file

@ -158,10 +158,6 @@ Yukihiro Matsumoto (matz)
NARUSE, Yui (naruse)
https://github.com/ruby/net-http
https://rubygems.org/gems/net-http
[lib/net/pop.rb]
_unmaintained_
https://github.com/ruby/net-pop
https://rubygems.org/gems/net-pop
[lib/net/smtp.rb]
TOMITA Masahiro (tmtm)
https://github.com/ruby/net-smtp
@ -387,6 +383,8 @@ Yukihiro Matsumoto (matz)
https://github.com/ruby/net-ftp
[net-imap]
https://github.com/ruby/net-imap
[net-pop]
https://github.com/ruby/net-pop
[matrix]
https://github.com/ruby/matrix
[prime]

View file

@ -47,7 +47,6 @@ OptionParser:: Ruby-oriented class for command-line option analysis
Logger:: Provides a simple logging utility for outputting messages
Mutex_m:: Mixin to extend objects to be handled like a Mutex
Net::HTTP:: HTTP client api for Ruby
Net::POP3:: Ruby client library for POP3
Net::SMTP:: Simple Mail Transfer Protocol client library for Ruby
Observable:: Provides a mechanism for publish/subscribe pattern in Ruby
Open3:: Provides access to stdin, stdout and stderr when running other programs
@ -109,6 +108,7 @@ REXML:: An XML toolkit for Ruby
RSS:: Family of libraries that support various formats of XML "feeds"
Net::FTP:: Support for the File Transfer Protocol
Net::IMAP:: Ruby client api for Internet Message Access Protocol
Net::POP3:: Ruby client library for POP3
Matrix:: Represents a mathematical matrix.
Prime:: Prime numbers and factorization library
RBS:: RBS is a language to describe the structure of Ruby programs

View file

@ -7,6 +7,7 @@ rexml 3.2.5 https://github.com/ruby/rexml
rss 0.2.9 https://github.com/ruby/rss 0.2.9
net-ftp 0.1.2 https://github.com/ruby/net-ftp
net-imap 0.2.1 https://github.com/ruby/net-imap
net-pop 0.1.1 https://github.com/ruby/net-pop
matrix 0.4.1 https://github.com/ruby/matrix
prime 0.1.2 https://github.com/ruby/prime
typeprof 0.14.1 https://github.com/ruby/typeprof

View file

@ -1,34 +0,0 @@
# frozen_string_literal: true
name = File.basename(__FILE__, ".gemspec")
version = ["lib", Array.new(name.count("-"), "..").join("/")].find do |dir|
break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
/^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
end rescue nil
end
Gem::Specification.new do |spec|
spec.name = name
spec.version = version
spec.authors = ["Yukihiro Matsumoto"]
spec.email = ["matz@ruby-lang.org"]
spec.summary = %q{Ruby client library for POP3.}
spec.description = %q{Ruby client library for POP3.}
spec.homepage = "https://github.com/ruby/net-pop"
spec.licenses = ["Ruby", "BSD-2-Clause"]
spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = spec.homepage
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
`git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.add_dependency "net-protocol"
spec.add_dependency "digest"
spec.add_dependency "timeout"
end

File diff suppressed because it is too large Load diff

View file

@ -80,7 +80,6 @@ DEFAULT_GEM_LIBS = %w[
logger
mutex_m
net-http
net-pop
net-protocol
net-smtp
observer

View file

@ -1,166 +0,0 @@
# frozen_string_literal: true
require 'net/pop'
require 'test/unit'
require 'digest/md5'
class TestPOP < Test::Unit::TestCase
def setup
@users = {'user' => 'pass' }
@ok_user = 'user'
@stamp_base = "#{$$}.#{Time.now.to_i}@localhost"
end
def test_pop_auth_ok
pop_test(false) do |pop|
assert_instance_of Net::POP3, pop
assert_nothing_raised do
pop.start(@ok_user, @users[@ok_user])
end
end
end
def test_pop_auth_ng
pop_test(false) do |pop|
assert_instance_of Net::POP3, pop
assert_raise Net::POPAuthenticationError do
pop.start(@ok_user, 'bad password')
end
end
end
def test_apop_ok
pop_test(@stamp_base) do |pop|
assert_instance_of Net::APOP, pop
assert_nothing_raised do
pop.start(@ok_user, @users[@ok_user])
end
end
end
def test_apop_ng
pop_test(@stamp_base) do |pop|
assert_instance_of Net::APOP, pop
assert_raise Net::POPAuthenticationError do
pop.start(@ok_user, 'bad password')
end
end
end
def test_apop_invalid
pop_test("\x80"+@stamp_base) do |pop|
assert_instance_of Net::APOP, pop
assert_raise Net::POPAuthenticationError do
pop.start(@ok_user, @users[@ok_user])
end
end
end
def test_apop_invalid_at
pop_test(@stamp_base.sub('@', '.')) do |pop|
assert_instance_of Net::APOP, pop
assert_raise Net::POPAuthenticationError do
pop.start(@ok_user, @users[@ok_user])
end
end
end
def test_popmail
# totally not representative of real messages, but
# enough to test frozen bugs
lines = [ "[ruby-core:85210]" , "[Bug #14416]" ].freeze
command = Object.new
command.instance_variable_set(:@lines, lines)
def command.retr(n)
@lines.each { |l| yield "#{l}\r\n" }
end
def command.top(number, nl)
@lines.each do |l|
yield "#{l}\r\n"
break if (nl -= 1) <= 0
end
end
net_pop = :unused
popmail = Net::POPMail.new(1, 123, net_pop, command)
res = popmail.pop
assert_equal "[ruby-core:85210]\r\n[Bug #14416]\r\n", res
assert_not_predicate res, :frozen?
res = popmail.top(1)
assert_equal "[ruby-core:85210]\r\n", res
assert_not_predicate res, :frozen?
end
def pop_test(apop=false)
host = 'localhost'
server = TCPServer.new(host, 0)
port = server.addr[1]
server_thread = Thread.start do
sock = server.accept
begin
pop_server_loop(sock, apop)
ensure
sock.close
end
end
client_thread = Thread.start do
begin
begin
pop = Net::POP3::APOP(apop).new(host, port)
#pop.set_debug_output $stderr
yield pop
ensure
begin
pop.finish
rescue IOError
raise unless $!.message == "POP session not yet started"
end
end
ensure
server.close
end
end
assert_join_threads([client_thread, server_thread])
end
def pop_server_loop(sock, apop)
if apop
sock.print "+OK ready <#{apop}>\r\n"
else
sock.print "+OK ready\r\n"
end
user = nil
while line = sock.gets
case line
when /^USER (.+)\r\n/
user = $1
if @users.key?(user)
sock.print "+OK\r\n"
else
sock.print "-ERR unknown user\r\n"
end
when /^PASS (.+)\r\n/
if @users[user] == $1
sock.print "+OK\r\n"
else
sock.print "-ERR invalid password\r\n"
end
when /^APOP (.+) (.+)\r\n/
user = $1
if apop && Digest::MD5.hexdigest("<#{apop}>#{@users[user]}") == $2
sock.print "+OK\r\n"
else
sock.print "-ERR authentication failed\r\n"
end
when /^QUIT/
sock.print "+OK bye\r\n"
return
else
sock.print "-ERR command not recognized\r\n"
return
end
end
end
end

View file

@ -35,7 +35,6 @@ REPOSITORIES = {
pstore: "ruby/pstore",
delegate: "ruby/delegate",
benchmark: "ruby/benchmark",
"net-pop": "ruby/net-pop",
"net-smtp": "ruby/net-smtp",
cgi: "ruby/cgi",
readline: "ruby/readline",
@ -244,11 +243,6 @@ def sync_default_gems(gem)
cp_r("#{upstream}/openssl.gemspec", "ext/openssl")
cp_r("#{upstream}/History.md", "ext/openssl")
`git checkout ext/openssl/depend`
when "net-pop"
rm_rf(%w[lib/net/pop.rb lib/net/net-pop.gemspec test/net/pop])
cp_r("#{upstream}/lib/net/pop.rb", "lib/net")
cp_r("#{upstream}/test/net/pop", "test/net")
cp_r("#{upstream}/net-pop.gemspec", "lib/net")
when "net-smtp"
rm_rf(%w[lib/net/smtp.rb lib/net/net-smtp.gemspec test/net/smtp])
cp_r("#{upstream}/lib/net/smtp.rb", "lib/net")