[前][次][番号順一覧][スレッド一覧]

ruby-changes:52251

From: eregon <ko1@a...>
Date: Sun, 19 Aug 2018 04:55:14 +0900 (JST)
Subject: [ruby-changes:52251] eregon:r64460 (trunk): Use ftp for the service in getaddrinfo/getnameinfo/getservbyname specs

eregon	2018-08-19 04:36:57 +0900 (Sun, 19 Aug 2018)

  New Revision: 64460

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64460

  Log:
    Use ftp for the service in getaddrinfo/getnameinfo/getservbyname specs
    
    * Solaris cannot resolve 'http' but can resolve 'ftp'.

  Modified files:
    trunk/spec/ruby/library/socket/addrinfo/getnameinfo_spec.rb
    trunk/spec/ruby/library/socket/socket/getaddrinfo_spec.rb
    trunk/spec/ruby/library/socket/socket/getnameinfo_spec.rb
    trunk/spec/ruby/library/socket/socket/getservbyname_spec.rb
Index: spec/ruby/library/socket/socket/getservbyname_spec.rb
===================================================================
--- spec/ruby/library/socket/socket/getservbyname_spec.rb	(revision 64459)
+++ spec/ruby/library/socket/socket/getservbyname_spec.rb	(revision 64460)
@@ -10,12 +10,12 @@ describe "Socket#getservbyname" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getservbyname_spec.rb#L10
     Socket.getservbyname('discard', 'tcp').should == 9
   end
 
-  it 'returns the port for service "http"' do
-    Socket.getservbyname('http').should == 80
+  it 'returns the port for service "ftp"' do
+    Socket.getservbyname('ftp').should == 21
   end
 
-  it 'returns the port for service "http" with protocol "tcp"' do
-    Socket.getservbyname('http', 'tcp').should == 80
+  it 'returns the port for service "ftp" with protocol "tcp"' do
+    Socket.getservbyname('ftp', 'tcp').should == 21
   end
 
   it "returns the port for service 'domain' with protocol 'udp'" do
Index: spec/ruby/library/socket/socket/getaddrinfo_spec.rb
===================================================================
--- spec/ruby/library/socket/socket/getaddrinfo_spec.rb	(revision 64459)
+++ spec/ruby/library/socket/socket/getaddrinfo_spec.rb	(revision 64460)
@@ -112,14 +112,14 @@ end https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getaddrinfo_spec.rb#L112
 describe 'Socket.getaddrinfo' do
   describe 'without global reverse lookups' do
     it 'returns an Array' do
-      Socket.getaddrinfo(nil, 'http').should be_an_instance_of(Array)
+      Socket.getaddrinfo(nil, 'ftp').should be_an_instance_of(Array)
     end
 
     it 'accepts a Fixnum as the address family' do
-      array = Socket.getaddrinfo(nil, 'http', Socket::AF_INET)[0]
+      array = Socket.getaddrinfo(nil, 'ftp', Socket::AF_INET)[0]
 
       array[0].should == 'AF_INET'
-      array[1].should == 80
+      array[1].should == 21
       array[2].should == '127.0.0.1'
       array[3].should == '127.0.0.1'
       array[4].should == Socket::AF_INET
@@ -128,10 +128,10 @@ describe 'Socket.getaddrinfo' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getaddrinfo_spec.rb#L128
     end
 
     it 'accepts a Fixnum as the address family using IPv6' do
-      array = Socket.getaddrinfo(nil, 'http', Socket::AF_INET6)[0]
+      array = Socket.getaddrinfo(nil, 'ftp', Socket::AF_INET6)[0]
 
       array[0].should == 'AF_INET6'
-      array[1].should == 80
+      array[1].should == 21
       array[2].should == '::1'
       array[3].should == '::1'
       array[4].should == Socket::AF_INET6
@@ -140,10 +140,10 @@ describe 'Socket.getaddrinfo' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getaddrinfo_spec.rb#L140
     end
 
     it 'accepts a Symbol as the address family' do
-      array = Socket.getaddrinfo(nil, 'http', :INET)[0]
+      array = Socket.getaddrinfo(nil, 'ftp', :INET)[0]
 
       array[0].should == 'AF_INET'
-      array[1].should == 80
+      array[1].should == 21
       array[2].should == '127.0.0.1'
       array[3].should == '127.0.0.1'
       array[4].should == Socket::AF_INET
@@ -152,10 +152,10 @@ describe 'Socket.getaddrinfo' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getaddrinfo_spec.rb#L152
     end
 
     it 'accepts a Symbol as the address family using IPv6' do
-      array = Socket.getaddrinfo(nil, 'http', :INET6)[0]
+      array = Socket.getaddrinfo(nil, 'ftp', :INET6)[0]
 
       array[0].should == 'AF_INET6'
-      array[1].should == 80
+      array[1].should == 21
       array[2].should == '::1'
       array[3].should == '::1'
       array[4].should == Socket::AF_INET6
@@ -164,10 +164,10 @@ describe 'Socket.getaddrinfo' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getaddrinfo_spec.rb#L164
     end
 
     it 'accepts a String as the address family' do
-      array = Socket.getaddrinfo(nil, 'http', 'INET')[0]
+      array = Socket.getaddrinfo(nil, 'ftp', 'INET')[0]
 
       array[0].should == 'AF_INET'
-      array[1].should == 80
+      array[1].should == 21
       array[2].should == '127.0.0.1'
       array[3].should == '127.0.0.1'
       array[4].should == Socket::AF_INET
@@ -176,10 +176,10 @@ describe 'Socket.getaddrinfo' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getaddrinfo_spec.rb#L176
     end
 
     it 'accepts a String as the address family using IPv6' do
-      array = Socket.getaddrinfo(nil, 'http', 'INET6')[0]
+      array = Socket.getaddrinfo(nil, 'ftp', 'INET6')[0]
 
       array[0].should == 'AF_INET6'
-      array[1].should == 80
+      array[1].should == 21
       array[2].should == '::1'
       array[3].should == '::1'
       array[4].should == Socket::AF_INET6
@@ -192,10 +192,10 @@ describe 'Socket.getaddrinfo' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getaddrinfo_spec.rb#L192
 
       dummy.stub!(:to_str).and_return('127.0.0.1')
 
-      array = Socket.getaddrinfo(dummy, 'http')[0]
+      array = Socket.getaddrinfo(dummy, 'ftp')[0]
 
       array[0].should == 'AF_INET'
-      array[1].should == 80
+      array[1].should == 21
       array[2].should == '127.0.0.1'
       array[3].should == '127.0.0.1'
       array[4].should == Socket::AF_INET
@@ -208,10 +208,10 @@ describe 'Socket.getaddrinfo' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getaddrinfo_spec.rb#L208
 
       dummy.stub!(:to_str).and_return('INET')
 
-      array = Socket.getaddrinfo(nil, 'http', dummy)[0]
+      array = Socket.getaddrinfo(nil, 'ftp', dummy)[0]
 
       array[0].should == 'AF_INET'
-      array[1].should == 80
+      array[1].should == 21
       array[2].should == '127.0.0.1'
       array[3].should == '127.0.0.1'
       array[4].should == Socket::AF_INET
@@ -225,9 +225,9 @@ describe 'Socket.getaddrinfo' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getaddrinfo_spec.rb#L225
     end
 
     it 'accepts a Fixnum as the socket type' do
-      Socket.getaddrinfo(nil, 'http', :INET, Socket::SOCK_STREAM)[0].should == [
+      Socket.getaddrinfo(nil, 'ftp', :INET, Socket::SOCK_STREAM)[0].should == [
         'AF_INET',
-        80,
+        21,
         '127.0.0.1',
         '127.0.0.1',
         Socket::AF_INET,
@@ -237,9 +237,9 @@ describe 'Socket.getaddrinfo' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getaddrinfo_spec.rb#L237
     end
 
     it 'accepts a Symbol as the socket type' do
-      Socket.getaddrinfo(nil, 'http', :INET, :STREAM)[0].should == [
+      Socket.getaddrinfo(nil, 'ftp', :INET, :STREAM)[0].should == [
         'AF_INET',
-        80,
+        21,
         '127.0.0.1',
         '127.0.0.1',
         Socket::AF_INET,
@@ -249,9 +249,9 @@ describe 'Socket.getaddrinfo' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getaddrinfo_spec.rb#L249
     end
 
     it 'accepts a String as the socket type' do
-      Socket.getaddrinfo(nil, 'http', :INET, 'STREAM')[0].should == [
+      Socket.getaddrinfo(nil, 'ftp', :INET, 'STREAM')[0].should == [
         'AF_INET',
-        80,
+        21,
         '127.0.0.1',
         '127.0.0.1',
         Socket::AF_INET,
@@ -265,9 +265,9 @@ describe 'Socket.getaddrinfo' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getaddrinfo_spec.rb#L265
 
       dummy.stub!(:to_str).and_return('STREAM')
 
-      Socket.getaddrinfo(nil, 'http', :INET, dummy)[0].should == [
+      Socket.getaddrinfo(nil, 'ftp', :INET, dummy)[0].should == [
         'AF_INET',
-        80,
+        21,
         '127.0.0.1',
         '127.0.0.1',
         Socket::AF_INET,
@@ -293,12 +293,12 @@ describe 'Socket.getaddrinfo' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getaddrinfo_spec.rb#L293
     end
 
     it 'accepts a Fixnum as the flags' do
-      addr = Socket.getaddrinfo(nil, 'http', :INET, :STREAM,
+      addr = Socket.getaddrinfo(nil, 'ftp', :INET, :STREAM,
                                 Socket::IPPROTO_TCP, Socket::AI_PASSIVE)
 
       addr[0].should == [
         'AF_INET',
-        80,
+        21,
         '0.0.0.0',
         '0.0.0.0',
         Socket::AF_INET,
@@ -308,11 +308,11 @@ describe 'Socket.getaddrinfo' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getaddrinfo_spec.rb#L308
     end
 
     it 'performs a reverse lookup when the reverse_lookup argument is true' do
-      addr = Socket.getaddrinfo(nil, 'http', :INET, :STREAM,
+      addr = Socket.getaddrinfo(nil, 'ftp', :INET, :STREAM,
                                 Socket::IPPROTO_TCP, 0, true)[0]
 
       addr[0].should == 'AF_INET'
-      addr[1].should == 80
+      addr[1].should == 21
 
       addr[2].should be_an_instance_of(String)
       addr[2].should_not == addr[3]
@@ -321,11 +321,11 @@ describe 'Socket.getaddrinfo' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getaddrinfo_spec.rb#L321
     end
 
     it 'performs a reverse lookup when the reverse_lookup argument is :hostname' do
-      addr = Socket.getaddrinfo(nil, 'http', :INET, :STREAM,
+      addr = Socket.getaddrinfo(nil, 'ftp', :INET, :STREAM,
                                 Socket::IPPROTO_TCP, 0, :hostname)[0]
 
       addr[0].should == 'AF_INET'
-      addr[1].should == 80
+      addr[1].should == 21
 
       addr[2].should be_an_instance_of(String)
       addr[2].should_not == addr[3]
@@ -334,12 +334,12 @@ describe 'Socket.getaddrinfo' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getaddrinfo_spec.rb#L334
     end
 
     it 'performs a reverse lookup when the reverse_lookup argument is :numeric' do
-      addr = Socket.getaddrinfo(nil, 'http', :INET, :STREAM,
+      addr = Socket.getaddrinfo(nil, 'ftp', :INET, :STREAM,
                                 Socket::IPPROTO_TCP, 0, :numeric)[0]
 
       addr.should == [
         'AF_INET',
-        80,
+        21,
         '127.0.0.1',
         '127.0.0.1',
         Socket::AF_INET,
@@ -360,10 +360,10 @@ describe 'Socket.getaddrinfo' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getaddrinfo_spec.rb#L360
     end
 
     it 'returns an address honoring the global lookup option' do
-      addr = Socket.getaddrinfo(nil, 'http', :INET)[0]
+      addr = Socket.getaddrinfo(nil, 'ftp', :INET)[0]
 
       addr[0].should == 'AF_INET'
-      addr[1].should == 80
+      addr[1].should == 21
 
       # We don't have control over this value and there's no way to test this
       # without relying on Socket.getaddrinfo()'s own behaviour (meaning this
Index: spec/ruby/library/socket/socket/getnameinfo_spec.rb
===================================================================
--- spec/ruby/library/socket/socket/getnameinfo_spec.rb	(revision 64459)
+++ spec/ruby/library/socket/socket/getnameinfo_spec.rb	(revision 64460)
@@ -65,7 +65,7 @@ end https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getnameinfo_spec.rb#L65
 describe 'Socket.getnameinfo' do
   describe 'using a String as the first argument' do
     before do
-      @addr = Socket.sockaddr_in(80, '127.0.0.1')
+      @addr = Socket.sockaddr_in(21, '127.0.0.1')
     end
 
     it 'raises SocketError or TypeError when using an invalid String' do
@@ -76,7 +76,7 @@ describe 'Socket.getnameinfo' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getnameinfo_spec.rb#L76
 
     describe 'without custom flags' do
       it 'returns an Array containing the hostname and service name' do
-        Socket.getnameinfo(@addr).should == [SocketSpecs.hostname_reverse_lookup, 'http']
+        Socket.getnameinfo(@addr).should == [SocketSpecs.hostname_reverse_lookup, 'ftp']
       end
     end
 
@@ -86,7 +86,7 @@ describe 'Socket.getnameinfo' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getnameinfo_spec.rb#L86
 
         %w{127.0.0.1 ::1}.include?(array[0]).should == true
 
-        array[1].should == 'http'
+        array[1].should == 'ftp'
       end
     end
   end
@@ -98,7 +98,7 @@ describe 'Socket.getnameinfo' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getnameinfo_spec.rb#L98
 
     describe 'using a 3 element Array as the first argument' do
       before do
-        @addr = [family_name, 80, @hostname]
+        @addr = [family_name, 21, @hostname]
       end
 
       it 'raises ArgumentError when using an invalid Array' do
@@ -110,14 +110,14 @@ describe 'Socket.getnameinfo' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getnameinfo_spec.rb#L110
           array = Socket.getnameinfo(@addr)
           array.should be_an_instance_of(Array)
           array[0].should include(@hostname)
-          array[1].should == 'http'
+          array[1].should == 'ftp'
         end
       end
 
       platform_is_not :windows do
         describe 'using NI_NUMERICHOST as the flag' do
           it 'returns an Array containing the numeric hostname and service name' do
-            Socket.getnameinfo(@addr, Socket::NI_NUMERICHOST).should == [ip_address, 'http']
+            Socket.getnameinfo(@addr, Socket::NI_NUMERICHOST).should == [ip_address, 'ftp']
           end
         end
       end
@@ -125,7 +125,7 @@ describe 'Socket.getnameinfo' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getnameinfo_spec.rb#L125
 
     describe 'using a 4 element Array as the first argument' do
       before do
-        @addr = [family_name, 80, ip_address, ip_address]
+        @addr = [family_name, 21, ip_address, ip_address]
       end
 
       describe 'without custom flags' do
@@ -133,22 +133,22 @@ describe 'Socket.getnameinfo' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/getnameinfo_spec.rb#L133
           array = Socket.getnameinfo(@addr)
           array.should be_an_instance_of(Array)
           array[0].should == @hostname
-          array[1].should == 'http'
+          array[1].should == 'ftp'
         end
 
         it 'uses the 3rd value as the hostname if the 4th is not present' do
-          addr = [family_name, 80, ip_address, nil]
+          addr = [family_name, 21, ip_address, nil]
 
           array = Socket.getnameinfo(addr)
           array.should be_an_instance_of(Array)
           array[0].should == @hostname
-          array[1].should == 'http'
+          array[1].should == 'ftp'
         end
       end
 
       describe 'using NI_NUMERICHOST as the flag' do
         it 'returns an Array containing the numeric hostname and service name' do
-          Socket.getnameinfo(@addr, Socket::NI_NUMERICHOST).should == [ip_address, 'http']
+          Socket.getnameinfo(@addr, Socket::NI_NUMERICHOST).should == [ip_address, 'ftp']
         end
       end
     end
Index: spec/ruby/library/socket/addrinfo/getnameinfo_spec.rb
===================================================================
--- spec/ruby/library/socket/addrinfo/getnameinfo_spec.rb	(revision 64459)
+++ spec/ruby/library/socket/addrinfo/getnameinfo_spec.rb	(revision 64460)
@@ -5,26 +5,17 @@ describe 'Addrinfo#getnameinfo' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/addrinfo/getnameinfo_spec.rb#L5
   describe 'using an IP Addrinfo' do
     SocketSpecs.each_ip_protocol do |family, ip_address|
       before do
-        @addr = Addrinfo.tcp(ip_address, 80)
+        @addr = Addrinfo.tcp(ip_address, 21)
       end
 
-      platform_is_not :solaris do
-        it 'returns the node and service names' do
-          host, service = @addr.getnameinfo
-          service.should == 'http'
-        end
-      end
-
-      platform_is :solaris do
-        it 'returns the node and service names' do
-          host, service = @addr.getnameinfo
-          service.should == '80'
-        end
+      it 'returns the node and service names' do
+        host, service = @addr.getnameinfo
+        service.should == 'ftp'
       end
 
       it 'accepts flags as a Fixnum as the first argument' do
         host, service = @addr.getnameinfo(Socket::NI_NUMERICSERV)
-        service.should == '80'
+        service.should == '21'
       end
     end
   end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]